babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330
  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. * Utility function to detect if the current user agent is Safari
  35262. * @returns whether or not the current user agent is safari
  35263. */
  35264. static IsSafari(): boolean;
  35265. }
  35266. /**
  35267. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35268. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35269. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35270. * @param name The name of the class, case should be preserved
  35271. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35272. */
  35273. export function className(name: string, module?: string): (target: Object) => void;
  35274. /**
  35275. * An implementation of a loop for asynchronous functions.
  35276. */
  35277. export class AsyncLoop {
  35278. /**
  35279. * Defines the number of iterations for the loop
  35280. */
  35281. iterations: number;
  35282. /**
  35283. * Defines the current index of the loop.
  35284. */
  35285. index: number;
  35286. private _done;
  35287. private _fn;
  35288. private _successCallback;
  35289. /**
  35290. * Constructor.
  35291. * @param iterations the number of iterations.
  35292. * @param func the function to run each iteration
  35293. * @param successCallback the callback that will be called upon succesful execution
  35294. * @param offset starting offset.
  35295. */
  35296. constructor(
  35297. /**
  35298. * Defines the number of iterations for the loop
  35299. */
  35300. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35301. /**
  35302. * Execute the next iteration. Must be called after the last iteration was finished.
  35303. */
  35304. executeNext(): void;
  35305. /**
  35306. * Break the loop and run the success callback.
  35307. */
  35308. breakLoop(): void;
  35309. /**
  35310. * Create and run an async loop.
  35311. * @param iterations the number of iterations.
  35312. * @param fn the function to run each iteration
  35313. * @param successCallback the callback that will be called upon succesful execution
  35314. * @param offset starting offset.
  35315. * @returns the created async loop object
  35316. */
  35317. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35318. /**
  35319. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35320. * @param iterations total number of iterations
  35321. * @param syncedIterations number of synchronous iterations in each async iteration.
  35322. * @param fn the function to call each iteration.
  35323. * @param callback a success call back that will be called when iterating stops.
  35324. * @param breakFunction a break condition (optional)
  35325. * @param timeout timeout settings for the setTimeout function. default - 0.
  35326. * @returns the created async loop object
  35327. */
  35328. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35329. }
  35330. }
  35331. declare module "babylonjs/Misc/stringDictionary" {
  35332. import { Nullable } from "babylonjs/types";
  35333. /**
  35334. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35335. * The underlying implementation relies on an associative array to ensure the best performances.
  35336. * The value can be anything including 'null' but except 'undefined'
  35337. */
  35338. export class StringDictionary<T> {
  35339. /**
  35340. * This will clear this dictionary and copy the content from the 'source' one.
  35341. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35342. * @param source the dictionary to take the content from and copy to this dictionary
  35343. */
  35344. copyFrom(source: StringDictionary<T>): void;
  35345. /**
  35346. * Get a value based from its key
  35347. * @param key the given key to get the matching value from
  35348. * @return the value if found, otherwise undefined is returned
  35349. */
  35350. get(key: string): T | undefined;
  35351. /**
  35352. * Get a value from its key or add it if it doesn't exist.
  35353. * This method will ensure you that a given key/data will be present in the dictionary.
  35354. * @param key the given key to get the matching value from
  35355. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35356. * The factory will only be invoked if there's no data for the given key.
  35357. * @return the value corresponding to the key.
  35358. */
  35359. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35360. /**
  35361. * Get a value from its key if present in the dictionary otherwise add it
  35362. * @param key the key to get the value from
  35363. * @param val if there's no such key/value pair in the dictionary add it with this value
  35364. * @return the value corresponding to the key
  35365. */
  35366. getOrAdd(key: string, val: T): T;
  35367. /**
  35368. * Check if there's a given key in the dictionary
  35369. * @param key the key to check for
  35370. * @return true if the key is present, false otherwise
  35371. */
  35372. contains(key: string): boolean;
  35373. /**
  35374. * Add a new key and its corresponding value
  35375. * @param key the key to add
  35376. * @param value the value corresponding to the key
  35377. * @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
  35378. */
  35379. add(key: string, value: T): boolean;
  35380. /**
  35381. * Update a specific value associated to a key
  35382. * @param key defines the key to use
  35383. * @param value defines the value to store
  35384. * @returns true if the value was updated (or false if the key was not found)
  35385. */
  35386. set(key: string, value: T): boolean;
  35387. /**
  35388. * Get the element of the given key and remove it from the dictionary
  35389. * @param key defines the key to search
  35390. * @returns the value associated with the key or null if not found
  35391. */
  35392. getAndRemove(key: string): Nullable<T>;
  35393. /**
  35394. * Remove a key/value from the dictionary.
  35395. * @param key the key to remove
  35396. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35397. */
  35398. remove(key: string): boolean;
  35399. /**
  35400. * Clear the whole content of the dictionary
  35401. */
  35402. clear(): void;
  35403. /**
  35404. * Gets the current count
  35405. */
  35406. get count(): number;
  35407. /**
  35408. * Execute a callback on each key/val of the dictionary.
  35409. * Note that you can remove any element in this dictionary in the callback implementation
  35410. * @param callback the callback to execute on a given key/value pair
  35411. */
  35412. forEach(callback: (key: string, val: T) => void): void;
  35413. /**
  35414. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35415. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35416. * Note that you can remove any element in this dictionary in the callback implementation
  35417. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35418. * @returns the first item
  35419. */
  35420. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35421. private _count;
  35422. private _data;
  35423. }
  35424. }
  35425. declare module "babylonjs/Collisions/collisionCoordinator" {
  35426. import { Nullable } from "babylonjs/types";
  35427. import { Scene } from "babylonjs/scene";
  35428. import { Vector3 } from "babylonjs/Maths/math.vector";
  35429. import { Collider } from "babylonjs/Collisions/collider";
  35430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35431. /** @hidden */
  35432. export interface ICollisionCoordinator {
  35433. createCollider(): Collider;
  35434. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35435. init(scene: Scene): void;
  35436. }
  35437. /** @hidden */
  35438. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35439. private _scene;
  35440. private _scaledPosition;
  35441. private _scaledVelocity;
  35442. private _finalPosition;
  35443. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35444. createCollider(): Collider;
  35445. init(scene: Scene): void;
  35446. private _collideWithWorld;
  35447. }
  35448. }
  35449. declare module "babylonjs/Inputs/scene.inputManager" {
  35450. import { Nullable } from "babylonjs/types";
  35451. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35452. import { Vector2 } from "babylonjs/Maths/math.vector";
  35453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35454. import { Scene } from "babylonjs/scene";
  35455. /**
  35456. * Class used to manage all inputs for the scene.
  35457. */
  35458. export class InputManager {
  35459. /** The distance in pixel that you have to move to prevent some events */
  35460. static DragMovementThreshold: number;
  35461. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35462. static LongPressDelay: number;
  35463. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35464. static DoubleClickDelay: number;
  35465. /** If you need to check double click without raising a single click at first click, enable this flag */
  35466. static ExclusiveDoubleClickMode: boolean;
  35467. private _wheelEventName;
  35468. private _onPointerMove;
  35469. private _onPointerDown;
  35470. private _onPointerUp;
  35471. private _initClickEvent;
  35472. private _initActionManager;
  35473. private _delayedSimpleClick;
  35474. private _delayedSimpleClickTimeout;
  35475. private _previousDelayedSimpleClickTimeout;
  35476. private _meshPickProceed;
  35477. private _previousButtonPressed;
  35478. private _currentPickResult;
  35479. private _previousPickResult;
  35480. private _totalPointersPressed;
  35481. private _doubleClickOccured;
  35482. private _pointerOverMesh;
  35483. private _pickedDownMesh;
  35484. private _pickedUpMesh;
  35485. private _pointerX;
  35486. private _pointerY;
  35487. private _unTranslatedPointerX;
  35488. private _unTranslatedPointerY;
  35489. private _startingPointerPosition;
  35490. private _previousStartingPointerPosition;
  35491. private _startingPointerTime;
  35492. private _previousStartingPointerTime;
  35493. private _pointerCaptures;
  35494. private _onKeyDown;
  35495. private _onKeyUp;
  35496. private _onCanvasFocusObserver;
  35497. private _onCanvasBlurObserver;
  35498. private _scene;
  35499. /**
  35500. * Creates a new InputManager
  35501. * @param scene defines the hosting scene
  35502. */
  35503. constructor(scene: Scene);
  35504. /**
  35505. * Gets the mesh that is currently under the pointer
  35506. */
  35507. get meshUnderPointer(): Nullable<AbstractMesh>;
  35508. /**
  35509. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35510. */
  35511. get unTranslatedPointer(): Vector2;
  35512. /**
  35513. * Gets or sets the current on-screen X position of the pointer
  35514. */
  35515. get pointerX(): number;
  35516. set pointerX(value: number);
  35517. /**
  35518. * Gets or sets the current on-screen Y position of the pointer
  35519. */
  35520. get pointerY(): number;
  35521. set pointerY(value: number);
  35522. private _updatePointerPosition;
  35523. private _processPointerMove;
  35524. private _setRayOnPointerInfo;
  35525. private _checkPrePointerObservable;
  35526. /**
  35527. * Use this method to simulate a pointer move on a mesh
  35528. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35529. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35530. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35531. */
  35532. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35533. /**
  35534. * Use this method to simulate a pointer down on a mesh
  35535. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35536. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35537. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35538. */
  35539. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35540. private _processPointerDown;
  35541. /** @hidden */
  35542. _isPointerSwiping(): boolean;
  35543. /**
  35544. * Use this method to simulate a pointer up on a mesh
  35545. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35546. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35547. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35548. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35549. */
  35550. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35551. private _processPointerUp;
  35552. /**
  35553. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35554. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35555. * @returns true if the pointer was captured
  35556. */
  35557. isPointerCaptured(pointerId?: number): boolean;
  35558. /**
  35559. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35560. * @param attachUp defines if you want to attach events to pointerup
  35561. * @param attachDown defines if you want to attach events to pointerdown
  35562. * @param attachMove defines if you want to attach events to pointermove
  35563. */
  35564. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35565. /**
  35566. * Detaches all event handlers
  35567. */
  35568. detachControl(): void;
  35569. /**
  35570. * Force the value of meshUnderPointer
  35571. * @param mesh defines the mesh to use
  35572. */
  35573. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35574. /**
  35575. * Gets the mesh under the pointer
  35576. * @returns a Mesh or null if no mesh is under the pointer
  35577. */
  35578. getPointerOverMesh(): Nullable<AbstractMesh>;
  35579. }
  35580. }
  35581. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35582. /**
  35583. * Helper class used to generate session unique ID
  35584. */
  35585. export class UniqueIdGenerator {
  35586. private static _UniqueIdCounter;
  35587. /**
  35588. * Gets an unique (relatively to the current scene) Id
  35589. */
  35590. static get UniqueId(): number;
  35591. }
  35592. }
  35593. declare module "babylonjs/Animations/animationGroup" {
  35594. import { Animatable } from "babylonjs/Animations/animatable";
  35595. import { Animation } from "babylonjs/Animations/animation";
  35596. import { Scene, IDisposable } from "babylonjs/scene";
  35597. import { Observable } from "babylonjs/Misc/observable";
  35598. import { Nullable } from "babylonjs/types";
  35599. import "babylonjs/Animations/animatable";
  35600. /**
  35601. * This class defines the direct association between an animation and a target
  35602. */
  35603. export class TargetedAnimation {
  35604. /**
  35605. * Animation to perform
  35606. */
  35607. animation: Animation;
  35608. /**
  35609. * Target to animate
  35610. */
  35611. target: any;
  35612. /**
  35613. * Serialize the object
  35614. * @returns the JSON object representing the current entity
  35615. */
  35616. serialize(): any;
  35617. }
  35618. /**
  35619. * Use this class to create coordinated animations on multiple targets
  35620. */
  35621. export class AnimationGroup implements IDisposable {
  35622. /** The name of the animation group */
  35623. name: string;
  35624. private _scene;
  35625. private _targetedAnimations;
  35626. private _animatables;
  35627. private _from;
  35628. private _to;
  35629. private _isStarted;
  35630. private _isPaused;
  35631. private _speedRatio;
  35632. private _loopAnimation;
  35633. /**
  35634. * Gets or sets the unique id of the node
  35635. */
  35636. uniqueId: number;
  35637. /**
  35638. * This observable will notify when one animation have ended
  35639. */
  35640. onAnimationEndObservable: Observable<TargetedAnimation>;
  35641. /**
  35642. * Observer raised when one animation loops
  35643. */
  35644. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35645. /**
  35646. * Observer raised when all animations have looped
  35647. */
  35648. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35649. /**
  35650. * This observable will notify when all animations have ended.
  35651. */
  35652. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35653. /**
  35654. * This observable will notify when all animations have paused.
  35655. */
  35656. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35657. /**
  35658. * This observable will notify when all animations are playing.
  35659. */
  35660. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35661. /**
  35662. * Gets the first frame
  35663. */
  35664. get from(): number;
  35665. /**
  35666. * Gets the last frame
  35667. */
  35668. get to(): number;
  35669. /**
  35670. * Define if the animations are started
  35671. */
  35672. get isStarted(): boolean;
  35673. /**
  35674. * Gets a value indicating that the current group is playing
  35675. */
  35676. get isPlaying(): boolean;
  35677. /**
  35678. * Gets or sets the speed ratio to use for all animations
  35679. */
  35680. get speedRatio(): number;
  35681. /**
  35682. * Gets or sets the speed ratio to use for all animations
  35683. */
  35684. set speedRatio(value: number);
  35685. /**
  35686. * Gets or sets if all animations should loop or not
  35687. */
  35688. get loopAnimation(): boolean;
  35689. set loopAnimation(value: boolean);
  35690. /**
  35691. * Gets the targeted animations for this animation group
  35692. */
  35693. get targetedAnimations(): Array<TargetedAnimation>;
  35694. /**
  35695. * returning the list of animatables controlled by this animation group.
  35696. */
  35697. get animatables(): Array<Animatable>;
  35698. /**
  35699. * Instantiates a new Animation Group.
  35700. * This helps managing several animations at once.
  35701. * @see http://doc.babylonjs.com/how_to/group
  35702. * @param name Defines the name of the group
  35703. * @param scene Defines the scene the group belongs to
  35704. */
  35705. constructor(
  35706. /** The name of the animation group */
  35707. name: string, scene?: Nullable<Scene>);
  35708. /**
  35709. * Add an animation (with its target) in the group
  35710. * @param animation defines the animation we want to add
  35711. * @param target defines the target of the animation
  35712. * @returns the TargetedAnimation object
  35713. */
  35714. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35715. /**
  35716. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35717. * It can add constant keys at begin or end
  35718. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35719. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35720. * @returns the animation group
  35721. */
  35722. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35723. private _animationLoopCount;
  35724. private _animationLoopFlags;
  35725. private _processLoop;
  35726. /**
  35727. * Start all animations on given targets
  35728. * @param loop defines if animations must loop
  35729. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35730. * @param from defines the from key (optional)
  35731. * @param to defines the to key (optional)
  35732. * @returns the current animation group
  35733. */
  35734. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35735. /**
  35736. * Pause all animations
  35737. * @returns the animation group
  35738. */
  35739. pause(): AnimationGroup;
  35740. /**
  35741. * Play all animations to initial state
  35742. * This function will start() the animations if they were not started or will restart() them if they were paused
  35743. * @param loop defines if animations must loop
  35744. * @returns the animation group
  35745. */
  35746. play(loop?: boolean): AnimationGroup;
  35747. /**
  35748. * Reset all animations to initial state
  35749. * @returns the animation group
  35750. */
  35751. reset(): AnimationGroup;
  35752. /**
  35753. * Restart animations from key 0
  35754. * @returns the animation group
  35755. */
  35756. restart(): AnimationGroup;
  35757. /**
  35758. * Stop all animations
  35759. * @returns the animation group
  35760. */
  35761. stop(): AnimationGroup;
  35762. /**
  35763. * Set animation weight for all animatables
  35764. * @param weight defines the weight to use
  35765. * @return the animationGroup
  35766. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35767. */
  35768. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35769. /**
  35770. * Synchronize and normalize all animatables with a source animatable
  35771. * @param root defines the root animatable to synchronize with
  35772. * @return the animationGroup
  35773. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35774. */
  35775. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35776. /**
  35777. * Goes to a specific frame in this animation group
  35778. * @param frame the frame number to go to
  35779. * @return the animationGroup
  35780. */
  35781. goToFrame(frame: number): AnimationGroup;
  35782. /**
  35783. * Dispose all associated resources
  35784. */
  35785. dispose(): void;
  35786. private _checkAnimationGroupEnded;
  35787. /**
  35788. * Clone the current animation group and returns a copy
  35789. * @param newName defines the name of the new group
  35790. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35791. * @returns the new aniamtion group
  35792. */
  35793. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35794. /**
  35795. * Serializes the animationGroup to an object
  35796. * @returns Serialized object
  35797. */
  35798. serialize(): any;
  35799. /**
  35800. * Returns a new AnimationGroup object parsed from the source provided.
  35801. * @param parsedAnimationGroup defines the source
  35802. * @param scene defines the scene that will receive the animationGroup
  35803. * @returns a new AnimationGroup
  35804. */
  35805. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35806. /**
  35807. * Returns the string "AnimationGroup"
  35808. * @returns "AnimationGroup"
  35809. */
  35810. getClassName(): string;
  35811. /**
  35812. * Creates a detailled string about the object
  35813. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35814. * @returns a string representing the object
  35815. */
  35816. toString(fullDetails?: boolean): string;
  35817. }
  35818. }
  35819. declare module "babylonjs/scene" {
  35820. import { Nullable } from "babylonjs/types";
  35821. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35822. import { Observable } from "babylonjs/Misc/observable";
  35823. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35824. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35825. import { Geometry } from "babylonjs/Meshes/geometry";
  35826. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35827. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35829. import { Mesh } from "babylonjs/Meshes/mesh";
  35830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35831. import { Bone } from "babylonjs/Bones/bone";
  35832. import { Skeleton } from "babylonjs/Bones/skeleton";
  35833. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35834. import { Camera } from "babylonjs/Cameras/camera";
  35835. import { AbstractScene } from "babylonjs/abstractScene";
  35836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35838. import { Material } from "babylonjs/Materials/material";
  35839. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35840. import { Effect } from "babylonjs/Materials/effect";
  35841. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35842. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35843. import { Light } from "babylonjs/Lights/light";
  35844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35845. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35846. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35847. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35849. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35851. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35852. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35853. import { Engine } from "babylonjs/Engines/engine";
  35854. import { Node } from "babylonjs/node";
  35855. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35856. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35857. import { WebRequest } from "babylonjs/Misc/webRequest";
  35858. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35859. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35860. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35861. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35862. import { Plane } from "babylonjs/Maths/math.plane";
  35863. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35864. import { Ray } from "babylonjs/Culling/ray";
  35865. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35866. import { Animation } from "babylonjs/Animations/animation";
  35867. import { Animatable } from "babylonjs/Animations/animatable";
  35868. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35869. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35870. import { Collider } from "babylonjs/Collisions/collider";
  35871. /**
  35872. * Define an interface for all classes that will hold resources
  35873. */
  35874. export interface IDisposable {
  35875. /**
  35876. * Releases all held resources
  35877. */
  35878. dispose(): void;
  35879. }
  35880. /** Interface defining initialization parameters for Scene class */
  35881. export interface SceneOptions {
  35882. /**
  35883. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35884. * It will improve performance when the number of geometries becomes important.
  35885. */
  35886. useGeometryUniqueIdsMap?: boolean;
  35887. /**
  35888. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  35892. /**
  35893. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35894. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35895. */
  35896. useClonedMeshMap?: boolean;
  35897. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35898. virtual?: boolean;
  35899. }
  35900. /**
  35901. * Represents a scene to be rendered by the engine.
  35902. * @see http://doc.babylonjs.com/features/scene
  35903. */
  35904. export class Scene extends AbstractScene implements IAnimatable {
  35905. /** The fog is deactivated */
  35906. static readonly FOGMODE_NONE: number;
  35907. /** The fog density is following an exponential function */
  35908. static readonly FOGMODE_EXP: number;
  35909. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35910. static readonly FOGMODE_EXP2: number;
  35911. /** The fog density is following a linear function. */
  35912. static readonly FOGMODE_LINEAR: number;
  35913. /**
  35914. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35916. */
  35917. static MinDeltaTime: number;
  35918. /**
  35919. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35920. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35921. */
  35922. static MaxDeltaTime: number;
  35923. /**
  35924. * Factory used to create the default material.
  35925. * @param name The name of the material to create
  35926. * @param scene The scene to create the material for
  35927. * @returns The default material
  35928. */
  35929. static DefaultMaterialFactory(scene: Scene): Material;
  35930. /**
  35931. * Factory used to create the a collision coordinator.
  35932. * @returns The collision coordinator
  35933. */
  35934. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35935. /** @hidden */
  35936. _inputManager: InputManager;
  35937. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35938. cameraToUseForPointers: Nullable<Camera>;
  35939. /** @hidden */
  35940. readonly _isScene: boolean;
  35941. /**
  35942. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35943. */
  35944. autoClear: boolean;
  35945. /**
  35946. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35947. */
  35948. autoClearDepthAndStencil: boolean;
  35949. /**
  35950. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35951. */
  35952. clearColor: Color4;
  35953. /**
  35954. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35955. */
  35956. ambientColor: Color3;
  35957. /**
  35958. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35959. * It should only be one of the following (if not the default embedded one):
  35960. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35961. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35962. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35963. * The material properties need to be setup according to the type of texture in use.
  35964. */
  35965. environmentBRDFTexture: BaseTexture;
  35966. /** @hidden */
  35967. protected _environmentTexture: Nullable<BaseTexture>;
  35968. /**
  35969. * Texture used in all pbr material as the reflection texture.
  35970. * As in the majority of the scene they are the same (exception for multi room and so on),
  35971. * this is easier to reference from here than from all the materials.
  35972. */
  35973. get environmentTexture(): Nullable<BaseTexture>;
  35974. /**
  35975. * Texture used in all pbr material as the reflection texture.
  35976. * As in the majority of the scene they are the same (exception for multi room and so on),
  35977. * this is easier to set here than in all the materials.
  35978. */
  35979. set environmentTexture(value: Nullable<BaseTexture>);
  35980. /** @hidden */
  35981. protected _environmentIntensity: number;
  35982. /**
  35983. * Intensity of the environment in all pbr material.
  35984. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35985. * As in the majority of the scene they are the same (exception for multi room and so on),
  35986. * this is easier to reference from here than from all the materials.
  35987. */
  35988. get environmentIntensity(): number;
  35989. /**
  35990. * Intensity of the environment in all pbr material.
  35991. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35992. * As in the majority of the scene they are the same (exception for multi room and so on),
  35993. * this is easier to set here than in all the materials.
  35994. */
  35995. set environmentIntensity(value: number);
  35996. /** @hidden */
  35997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35998. /**
  35999. * Default image processing configuration used either in the rendering
  36000. * Forward main pass or through the imageProcessingPostProcess if present.
  36001. * As in the majority of the scene they are the same (exception for multi camera),
  36002. * this is easier to reference from here than from all the materials and post process.
  36003. *
  36004. * No setter as we it is a shared configuration, you can set the values instead.
  36005. */
  36006. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36007. private _forceWireframe;
  36008. /**
  36009. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36010. */
  36011. set forceWireframe(value: boolean);
  36012. get forceWireframe(): boolean;
  36013. private _skipFrustumClipping;
  36014. /**
  36015. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36016. */
  36017. set skipFrustumClipping(value: boolean);
  36018. get skipFrustumClipping(): boolean;
  36019. private _forcePointsCloud;
  36020. /**
  36021. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36022. */
  36023. set forcePointsCloud(value: boolean);
  36024. get forcePointsCloud(): boolean;
  36025. /**
  36026. * Gets or sets the active clipplane 1
  36027. */
  36028. clipPlane: Nullable<Plane>;
  36029. /**
  36030. * Gets or sets the active clipplane 2
  36031. */
  36032. clipPlane2: Nullable<Plane>;
  36033. /**
  36034. * Gets or sets the active clipplane 3
  36035. */
  36036. clipPlane3: Nullable<Plane>;
  36037. /**
  36038. * Gets or sets the active clipplane 4
  36039. */
  36040. clipPlane4: Nullable<Plane>;
  36041. /**
  36042. * Gets or sets the active clipplane 5
  36043. */
  36044. clipPlane5: Nullable<Plane>;
  36045. /**
  36046. * Gets or sets the active clipplane 6
  36047. */
  36048. clipPlane6: Nullable<Plane>;
  36049. /**
  36050. * Gets or sets a boolean indicating if animations are enabled
  36051. */
  36052. animationsEnabled: boolean;
  36053. private _animationPropertiesOverride;
  36054. /**
  36055. * Gets or sets the animation properties override
  36056. */
  36057. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36058. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36059. /**
  36060. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36061. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36062. */
  36063. useConstantAnimationDeltaTime: boolean;
  36064. /**
  36065. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36066. * Please note that it requires to run a ray cast through the scene on every frame
  36067. */
  36068. constantlyUpdateMeshUnderPointer: boolean;
  36069. /**
  36070. * Defines the HTML cursor to use when hovering over interactive elements
  36071. */
  36072. hoverCursor: string;
  36073. /**
  36074. * Defines the HTML default cursor to use (empty by default)
  36075. */
  36076. defaultCursor: string;
  36077. /**
  36078. * Defines wether cursors are handled by the scene.
  36079. */
  36080. doNotHandleCursors: boolean;
  36081. /**
  36082. * This is used to call preventDefault() on pointer down
  36083. * in order to block unwanted artifacts like system double clicks
  36084. */
  36085. preventDefaultOnPointerDown: boolean;
  36086. /**
  36087. * This is used to call preventDefault() on pointer up
  36088. * in order to block unwanted artifacts like system double clicks
  36089. */
  36090. preventDefaultOnPointerUp: boolean;
  36091. /**
  36092. * Gets or sets user defined metadata
  36093. */
  36094. metadata: any;
  36095. /**
  36096. * For internal use only. Please do not use.
  36097. */
  36098. reservedDataStore: any;
  36099. /**
  36100. * Gets the name of the plugin used to load this scene (null by default)
  36101. */
  36102. loadingPluginName: string;
  36103. /**
  36104. * Use this array to add regular expressions used to disable offline support for specific urls
  36105. */
  36106. disableOfflineSupportExceptionRules: RegExp[];
  36107. /**
  36108. * An event triggered when the scene is disposed.
  36109. */
  36110. onDisposeObservable: Observable<Scene>;
  36111. private _onDisposeObserver;
  36112. /** Sets a function to be executed when this scene is disposed. */
  36113. set onDispose(callback: () => void);
  36114. /**
  36115. * An event triggered before rendering the scene (right after animations and physics)
  36116. */
  36117. onBeforeRenderObservable: Observable<Scene>;
  36118. private _onBeforeRenderObserver;
  36119. /** Sets a function to be executed before rendering this scene */
  36120. set beforeRender(callback: Nullable<() => void>);
  36121. /**
  36122. * An event triggered after rendering the scene
  36123. */
  36124. onAfterRenderObservable: Observable<Scene>;
  36125. /**
  36126. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36127. */
  36128. onAfterRenderCameraObservable: Observable<Camera>;
  36129. private _onAfterRenderObserver;
  36130. /** Sets a function to be executed after rendering this scene */
  36131. set afterRender(callback: Nullable<() => void>);
  36132. /**
  36133. * An event triggered before animating the scene
  36134. */
  36135. onBeforeAnimationsObservable: Observable<Scene>;
  36136. /**
  36137. * An event triggered after animations processing
  36138. */
  36139. onAfterAnimationsObservable: Observable<Scene>;
  36140. /**
  36141. * An event triggered before draw calls are ready to be sent
  36142. */
  36143. onBeforeDrawPhaseObservable: Observable<Scene>;
  36144. /**
  36145. * An event triggered after draw calls have been sent
  36146. */
  36147. onAfterDrawPhaseObservable: Observable<Scene>;
  36148. /**
  36149. * An event triggered when the scene is ready
  36150. */
  36151. onReadyObservable: Observable<Scene>;
  36152. /**
  36153. * An event triggered before rendering a camera
  36154. */
  36155. onBeforeCameraRenderObservable: Observable<Camera>;
  36156. private _onBeforeCameraRenderObserver;
  36157. /** Sets a function to be executed before rendering a camera*/
  36158. set beforeCameraRender(callback: () => void);
  36159. /**
  36160. * An event triggered after rendering a camera
  36161. */
  36162. onAfterCameraRenderObservable: Observable<Camera>;
  36163. private _onAfterCameraRenderObserver;
  36164. /** Sets a function to be executed after rendering a camera*/
  36165. set afterCameraRender(callback: () => void);
  36166. /**
  36167. * An event triggered when active meshes evaluation is about to start
  36168. */
  36169. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36170. /**
  36171. * An event triggered when active meshes evaluation is done
  36172. */
  36173. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36174. /**
  36175. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36179. /**
  36180. * An event triggered when particles rendering is done
  36181. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36182. */
  36183. onAfterParticlesRenderingObservable: Observable<Scene>;
  36184. /**
  36185. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36186. */
  36187. onDataLoadedObservable: Observable<Scene>;
  36188. /**
  36189. * An event triggered when a camera is created
  36190. */
  36191. onNewCameraAddedObservable: Observable<Camera>;
  36192. /**
  36193. * An event triggered when a camera is removed
  36194. */
  36195. onCameraRemovedObservable: Observable<Camera>;
  36196. /**
  36197. * An event triggered when a light is created
  36198. */
  36199. onNewLightAddedObservable: Observable<Light>;
  36200. /**
  36201. * An event triggered when a light is removed
  36202. */
  36203. onLightRemovedObservable: Observable<Light>;
  36204. /**
  36205. * An event triggered when a geometry is created
  36206. */
  36207. onNewGeometryAddedObservable: Observable<Geometry>;
  36208. /**
  36209. * An event triggered when a geometry is removed
  36210. */
  36211. onGeometryRemovedObservable: Observable<Geometry>;
  36212. /**
  36213. * An event triggered when a transform node is created
  36214. */
  36215. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36216. /**
  36217. * An event triggered when a transform node is removed
  36218. */
  36219. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36220. /**
  36221. * An event triggered when a mesh is created
  36222. */
  36223. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36224. /**
  36225. * An event triggered when a mesh is removed
  36226. */
  36227. onMeshRemovedObservable: Observable<AbstractMesh>;
  36228. /**
  36229. * An event triggered when a skeleton is created
  36230. */
  36231. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36232. /**
  36233. * An event triggered when a skeleton is removed
  36234. */
  36235. onSkeletonRemovedObservable: Observable<Skeleton>;
  36236. /**
  36237. * An event triggered when a material is created
  36238. */
  36239. onNewMaterialAddedObservable: Observable<Material>;
  36240. /**
  36241. * An event triggered when a material is removed
  36242. */
  36243. onMaterialRemovedObservable: Observable<Material>;
  36244. /**
  36245. * An event triggered when a texture is created
  36246. */
  36247. onNewTextureAddedObservable: Observable<BaseTexture>;
  36248. /**
  36249. * An event triggered when a texture is removed
  36250. */
  36251. onTextureRemovedObservable: Observable<BaseTexture>;
  36252. /**
  36253. * An event triggered when render targets are about to be rendered
  36254. * Can happen multiple times per frame.
  36255. */
  36256. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36257. /**
  36258. * An event triggered when render targets were rendered.
  36259. * Can happen multiple times per frame.
  36260. */
  36261. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36262. /**
  36263. * An event triggered before calculating deterministic simulation step
  36264. */
  36265. onBeforeStepObservable: Observable<Scene>;
  36266. /**
  36267. * An event triggered after calculating deterministic simulation step
  36268. */
  36269. onAfterStepObservable: Observable<Scene>;
  36270. /**
  36271. * An event triggered when the activeCamera property is updated
  36272. */
  36273. onActiveCameraChanged: Observable<Scene>;
  36274. /**
  36275. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36276. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36277. * 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)
  36278. */
  36279. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36280. /**
  36281. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36282. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36283. * 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)
  36284. */
  36285. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36286. /**
  36287. * This Observable will when a mesh has been imported into the scene.
  36288. */
  36289. onMeshImportedObservable: Observable<AbstractMesh>;
  36290. /**
  36291. * This Observable will when an animation file has been imported into the scene.
  36292. */
  36293. onAnimationFileImportedObservable: Observable<Scene>;
  36294. /**
  36295. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36296. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36297. */
  36298. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36299. /** @hidden */
  36300. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36301. /**
  36302. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36303. */
  36304. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36305. /**
  36306. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36307. */
  36308. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36309. /**
  36310. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36311. */
  36312. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36313. /** Callback called when a pointer move is detected */
  36314. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36315. /** Callback called when a pointer down is detected */
  36316. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36317. /** Callback called when a pointer up is detected */
  36318. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36319. /** Callback called when a pointer pick is detected */
  36320. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36321. /**
  36322. * 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).
  36323. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36324. */
  36325. onPrePointerObservable: Observable<PointerInfoPre>;
  36326. /**
  36327. * Observable event triggered each time an input event is received from the rendering canvas
  36328. */
  36329. onPointerObservable: Observable<PointerInfo>;
  36330. /**
  36331. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36332. */
  36333. get unTranslatedPointer(): Vector2;
  36334. /**
  36335. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36336. */
  36337. static get DragMovementThreshold(): number;
  36338. static set DragMovementThreshold(value: number);
  36339. /**
  36340. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36341. */
  36342. static get LongPressDelay(): number;
  36343. static set LongPressDelay(value: number);
  36344. /**
  36345. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36346. */
  36347. static get DoubleClickDelay(): number;
  36348. static set DoubleClickDelay(value: number);
  36349. /** If you need to check double click without raising a single click at first click, enable this flag */
  36350. static get ExclusiveDoubleClickMode(): boolean;
  36351. static set ExclusiveDoubleClickMode(value: boolean);
  36352. /** @hidden */
  36353. _mirroredCameraPosition: Nullable<Vector3>;
  36354. /**
  36355. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36356. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36357. */
  36358. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36359. /**
  36360. * Observable event triggered each time an keyboard event is received from the hosting window
  36361. */
  36362. onKeyboardObservable: Observable<KeyboardInfo>;
  36363. private _useRightHandedSystem;
  36364. /**
  36365. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36366. */
  36367. set useRightHandedSystem(value: boolean);
  36368. get useRightHandedSystem(): boolean;
  36369. private _timeAccumulator;
  36370. private _currentStepId;
  36371. private _currentInternalStep;
  36372. /**
  36373. * Sets the step Id used by deterministic lock step
  36374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36375. * @param newStepId defines the step Id
  36376. */
  36377. setStepId(newStepId: number): void;
  36378. /**
  36379. * Gets the step Id used by deterministic lock step
  36380. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36381. * @returns the step Id
  36382. */
  36383. getStepId(): number;
  36384. /**
  36385. * Gets the internal step used by deterministic lock step
  36386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36387. * @returns the internal step
  36388. */
  36389. getInternalStep(): number;
  36390. private _fogEnabled;
  36391. /**
  36392. * Gets or sets a boolean indicating if fog is enabled on this scene
  36393. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36394. * (Default is true)
  36395. */
  36396. set fogEnabled(value: boolean);
  36397. get fogEnabled(): boolean;
  36398. private _fogMode;
  36399. /**
  36400. * Gets or sets the fog mode to use
  36401. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36402. * | mode | value |
  36403. * | --- | --- |
  36404. * | FOGMODE_NONE | 0 |
  36405. * | FOGMODE_EXP | 1 |
  36406. * | FOGMODE_EXP2 | 2 |
  36407. * | FOGMODE_LINEAR | 3 |
  36408. */
  36409. set fogMode(value: number);
  36410. get fogMode(): number;
  36411. /**
  36412. * Gets or sets the fog color to use
  36413. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36414. * (Default is Color3(0.2, 0.2, 0.3))
  36415. */
  36416. fogColor: Color3;
  36417. /**
  36418. * Gets or sets the fog density to use
  36419. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36420. * (Default is 0.1)
  36421. */
  36422. fogDensity: number;
  36423. /**
  36424. * Gets or sets the fog start distance to use
  36425. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36426. * (Default is 0)
  36427. */
  36428. fogStart: number;
  36429. /**
  36430. * Gets or sets the fog end distance to use
  36431. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36432. * (Default is 1000)
  36433. */
  36434. fogEnd: number;
  36435. private _shadowsEnabled;
  36436. /**
  36437. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36438. */
  36439. set shadowsEnabled(value: boolean);
  36440. get shadowsEnabled(): boolean;
  36441. private _lightsEnabled;
  36442. /**
  36443. * Gets or sets a boolean indicating if lights are enabled on this scene
  36444. */
  36445. set lightsEnabled(value: boolean);
  36446. get lightsEnabled(): boolean;
  36447. /** All of the active cameras added to this scene. */
  36448. activeCameras: Camera[];
  36449. /** @hidden */
  36450. _activeCamera: Nullable<Camera>;
  36451. /** Gets or sets the current active camera */
  36452. get activeCamera(): Nullable<Camera>;
  36453. set activeCamera(value: Nullable<Camera>);
  36454. private _defaultMaterial;
  36455. /** The default material used on meshes when no material is affected */
  36456. get defaultMaterial(): Material;
  36457. /** The default material used on meshes when no material is affected */
  36458. set defaultMaterial(value: Material);
  36459. private _texturesEnabled;
  36460. /**
  36461. * Gets or sets a boolean indicating if textures are enabled on this scene
  36462. */
  36463. set texturesEnabled(value: boolean);
  36464. get texturesEnabled(): boolean;
  36465. /**
  36466. * Gets or sets a boolean indicating if particles are enabled on this scene
  36467. */
  36468. particlesEnabled: boolean;
  36469. /**
  36470. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36471. */
  36472. spritesEnabled: boolean;
  36473. private _skeletonsEnabled;
  36474. /**
  36475. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36476. */
  36477. set skeletonsEnabled(value: boolean);
  36478. get skeletonsEnabled(): boolean;
  36479. /**
  36480. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36481. */
  36482. lensFlaresEnabled: boolean;
  36483. /**
  36484. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36485. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36486. */
  36487. collisionsEnabled: boolean;
  36488. private _collisionCoordinator;
  36489. /** @hidden */
  36490. get collisionCoordinator(): ICollisionCoordinator;
  36491. /**
  36492. * Defines the gravity applied to this scene (used only for collisions)
  36493. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36494. */
  36495. gravity: Vector3;
  36496. /**
  36497. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36498. */
  36499. postProcessesEnabled: boolean;
  36500. /**
  36501. * The list of postprocesses added to the scene
  36502. */
  36503. postProcesses: PostProcess[];
  36504. /**
  36505. * Gets the current postprocess manager
  36506. */
  36507. postProcessManager: PostProcessManager;
  36508. /**
  36509. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36510. */
  36511. renderTargetsEnabled: boolean;
  36512. /**
  36513. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36514. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36515. */
  36516. dumpNextRenderTargets: boolean;
  36517. /**
  36518. * The list of user defined render targets added to the scene
  36519. */
  36520. customRenderTargets: RenderTargetTexture[];
  36521. /**
  36522. * Defines if texture loading must be delayed
  36523. * If true, textures will only be loaded when they need to be rendered
  36524. */
  36525. useDelayedTextureLoading: boolean;
  36526. /**
  36527. * Gets the list of meshes imported to the scene through SceneLoader
  36528. */
  36529. importedMeshesFiles: String[];
  36530. /**
  36531. * Gets or sets a boolean indicating if probes are enabled on this scene
  36532. */
  36533. probesEnabled: boolean;
  36534. /**
  36535. * Gets or sets the current offline provider to use to store scene data
  36536. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36537. */
  36538. offlineProvider: IOfflineProvider;
  36539. /**
  36540. * Gets or sets the action manager associated with the scene
  36541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36542. */
  36543. actionManager: AbstractActionManager;
  36544. private _meshesForIntersections;
  36545. /**
  36546. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36547. */
  36548. proceduralTexturesEnabled: boolean;
  36549. private _engine;
  36550. private _totalVertices;
  36551. /** @hidden */
  36552. _activeIndices: PerfCounter;
  36553. /** @hidden */
  36554. _activeParticles: PerfCounter;
  36555. /** @hidden */
  36556. _activeBones: PerfCounter;
  36557. private _animationRatio;
  36558. /** @hidden */
  36559. _animationTimeLast: number;
  36560. /** @hidden */
  36561. _animationTime: number;
  36562. /**
  36563. * Gets or sets a general scale for animation speed
  36564. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36565. */
  36566. animationTimeScale: number;
  36567. /** @hidden */
  36568. _cachedMaterial: Nullable<Material>;
  36569. /** @hidden */
  36570. _cachedEffect: Nullable<Effect>;
  36571. /** @hidden */
  36572. _cachedVisibility: Nullable<number>;
  36573. private _renderId;
  36574. private _frameId;
  36575. private _executeWhenReadyTimeoutId;
  36576. private _intermediateRendering;
  36577. private _viewUpdateFlag;
  36578. private _projectionUpdateFlag;
  36579. /** @hidden */
  36580. _toBeDisposed: Nullable<IDisposable>[];
  36581. private _activeRequests;
  36582. /** @hidden */
  36583. _pendingData: any[];
  36584. private _isDisposed;
  36585. /**
  36586. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36587. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36588. */
  36589. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36590. private _activeMeshes;
  36591. private _processedMaterials;
  36592. private _renderTargets;
  36593. /** @hidden */
  36594. _activeParticleSystems: SmartArray<IParticleSystem>;
  36595. private _activeSkeletons;
  36596. private _softwareSkinnedMeshes;
  36597. private _renderingManager;
  36598. /** @hidden */
  36599. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36600. private _transformMatrix;
  36601. private _sceneUbo;
  36602. /** @hidden */
  36603. _viewMatrix: Matrix;
  36604. private _projectionMatrix;
  36605. /** @hidden */
  36606. _forcedViewPosition: Nullable<Vector3>;
  36607. /** @hidden */
  36608. _frustumPlanes: Plane[];
  36609. /**
  36610. * Gets the list of frustum planes (built from the active camera)
  36611. */
  36612. get frustumPlanes(): Plane[];
  36613. /**
  36614. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36615. * This is useful if there are more lights that the maximum simulteanous authorized
  36616. */
  36617. requireLightSorting: boolean;
  36618. /** @hidden */
  36619. readonly useMaterialMeshMap: boolean;
  36620. /** @hidden */
  36621. readonly useClonedMeshMap: boolean;
  36622. private _externalData;
  36623. private _uid;
  36624. /**
  36625. * @hidden
  36626. * Backing store of defined scene components.
  36627. */
  36628. _components: ISceneComponent[];
  36629. /**
  36630. * @hidden
  36631. * Backing store of defined scene components.
  36632. */
  36633. _serializableComponents: ISceneSerializableComponent[];
  36634. /**
  36635. * List of components to register on the next registration step.
  36636. */
  36637. private _transientComponents;
  36638. /**
  36639. * Registers the transient components if needed.
  36640. */
  36641. private _registerTransientComponents;
  36642. /**
  36643. * @hidden
  36644. * Add a component to the scene.
  36645. * Note that the ccomponent could be registered on th next frame if this is called after
  36646. * the register component stage.
  36647. * @param component Defines the component to add to the scene
  36648. */
  36649. _addComponent(component: ISceneComponent): void;
  36650. /**
  36651. * @hidden
  36652. * Gets a component from the scene.
  36653. * @param name defines the name of the component to retrieve
  36654. * @returns the component or null if not present
  36655. */
  36656. _getComponent(name: string): Nullable<ISceneComponent>;
  36657. /**
  36658. * @hidden
  36659. * Defines the actions happening before camera updates.
  36660. */
  36661. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36662. /**
  36663. * @hidden
  36664. * Defines the actions happening before clear the canvas.
  36665. */
  36666. _beforeClearStage: Stage<SimpleStageAction>;
  36667. /**
  36668. * @hidden
  36669. * Defines the actions when collecting render targets for the frame.
  36670. */
  36671. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36672. /**
  36673. * @hidden
  36674. * Defines the actions happening for one camera in the frame.
  36675. */
  36676. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36677. /**
  36678. * @hidden
  36679. * Defines the actions happening during the per mesh ready checks.
  36680. */
  36681. _isReadyForMeshStage: Stage<MeshStageAction>;
  36682. /**
  36683. * @hidden
  36684. * Defines the actions happening before evaluate active mesh checks.
  36685. */
  36686. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36687. /**
  36688. * @hidden
  36689. * Defines the actions happening during the evaluate sub mesh checks.
  36690. */
  36691. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36692. /**
  36693. * @hidden
  36694. * Defines the actions happening during the active mesh stage.
  36695. */
  36696. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36697. /**
  36698. * @hidden
  36699. * Defines the actions happening during the per camera render target step.
  36700. */
  36701. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36702. /**
  36703. * @hidden
  36704. * Defines the actions happening just before the active camera is drawing.
  36705. */
  36706. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36707. /**
  36708. * @hidden
  36709. * Defines the actions happening just before a render target is drawing.
  36710. */
  36711. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36712. /**
  36713. * @hidden
  36714. * Defines the actions happening just before a rendering group is drawing.
  36715. */
  36716. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36717. /**
  36718. * @hidden
  36719. * Defines the actions happening just before a mesh is drawing.
  36720. */
  36721. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36722. /**
  36723. * @hidden
  36724. * Defines the actions happening just after a mesh has been drawn.
  36725. */
  36726. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36727. /**
  36728. * @hidden
  36729. * Defines the actions happening just after a rendering group has been drawn.
  36730. */
  36731. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36732. /**
  36733. * @hidden
  36734. * Defines the actions happening just after the active camera has been drawn.
  36735. */
  36736. _afterCameraDrawStage: Stage<CameraStageAction>;
  36737. /**
  36738. * @hidden
  36739. * Defines the actions happening just after a render target has been drawn.
  36740. */
  36741. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36742. /**
  36743. * @hidden
  36744. * Defines the actions happening just after rendering all cameras and computing intersections.
  36745. */
  36746. _afterRenderStage: Stage<SimpleStageAction>;
  36747. /**
  36748. * @hidden
  36749. * Defines the actions happening when a pointer move event happens.
  36750. */
  36751. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36752. /**
  36753. * @hidden
  36754. * Defines the actions happening when a pointer down event happens.
  36755. */
  36756. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36757. /**
  36758. * @hidden
  36759. * Defines the actions happening when a pointer up event happens.
  36760. */
  36761. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36762. /**
  36763. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36764. */
  36765. private geometriesByUniqueId;
  36766. /**
  36767. * Creates a new Scene
  36768. * @param engine defines the engine to use to render this scene
  36769. * @param options defines the scene options
  36770. */
  36771. constructor(engine: Engine, options?: SceneOptions);
  36772. /**
  36773. * Gets a string idenfifying the name of the class
  36774. * @returns "Scene" string
  36775. */
  36776. getClassName(): string;
  36777. private _defaultMeshCandidates;
  36778. /**
  36779. * @hidden
  36780. */
  36781. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36782. private _defaultSubMeshCandidates;
  36783. /**
  36784. * @hidden
  36785. */
  36786. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36787. /**
  36788. * Sets the default candidate providers for the scene.
  36789. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36790. * and getCollidingSubMeshCandidates to their default function
  36791. */
  36792. setDefaultCandidateProviders(): void;
  36793. /**
  36794. * Gets the mesh that is currently under the pointer
  36795. */
  36796. get meshUnderPointer(): Nullable<AbstractMesh>;
  36797. /**
  36798. * Gets or sets the current on-screen X position of the pointer
  36799. */
  36800. get pointerX(): number;
  36801. set pointerX(value: number);
  36802. /**
  36803. * Gets or sets the current on-screen Y position of the pointer
  36804. */
  36805. get pointerY(): number;
  36806. set pointerY(value: number);
  36807. /**
  36808. * Gets the cached material (ie. the latest rendered one)
  36809. * @returns the cached material
  36810. */
  36811. getCachedMaterial(): Nullable<Material>;
  36812. /**
  36813. * Gets the cached effect (ie. the latest rendered one)
  36814. * @returns the cached effect
  36815. */
  36816. getCachedEffect(): Nullable<Effect>;
  36817. /**
  36818. * Gets the cached visibility state (ie. the latest rendered one)
  36819. * @returns the cached visibility state
  36820. */
  36821. getCachedVisibility(): Nullable<number>;
  36822. /**
  36823. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36824. * @param material defines the current material
  36825. * @param effect defines the current effect
  36826. * @param visibility defines the current visibility state
  36827. * @returns true if one parameter is not cached
  36828. */
  36829. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36830. /**
  36831. * Gets the engine associated with the scene
  36832. * @returns an Engine
  36833. */
  36834. getEngine(): Engine;
  36835. /**
  36836. * Gets the total number of vertices rendered per frame
  36837. * @returns the total number of vertices rendered per frame
  36838. */
  36839. getTotalVertices(): number;
  36840. /**
  36841. * Gets the performance counter for total vertices
  36842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36843. */
  36844. get totalVerticesPerfCounter(): PerfCounter;
  36845. /**
  36846. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36847. * @returns the total number of active indices rendered per frame
  36848. */
  36849. getActiveIndices(): number;
  36850. /**
  36851. * Gets the performance counter for active indices
  36852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36853. */
  36854. get totalActiveIndicesPerfCounter(): PerfCounter;
  36855. /**
  36856. * Gets the total number of active particles rendered per frame
  36857. * @returns the total number of active particles rendered per frame
  36858. */
  36859. getActiveParticles(): number;
  36860. /**
  36861. * Gets the performance counter for active particles
  36862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36863. */
  36864. get activeParticlesPerfCounter(): PerfCounter;
  36865. /**
  36866. * Gets the total number of active bones rendered per frame
  36867. * @returns the total number of active bones rendered per frame
  36868. */
  36869. getActiveBones(): number;
  36870. /**
  36871. * Gets the performance counter for active bones
  36872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36873. */
  36874. get activeBonesPerfCounter(): PerfCounter;
  36875. /**
  36876. * Gets the array of active meshes
  36877. * @returns an array of AbstractMesh
  36878. */
  36879. getActiveMeshes(): SmartArray<AbstractMesh>;
  36880. /**
  36881. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36882. * @returns a number
  36883. */
  36884. getAnimationRatio(): number;
  36885. /**
  36886. * Gets an unique Id for the current render phase
  36887. * @returns a number
  36888. */
  36889. getRenderId(): number;
  36890. /**
  36891. * Gets an unique Id for the current frame
  36892. * @returns a number
  36893. */
  36894. getFrameId(): number;
  36895. /** Call this function if you want to manually increment the render Id*/
  36896. incrementRenderId(): void;
  36897. private _createUbo;
  36898. /**
  36899. * Use this method to simulate a pointer move on a mesh
  36900. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36901. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36902. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36903. * @returns the current scene
  36904. */
  36905. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36906. /**
  36907. * Use this method to simulate a pointer down on a mesh
  36908. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36909. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36910. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36911. * @returns the current scene
  36912. */
  36913. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36914. /**
  36915. * Use this method to simulate a pointer up on a mesh
  36916. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36917. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36918. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36919. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36920. * @returns the current scene
  36921. */
  36922. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36923. /**
  36924. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36925. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36926. * @returns true if the pointer was captured
  36927. */
  36928. isPointerCaptured(pointerId?: number): boolean;
  36929. /**
  36930. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36931. * @param attachUp defines if you want to attach events to pointerup
  36932. * @param attachDown defines if you want to attach events to pointerdown
  36933. * @param attachMove defines if you want to attach events to pointermove
  36934. */
  36935. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36936. /** Detaches all event handlers*/
  36937. detachControl(): void;
  36938. /**
  36939. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36940. * Delay loaded resources are not taking in account
  36941. * @return true if all required resources are ready
  36942. */
  36943. isReady(): boolean;
  36944. /** Resets all cached information relative to material (including effect and visibility) */
  36945. resetCachedMaterial(): void;
  36946. /**
  36947. * Registers a function to be called before every frame render
  36948. * @param func defines the function to register
  36949. */
  36950. registerBeforeRender(func: () => void): void;
  36951. /**
  36952. * Unregisters a function called before every frame render
  36953. * @param func defines the function to unregister
  36954. */
  36955. unregisterBeforeRender(func: () => void): void;
  36956. /**
  36957. * Registers a function to be called after every frame render
  36958. * @param func defines the function to register
  36959. */
  36960. registerAfterRender(func: () => void): void;
  36961. /**
  36962. * Unregisters a function called after every frame render
  36963. * @param func defines the function to unregister
  36964. */
  36965. unregisterAfterRender(func: () => void): void;
  36966. private _executeOnceBeforeRender;
  36967. /**
  36968. * The provided function will run before render once and will be disposed afterwards.
  36969. * A timeout delay can be provided so that the function will be executed in N ms.
  36970. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36971. * @param func The function to be executed.
  36972. * @param timeout optional delay in ms
  36973. */
  36974. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36975. /** @hidden */
  36976. _addPendingData(data: any): void;
  36977. /** @hidden */
  36978. _removePendingData(data: any): void;
  36979. /**
  36980. * Returns the number of items waiting to be loaded
  36981. * @returns the number of items waiting to be loaded
  36982. */
  36983. getWaitingItemsCount(): number;
  36984. /**
  36985. * Returns a boolean indicating if the scene is still loading data
  36986. */
  36987. get isLoading(): boolean;
  36988. /**
  36989. * Registers a function to be executed when the scene is ready
  36990. * @param {Function} func - the function to be executed
  36991. */
  36992. executeWhenReady(func: () => void): void;
  36993. /**
  36994. * Returns a promise that resolves when the scene is ready
  36995. * @returns A promise that resolves when the scene is ready
  36996. */
  36997. whenReadyAsync(): Promise<void>;
  36998. /** @hidden */
  36999. _checkIsReady(): void;
  37000. /**
  37001. * Gets all animatable attached to the scene
  37002. */
  37003. get animatables(): Animatable[];
  37004. /**
  37005. * Resets the last animation time frame.
  37006. * Useful to override when animations start running when loading a scene for the first time.
  37007. */
  37008. resetLastAnimationTimeFrame(): void;
  37009. /**
  37010. * Gets the current view matrix
  37011. * @returns a Matrix
  37012. */
  37013. getViewMatrix(): Matrix;
  37014. /**
  37015. * Gets the current projection matrix
  37016. * @returns a Matrix
  37017. */
  37018. getProjectionMatrix(): Matrix;
  37019. /**
  37020. * Gets the current transform matrix
  37021. * @returns a Matrix made of View * Projection
  37022. */
  37023. getTransformMatrix(): Matrix;
  37024. /**
  37025. * Sets the current transform matrix
  37026. * @param viewL defines the View matrix to use
  37027. * @param projectionL defines the Projection matrix to use
  37028. * @param viewR defines the right View matrix to use (if provided)
  37029. * @param projectionR defines the right Projection matrix to use (if provided)
  37030. */
  37031. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37032. /**
  37033. * Gets the uniform buffer used to store scene data
  37034. * @returns a UniformBuffer
  37035. */
  37036. getSceneUniformBuffer(): UniformBuffer;
  37037. /**
  37038. * Gets an unique (relatively to the current scene) Id
  37039. * @returns an unique number for the scene
  37040. */
  37041. getUniqueId(): number;
  37042. /**
  37043. * Add a mesh to the list of scene's meshes
  37044. * @param newMesh defines the mesh to add
  37045. * @param recursive if all child meshes should also be added to the scene
  37046. */
  37047. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37048. /**
  37049. * Remove a mesh for the list of scene's meshes
  37050. * @param toRemove defines the mesh to remove
  37051. * @param recursive if all child meshes should also be removed from the scene
  37052. * @returns the index where the mesh was in the mesh list
  37053. */
  37054. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37055. /**
  37056. * Add a transform node to the list of scene's transform nodes
  37057. * @param newTransformNode defines the transform node to add
  37058. */
  37059. addTransformNode(newTransformNode: TransformNode): void;
  37060. /**
  37061. * Remove a transform node for the list of scene's transform nodes
  37062. * @param toRemove defines the transform node to remove
  37063. * @returns the index where the transform node was in the transform node list
  37064. */
  37065. removeTransformNode(toRemove: TransformNode): number;
  37066. /**
  37067. * Remove a skeleton for the list of scene's skeletons
  37068. * @param toRemove defines the skeleton to remove
  37069. * @returns the index where the skeleton was in the skeleton list
  37070. */
  37071. removeSkeleton(toRemove: Skeleton): number;
  37072. /**
  37073. * Remove a morph target for the list of scene's morph targets
  37074. * @param toRemove defines the morph target to remove
  37075. * @returns the index where the morph target was in the morph target list
  37076. */
  37077. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37078. /**
  37079. * Remove a light for the list of scene's lights
  37080. * @param toRemove defines the light to remove
  37081. * @returns the index where the light was in the light list
  37082. */
  37083. removeLight(toRemove: Light): number;
  37084. /**
  37085. * Remove a camera for the list of scene's cameras
  37086. * @param toRemove defines the camera to remove
  37087. * @returns the index where the camera was in the camera list
  37088. */
  37089. removeCamera(toRemove: Camera): number;
  37090. /**
  37091. * Remove a particle system for the list of scene's particle systems
  37092. * @param toRemove defines the particle system to remove
  37093. * @returns the index where the particle system was in the particle system list
  37094. */
  37095. removeParticleSystem(toRemove: IParticleSystem): number;
  37096. /**
  37097. * Remove a animation for the list of scene's animations
  37098. * @param toRemove defines the animation to remove
  37099. * @returns the index where the animation was in the animation list
  37100. */
  37101. removeAnimation(toRemove: Animation): number;
  37102. /**
  37103. * Will stop the animation of the given target
  37104. * @param target - the target
  37105. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37106. * @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)
  37107. */
  37108. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37109. /**
  37110. * Removes the given animation group from this scene.
  37111. * @param toRemove The animation group to remove
  37112. * @returns The index of the removed animation group
  37113. */
  37114. removeAnimationGroup(toRemove: AnimationGroup): number;
  37115. /**
  37116. * Removes the given multi-material from this scene.
  37117. * @param toRemove The multi-material to remove
  37118. * @returns The index of the removed multi-material
  37119. */
  37120. removeMultiMaterial(toRemove: MultiMaterial): number;
  37121. /**
  37122. * Removes the given material from this scene.
  37123. * @param toRemove The material to remove
  37124. * @returns The index of the removed material
  37125. */
  37126. removeMaterial(toRemove: Material): number;
  37127. /**
  37128. * Removes the given action manager from this scene.
  37129. * @param toRemove The action manager to remove
  37130. * @returns The index of the removed action manager
  37131. */
  37132. removeActionManager(toRemove: AbstractActionManager): number;
  37133. /**
  37134. * Removes the given texture from this scene.
  37135. * @param toRemove The texture to remove
  37136. * @returns The index of the removed texture
  37137. */
  37138. removeTexture(toRemove: BaseTexture): number;
  37139. /**
  37140. * Adds the given light to this scene
  37141. * @param newLight The light to add
  37142. */
  37143. addLight(newLight: Light): void;
  37144. /**
  37145. * Sorts the list list based on light priorities
  37146. */
  37147. sortLightsByPriority(): void;
  37148. /**
  37149. * Adds the given camera to this scene
  37150. * @param newCamera The camera to add
  37151. */
  37152. addCamera(newCamera: Camera): void;
  37153. /**
  37154. * Adds the given skeleton to this scene
  37155. * @param newSkeleton The skeleton to add
  37156. */
  37157. addSkeleton(newSkeleton: Skeleton): void;
  37158. /**
  37159. * Adds the given particle system to this scene
  37160. * @param newParticleSystem The particle system to add
  37161. */
  37162. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37163. /**
  37164. * Adds the given animation to this scene
  37165. * @param newAnimation The animation to add
  37166. */
  37167. addAnimation(newAnimation: Animation): void;
  37168. /**
  37169. * Adds the given animation group to this scene.
  37170. * @param newAnimationGroup The animation group to add
  37171. */
  37172. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37173. /**
  37174. * Adds the given multi-material to this scene
  37175. * @param newMultiMaterial The multi-material to add
  37176. */
  37177. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37178. /**
  37179. * Adds the given material to this scene
  37180. * @param newMaterial The material to add
  37181. */
  37182. addMaterial(newMaterial: Material): void;
  37183. /**
  37184. * Adds the given morph target to this scene
  37185. * @param newMorphTargetManager The morph target to add
  37186. */
  37187. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37188. /**
  37189. * Adds the given geometry to this scene
  37190. * @param newGeometry The geometry to add
  37191. */
  37192. addGeometry(newGeometry: Geometry): void;
  37193. /**
  37194. * Adds the given action manager to this scene
  37195. * @param newActionManager The action manager to add
  37196. */
  37197. addActionManager(newActionManager: AbstractActionManager): void;
  37198. /**
  37199. * Adds the given texture to this scene.
  37200. * @param newTexture The texture to add
  37201. */
  37202. addTexture(newTexture: BaseTexture): void;
  37203. /**
  37204. * Switch active camera
  37205. * @param newCamera defines the new active camera
  37206. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37207. */
  37208. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37209. /**
  37210. * sets the active camera of the scene using its ID
  37211. * @param id defines the camera's ID
  37212. * @return the new active camera or null if none found.
  37213. */
  37214. setActiveCameraByID(id: string): Nullable<Camera>;
  37215. /**
  37216. * sets the active camera of the scene using its name
  37217. * @param name defines the camera's name
  37218. * @returns the new active camera or null if none found.
  37219. */
  37220. setActiveCameraByName(name: string): Nullable<Camera>;
  37221. /**
  37222. * get an animation group using its name
  37223. * @param name defines the material's name
  37224. * @return the animation group or null if none found.
  37225. */
  37226. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37227. /**
  37228. * Get a material using its unique id
  37229. * @param uniqueId defines the material's unique id
  37230. * @return the material or null if none found.
  37231. */
  37232. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37233. /**
  37234. * get a material using its id
  37235. * @param id defines the material's ID
  37236. * @return the material or null if none found.
  37237. */
  37238. getMaterialByID(id: string): Nullable<Material>;
  37239. /**
  37240. * Gets a the last added material using a given id
  37241. * @param id defines the material's ID
  37242. * @return the last material with the given id or null if none found.
  37243. */
  37244. getLastMaterialByID(id: string): Nullable<Material>;
  37245. /**
  37246. * Gets a material using its name
  37247. * @param name defines the material's name
  37248. * @return the material or null if none found.
  37249. */
  37250. getMaterialByName(name: string): Nullable<Material>;
  37251. /**
  37252. * Get a texture using its unique id
  37253. * @param uniqueId defines the texture's unique id
  37254. * @return the texture or null if none found.
  37255. */
  37256. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37257. /**
  37258. * Gets a camera using its id
  37259. * @param id defines the id to look for
  37260. * @returns the camera or null if not found
  37261. */
  37262. getCameraByID(id: string): Nullable<Camera>;
  37263. /**
  37264. * Gets a camera using its unique id
  37265. * @param uniqueId defines the unique id to look for
  37266. * @returns the camera or null if not found
  37267. */
  37268. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37269. /**
  37270. * Gets a camera using its name
  37271. * @param name defines the camera's name
  37272. * @return the camera or null if none found.
  37273. */
  37274. getCameraByName(name: string): Nullable<Camera>;
  37275. /**
  37276. * Gets a bone using its id
  37277. * @param id defines the bone's id
  37278. * @return the bone or null if not found
  37279. */
  37280. getBoneByID(id: string): Nullable<Bone>;
  37281. /**
  37282. * Gets a bone using its id
  37283. * @param name defines the bone's name
  37284. * @return the bone or null if not found
  37285. */
  37286. getBoneByName(name: string): Nullable<Bone>;
  37287. /**
  37288. * Gets a light node using its name
  37289. * @param name defines the the light's name
  37290. * @return the light or null if none found.
  37291. */
  37292. getLightByName(name: string): Nullable<Light>;
  37293. /**
  37294. * Gets a light node using its id
  37295. * @param id defines the light's id
  37296. * @return the light or null if none found.
  37297. */
  37298. getLightByID(id: string): Nullable<Light>;
  37299. /**
  37300. * Gets a light node using its scene-generated unique ID
  37301. * @param uniqueId defines the light's unique id
  37302. * @return the light or null if none found.
  37303. */
  37304. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37305. /**
  37306. * Gets a particle system by id
  37307. * @param id defines the particle system id
  37308. * @return the corresponding system or null if none found
  37309. */
  37310. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37311. /**
  37312. * Gets a geometry using its ID
  37313. * @param id defines the geometry's id
  37314. * @return the geometry or null if none found.
  37315. */
  37316. getGeometryByID(id: string): Nullable<Geometry>;
  37317. private _getGeometryByUniqueID;
  37318. /**
  37319. * Add a new geometry to this scene
  37320. * @param geometry defines the geometry to be added to the scene.
  37321. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37322. * @return a boolean defining if the geometry was added or not
  37323. */
  37324. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37325. /**
  37326. * Removes an existing geometry
  37327. * @param geometry defines the geometry to be removed from the scene
  37328. * @return a boolean defining if the geometry was removed or not
  37329. */
  37330. removeGeometry(geometry: Geometry): boolean;
  37331. /**
  37332. * Gets the list of geometries attached to the scene
  37333. * @returns an array of Geometry
  37334. */
  37335. getGeometries(): Geometry[];
  37336. /**
  37337. * Gets the first added mesh found of a given ID
  37338. * @param id defines the id to search for
  37339. * @return the mesh found or null if not found at all
  37340. */
  37341. getMeshByID(id: string): Nullable<AbstractMesh>;
  37342. /**
  37343. * Gets a list of meshes using their id
  37344. * @param id defines the id to search for
  37345. * @returns a list of meshes
  37346. */
  37347. getMeshesByID(id: string): Array<AbstractMesh>;
  37348. /**
  37349. * Gets the first added transform node found of a given ID
  37350. * @param id defines the id to search for
  37351. * @return the found transform node or null if not found at all.
  37352. */
  37353. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37354. /**
  37355. * Gets a transform node with its auto-generated unique id
  37356. * @param uniqueId efines the unique id to search for
  37357. * @return the found transform node or null if not found at all.
  37358. */
  37359. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37360. /**
  37361. * Gets a list of transform nodes using their id
  37362. * @param id defines the id to search for
  37363. * @returns a list of transform nodes
  37364. */
  37365. getTransformNodesByID(id: string): Array<TransformNode>;
  37366. /**
  37367. * Gets a mesh with its auto-generated unique id
  37368. * @param uniqueId defines the unique id to search for
  37369. * @return the found mesh or null if not found at all.
  37370. */
  37371. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37372. /**
  37373. * Gets a the last added mesh using a given id
  37374. * @param id defines the id to search for
  37375. * @return the found mesh or null if not found at all.
  37376. */
  37377. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37378. /**
  37379. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37380. * @param id defines the id to search for
  37381. * @return the found node or null if not found at all
  37382. */
  37383. getLastEntryByID(id: string): Nullable<Node>;
  37384. /**
  37385. * Gets a node (Mesh, Camera, Light) using a given id
  37386. * @param id defines the id to search for
  37387. * @return the found node or null if not found at all
  37388. */
  37389. getNodeByID(id: string): Nullable<Node>;
  37390. /**
  37391. * Gets a node (Mesh, Camera, Light) using a given name
  37392. * @param name defines the name to search for
  37393. * @return the found node or null if not found at all.
  37394. */
  37395. getNodeByName(name: string): Nullable<Node>;
  37396. /**
  37397. * Gets a mesh using a given name
  37398. * @param name defines the name to search for
  37399. * @return the found mesh or null if not found at all.
  37400. */
  37401. getMeshByName(name: string): Nullable<AbstractMesh>;
  37402. /**
  37403. * Gets a transform node using a given name
  37404. * @param name defines the name to search for
  37405. * @return the found transform node or null if not found at all.
  37406. */
  37407. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37408. /**
  37409. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37410. * @param id defines the id to search for
  37411. * @return the found skeleton or null if not found at all.
  37412. */
  37413. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37414. /**
  37415. * Gets a skeleton using a given auto generated unique id
  37416. * @param uniqueId defines the unique id to search for
  37417. * @return the found skeleton or null if not found at all.
  37418. */
  37419. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37420. /**
  37421. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37422. * @param id defines the id to search for
  37423. * @return the found skeleton or null if not found at all.
  37424. */
  37425. getSkeletonById(id: string): Nullable<Skeleton>;
  37426. /**
  37427. * Gets a skeleton using a given name
  37428. * @param name defines the name to search for
  37429. * @return the found skeleton or null if not found at all.
  37430. */
  37431. getSkeletonByName(name: string): Nullable<Skeleton>;
  37432. /**
  37433. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37434. * @param id defines the id to search for
  37435. * @return the found morph target manager or null if not found at all.
  37436. */
  37437. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37438. /**
  37439. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37440. * @param id defines the id to search for
  37441. * @return the found morph target or null if not found at all.
  37442. */
  37443. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37444. /**
  37445. * Gets a boolean indicating if the given mesh is active
  37446. * @param mesh defines the mesh to look for
  37447. * @returns true if the mesh is in the active list
  37448. */
  37449. isActiveMesh(mesh: AbstractMesh): boolean;
  37450. /**
  37451. * Return a unique id as a string which can serve as an identifier for the scene
  37452. */
  37453. get uid(): string;
  37454. /**
  37455. * Add an externaly attached data from its key.
  37456. * This method call will fail and return false, if such key already exists.
  37457. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37458. * @param key the unique key that identifies the data
  37459. * @param data the data object to associate to the key for this Engine instance
  37460. * @return true if no such key were already present and the data was added successfully, false otherwise
  37461. */
  37462. addExternalData<T>(key: string, data: T): boolean;
  37463. /**
  37464. * Get an externaly attached data from its key
  37465. * @param key the unique key that identifies the data
  37466. * @return the associated data, if present (can be null), or undefined if not present
  37467. */
  37468. getExternalData<T>(key: string): Nullable<T>;
  37469. /**
  37470. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37471. * @param key the unique key that identifies the data
  37472. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37473. * @return the associated data, can be null if the factory returned null.
  37474. */
  37475. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37476. /**
  37477. * Remove an externaly attached data from the Engine instance
  37478. * @param key the unique key that identifies the data
  37479. * @return true if the data was successfully removed, false if it doesn't exist
  37480. */
  37481. removeExternalData(key: string): boolean;
  37482. private _evaluateSubMesh;
  37483. /**
  37484. * Clear the processed materials smart array preventing retention point in material dispose.
  37485. */
  37486. freeProcessedMaterials(): void;
  37487. private _preventFreeActiveMeshesAndRenderingGroups;
  37488. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37489. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37490. * when disposing several meshes in a row or a hierarchy of meshes.
  37491. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37492. */
  37493. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37494. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37495. /**
  37496. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37497. */
  37498. freeActiveMeshes(): void;
  37499. /**
  37500. * Clear the info related to rendering groups preventing retention points during dispose.
  37501. */
  37502. freeRenderingGroups(): void;
  37503. /** @hidden */
  37504. _isInIntermediateRendering(): boolean;
  37505. /**
  37506. * Lambda returning the list of potentially active meshes.
  37507. */
  37508. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37509. /**
  37510. * Lambda returning the list of potentially active sub meshes.
  37511. */
  37512. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37513. /**
  37514. * Lambda returning the list of potentially intersecting sub meshes.
  37515. */
  37516. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37517. /**
  37518. * Lambda returning the list of potentially colliding sub meshes.
  37519. */
  37520. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37521. private _activeMeshesFrozen;
  37522. private _skipEvaluateActiveMeshesCompletely;
  37523. /**
  37524. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37525. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37526. * @returns the current scene
  37527. */
  37528. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37529. /**
  37530. * Use this function to restart evaluating active meshes on every frame
  37531. * @returns the current scene
  37532. */
  37533. unfreezeActiveMeshes(): Scene;
  37534. private _evaluateActiveMeshes;
  37535. private _activeMesh;
  37536. /**
  37537. * Update the transform matrix to update from the current active camera
  37538. * @param force defines a boolean used to force the update even if cache is up to date
  37539. */
  37540. updateTransformMatrix(force?: boolean): void;
  37541. private _bindFrameBuffer;
  37542. /** @hidden */
  37543. _allowPostProcessClearColor: boolean;
  37544. /** @hidden */
  37545. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37546. private _processSubCameras;
  37547. private _checkIntersections;
  37548. /** @hidden */
  37549. _advancePhysicsEngineStep(step: number): void;
  37550. /**
  37551. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37552. */
  37553. getDeterministicFrameTime: () => number;
  37554. /** @hidden */
  37555. _animate(): void;
  37556. /** Execute all animations (for a frame) */
  37557. animate(): void;
  37558. /**
  37559. * Render the scene
  37560. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37561. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37562. */
  37563. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37564. /**
  37565. * Freeze all materials
  37566. * A frozen material will not be updatable but should be faster to render
  37567. */
  37568. freezeMaterials(): void;
  37569. /**
  37570. * Unfreeze all materials
  37571. * A frozen material will not be updatable but should be faster to render
  37572. */
  37573. unfreezeMaterials(): void;
  37574. /**
  37575. * Releases all held ressources
  37576. */
  37577. dispose(): void;
  37578. /**
  37579. * Gets if the scene is already disposed
  37580. */
  37581. get isDisposed(): boolean;
  37582. /**
  37583. * Call this function to reduce memory footprint of the scene.
  37584. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37585. */
  37586. clearCachedVertexData(): void;
  37587. /**
  37588. * This function will remove the local cached buffer data from texture.
  37589. * It will save memory but will prevent the texture from being rebuilt
  37590. */
  37591. cleanCachedTextureBuffer(): void;
  37592. /**
  37593. * Get the world extend vectors with an optional filter
  37594. *
  37595. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37596. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37597. */
  37598. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37599. min: Vector3;
  37600. max: Vector3;
  37601. };
  37602. /**
  37603. * Creates a ray that can be used to pick in the scene
  37604. * @param x defines the x coordinate of the origin (on-screen)
  37605. * @param y defines the y coordinate of the origin (on-screen)
  37606. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37607. * @param camera defines the camera to use for the picking
  37608. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37609. * @returns a Ray
  37610. */
  37611. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37612. /**
  37613. * Creates a ray that can be used to pick in the scene
  37614. * @param x defines the x coordinate of the origin (on-screen)
  37615. * @param y defines the y coordinate of the origin (on-screen)
  37616. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37617. * @param result defines the ray where to store the picking ray
  37618. * @param camera defines the camera to use for the picking
  37619. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37620. * @returns the current scene
  37621. */
  37622. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37623. /**
  37624. * Creates a ray that can be used to pick in the scene
  37625. * @param x defines the x coordinate of the origin (on-screen)
  37626. * @param y defines the y coordinate of the origin (on-screen)
  37627. * @param camera defines the camera to use for the picking
  37628. * @returns a Ray
  37629. */
  37630. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37631. /**
  37632. * Creates a ray that can be used to pick in the scene
  37633. * @param x defines the x coordinate of the origin (on-screen)
  37634. * @param y defines the y coordinate of the origin (on-screen)
  37635. * @param result defines the ray where to store the picking ray
  37636. * @param camera defines the camera to use for the picking
  37637. * @returns the current scene
  37638. */
  37639. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37640. /** Launch a ray to try to pick a mesh in the scene
  37641. * @param x position on screen
  37642. * @param y position on screen
  37643. * @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
  37644. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37645. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37646. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37647. * @returns a PickingInfo
  37648. */
  37649. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37650. /** Use the given ray to pick a mesh in the scene
  37651. * @param ray The ray to use to pick meshes
  37652. * @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
  37653. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37654. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37655. * @returns a PickingInfo
  37656. */
  37657. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37658. /**
  37659. * Launch a ray to try to pick a mesh in the scene
  37660. * @param x X position on screen
  37661. * @param y Y position on screen
  37662. * @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
  37663. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37664. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37665. * @returns an array of PickingInfo
  37666. */
  37667. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37668. /**
  37669. * Launch a ray to try to pick a mesh in the scene
  37670. * @param ray Ray to use
  37671. * @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
  37672. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37673. * @returns an array of PickingInfo
  37674. */
  37675. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37676. /**
  37677. * Force the value of meshUnderPointer
  37678. * @param mesh defines the mesh to use
  37679. */
  37680. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37681. /**
  37682. * Gets the mesh under the pointer
  37683. * @returns a Mesh or null if no mesh is under the pointer
  37684. */
  37685. getPointerOverMesh(): Nullable<AbstractMesh>;
  37686. /** @hidden */
  37687. _rebuildGeometries(): void;
  37688. /** @hidden */
  37689. _rebuildTextures(): void;
  37690. private _getByTags;
  37691. /**
  37692. * Get a list of meshes by tags
  37693. * @param tagsQuery defines the tags query to use
  37694. * @param forEach defines a predicate used to filter results
  37695. * @returns an array of Mesh
  37696. */
  37697. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37698. /**
  37699. * Get a list of cameras by tags
  37700. * @param tagsQuery defines the tags query to use
  37701. * @param forEach defines a predicate used to filter results
  37702. * @returns an array of Camera
  37703. */
  37704. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37705. /**
  37706. * Get a list of lights by tags
  37707. * @param tagsQuery defines the tags query to use
  37708. * @param forEach defines a predicate used to filter results
  37709. * @returns an array of Light
  37710. */
  37711. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37712. /**
  37713. * Get a list of materials by tags
  37714. * @param tagsQuery defines the tags query to use
  37715. * @param forEach defines a predicate used to filter results
  37716. * @returns an array of Material
  37717. */
  37718. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37719. /**
  37720. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37721. * This allowed control for front to back rendering or reversly depending of the special needs.
  37722. *
  37723. * @param renderingGroupId The rendering group id corresponding to its index
  37724. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37725. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37726. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37727. */
  37728. 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;
  37729. /**
  37730. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37731. *
  37732. * @param renderingGroupId The rendering group id corresponding to its index
  37733. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37734. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37735. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37736. */
  37737. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37738. /**
  37739. * Gets the current auto clear configuration for one rendering group of the rendering
  37740. * manager.
  37741. * @param index the rendering group index to get the information for
  37742. * @returns The auto clear setup for the requested rendering group
  37743. */
  37744. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37745. private _blockMaterialDirtyMechanism;
  37746. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37747. get blockMaterialDirtyMechanism(): boolean;
  37748. set blockMaterialDirtyMechanism(value: boolean);
  37749. /**
  37750. * Will flag all materials as dirty to trigger new shader compilation
  37751. * @param flag defines the flag used to specify which material part must be marked as dirty
  37752. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37753. */
  37754. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37755. /** @hidden */
  37756. _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;
  37757. /** @hidden */
  37758. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37759. /** @hidden */
  37760. _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;
  37761. /** @hidden */
  37762. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37763. /** @hidden */
  37764. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37765. /** @hidden */
  37766. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37767. }
  37768. }
  37769. declare module "babylonjs/assetContainer" {
  37770. import { AbstractScene } from "babylonjs/abstractScene";
  37771. import { Scene } from "babylonjs/scene";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37774. import { Skeleton } from "babylonjs/Bones/skeleton";
  37775. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37776. import { Animatable } from "babylonjs/Animations/animatable";
  37777. import { Nullable } from "babylonjs/types";
  37778. import { Node } from "babylonjs/node";
  37779. /**
  37780. * Set of assets to keep when moving a scene into an asset container.
  37781. */
  37782. export class KeepAssets extends AbstractScene {
  37783. }
  37784. /**
  37785. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37786. */
  37787. export class InstantiatedEntries {
  37788. /**
  37789. * List of new root nodes (eg. nodes with no parent)
  37790. */
  37791. rootNodes: TransformNode[];
  37792. /**
  37793. * List of new skeletons
  37794. */
  37795. skeletons: Skeleton[];
  37796. /**
  37797. * List of new animation groups
  37798. */
  37799. animationGroups: AnimationGroup[];
  37800. }
  37801. /**
  37802. * Container with a set of assets that can be added or removed from a scene.
  37803. */
  37804. export class AssetContainer extends AbstractScene {
  37805. /**
  37806. * The scene the AssetContainer belongs to.
  37807. */
  37808. scene: Scene;
  37809. /**
  37810. * Instantiates an AssetContainer.
  37811. * @param scene The scene the AssetContainer belongs to.
  37812. */
  37813. constructor(scene: Scene);
  37814. /**
  37815. * Instantiate or clone all meshes and add the new ones to the scene.
  37816. * Skeletons and animation groups will all be cloned
  37817. * @param nameFunction defines an optional function used to get new names for clones
  37818. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37819. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37820. */
  37821. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37822. /**
  37823. * Adds all the assets from the container to the scene.
  37824. */
  37825. addAllToScene(): void;
  37826. /**
  37827. * Removes all the assets in the container from the scene
  37828. */
  37829. removeAllFromScene(): void;
  37830. /**
  37831. * Disposes all the assets in the container
  37832. */
  37833. dispose(): void;
  37834. private _moveAssets;
  37835. /**
  37836. * Removes all the assets contained in the scene and adds them to the container.
  37837. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37838. */
  37839. moveAllFromScene(keepAssets?: KeepAssets): void;
  37840. /**
  37841. * 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.
  37842. * @returns the root mesh
  37843. */
  37844. createRootMesh(): Mesh;
  37845. /**
  37846. * Merge animations from this asset container into a scene
  37847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37848. * @param animatables set of animatables to retarget to a node from the scene
  37849. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37850. */
  37851. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37852. }
  37853. }
  37854. declare module "babylonjs/abstractScene" {
  37855. import { Scene } from "babylonjs/scene";
  37856. import { Nullable } from "babylonjs/types";
  37857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37858. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37859. import { Geometry } from "babylonjs/Meshes/geometry";
  37860. import { Skeleton } from "babylonjs/Bones/skeleton";
  37861. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37862. import { AssetContainer } from "babylonjs/assetContainer";
  37863. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37864. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37866. import { Material } from "babylonjs/Materials/material";
  37867. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37868. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37869. import { Camera } from "babylonjs/Cameras/camera";
  37870. import { Light } from "babylonjs/Lights/light";
  37871. import { Node } from "babylonjs/node";
  37872. import { Animation } from "babylonjs/Animations/animation";
  37873. /**
  37874. * Defines how the parser contract is defined.
  37875. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37876. */
  37877. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37878. /**
  37879. * Defines how the individual parser contract is defined.
  37880. * These parser can parse an individual asset
  37881. */
  37882. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37883. /**
  37884. * Base class of the scene acting as a container for the different elements composing a scene.
  37885. * This class is dynamically extended by the different components of the scene increasing
  37886. * flexibility and reducing coupling
  37887. */
  37888. export abstract class AbstractScene {
  37889. /**
  37890. * Stores the list of available parsers in the application.
  37891. */
  37892. private static _BabylonFileParsers;
  37893. /**
  37894. * Stores the list of available individual parsers in the application.
  37895. */
  37896. private static _IndividualBabylonFileParsers;
  37897. /**
  37898. * Adds a parser in the list of available ones
  37899. * @param name Defines the name of the parser
  37900. * @param parser Defines the parser to add
  37901. */
  37902. static AddParser(name: string, parser: BabylonFileParser): void;
  37903. /**
  37904. * Gets a general parser from the list of avaialble ones
  37905. * @param name Defines the name of the parser
  37906. * @returns the requested parser or null
  37907. */
  37908. static GetParser(name: string): Nullable<BabylonFileParser>;
  37909. /**
  37910. * Adds n individual parser in the list of available ones
  37911. * @param name Defines the name of the parser
  37912. * @param parser Defines the parser to add
  37913. */
  37914. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37915. /**
  37916. * Gets an individual parser from the list of avaialble ones
  37917. * @param name Defines the name of the parser
  37918. * @returns the requested parser or null
  37919. */
  37920. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37921. /**
  37922. * Parser json data and populate both a scene and its associated container object
  37923. * @param jsonData Defines the data to parse
  37924. * @param scene Defines the scene to parse the data for
  37925. * @param container Defines the container attached to the parsing sequence
  37926. * @param rootUrl Defines the root url of the data
  37927. */
  37928. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37929. /**
  37930. * Gets the list of root nodes (ie. nodes with no parent)
  37931. */
  37932. rootNodes: Node[];
  37933. /** All of the cameras added to this scene
  37934. * @see http://doc.babylonjs.com/babylon101/cameras
  37935. */
  37936. cameras: Camera[];
  37937. /**
  37938. * All of the lights added to this scene
  37939. * @see http://doc.babylonjs.com/babylon101/lights
  37940. */
  37941. lights: Light[];
  37942. /**
  37943. * All of the (abstract) meshes added to this scene
  37944. */
  37945. meshes: AbstractMesh[];
  37946. /**
  37947. * The list of skeletons added to the scene
  37948. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37949. */
  37950. skeletons: Skeleton[];
  37951. /**
  37952. * All of the particle systems added to this scene
  37953. * @see http://doc.babylonjs.com/babylon101/particles
  37954. */
  37955. particleSystems: IParticleSystem[];
  37956. /**
  37957. * Gets a list of Animations associated with the scene
  37958. */
  37959. animations: Animation[];
  37960. /**
  37961. * All of the animation groups added to this scene
  37962. * @see http://doc.babylonjs.com/how_to/group
  37963. */
  37964. animationGroups: AnimationGroup[];
  37965. /**
  37966. * All of the multi-materials added to this scene
  37967. * @see http://doc.babylonjs.com/how_to/multi_materials
  37968. */
  37969. multiMaterials: MultiMaterial[];
  37970. /**
  37971. * All of the materials added to this scene
  37972. * In the context of a Scene, it is not supposed to be modified manually.
  37973. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37974. * Note also that the order of the Material within the array is not significant and might change.
  37975. * @see http://doc.babylonjs.com/babylon101/materials
  37976. */
  37977. materials: Material[];
  37978. /**
  37979. * The list of morph target managers added to the scene
  37980. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37981. */
  37982. morphTargetManagers: MorphTargetManager[];
  37983. /**
  37984. * The list of geometries used in the scene.
  37985. */
  37986. geometries: Geometry[];
  37987. /**
  37988. * All of the tranform nodes added to this scene
  37989. * In the context of a Scene, it is not supposed to be modified manually.
  37990. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37991. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37992. * @see http://doc.babylonjs.com/how_to/transformnode
  37993. */
  37994. transformNodes: TransformNode[];
  37995. /**
  37996. * ActionManagers available on the scene.
  37997. */
  37998. actionManagers: AbstractActionManager[];
  37999. /**
  38000. * Textures to keep.
  38001. */
  38002. textures: BaseTexture[];
  38003. /**
  38004. * Environment texture for the scene
  38005. */
  38006. environmentTexture: Nullable<BaseTexture>;
  38007. /**
  38008. * @returns all meshes, lights, cameras, transformNodes and bones
  38009. */
  38010. getNodes(): Array<Node>;
  38011. }
  38012. }
  38013. declare module "babylonjs/Audio/sound" {
  38014. import { Observable } from "babylonjs/Misc/observable";
  38015. import { Vector3 } from "babylonjs/Maths/math.vector";
  38016. import { Nullable } from "babylonjs/types";
  38017. import { Scene } from "babylonjs/scene";
  38018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38019. /**
  38020. * Interface used to define options for Sound class
  38021. */
  38022. export interface ISoundOptions {
  38023. /**
  38024. * Does the sound autoplay once loaded.
  38025. */
  38026. autoplay?: boolean;
  38027. /**
  38028. * Does the sound loop after it finishes playing once.
  38029. */
  38030. loop?: boolean;
  38031. /**
  38032. * Sound's volume
  38033. */
  38034. volume?: number;
  38035. /**
  38036. * Is it a spatial sound?
  38037. */
  38038. spatialSound?: boolean;
  38039. /**
  38040. * Maximum distance to hear that sound
  38041. */
  38042. maxDistance?: number;
  38043. /**
  38044. * Uses user defined attenuation function
  38045. */
  38046. useCustomAttenuation?: boolean;
  38047. /**
  38048. * Define the roll off factor of spatial sounds.
  38049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38050. */
  38051. rolloffFactor?: number;
  38052. /**
  38053. * Define the reference distance the sound should be heard perfectly.
  38054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38055. */
  38056. refDistance?: number;
  38057. /**
  38058. * Define the distance attenuation model the sound will follow.
  38059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38060. */
  38061. distanceModel?: string;
  38062. /**
  38063. * Defines the playback speed (1 by default)
  38064. */
  38065. playbackRate?: number;
  38066. /**
  38067. * Defines if the sound is from a streaming source
  38068. */
  38069. streaming?: boolean;
  38070. /**
  38071. * Defines an optional length (in seconds) inside the sound file
  38072. */
  38073. length?: number;
  38074. /**
  38075. * Defines an optional offset (in seconds) inside the sound file
  38076. */
  38077. offset?: number;
  38078. /**
  38079. * If true, URLs will not be required to state the audio file codec to use.
  38080. */
  38081. skipCodecCheck?: boolean;
  38082. }
  38083. /**
  38084. * Defines a sound that can be played in the application.
  38085. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38087. */
  38088. export class Sound {
  38089. /**
  38090. * The name of the sound in the scene.
  38091. */
  38092. name: string;
  38093. /**
  38094. * Does the sound autoplay once loaded.
  38095. */
  38096. autoplay: boolean;
  38097. /**
  38098. * Does the sound loop after it finishes playing once.
  38099. */
  38100. loop: boolean;
  38101. /**
  38102. * Does the sound use a custom attenuation curve to simulate the falloff
  38103. * happening when the source gets further away from the camera.
  38104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38105. */
  38106. useCustomAttenuation: boolean;
  38107. /**
  38108. * The sound track id this sound belongs to.
  38109. */
  38110. soundTrackId: number;
  38111. /**
  38112. * Is this sound currently played.
  38113. */
  38114. isPlaying: boolean;
  38115. /**
  38116. * Is this sound currently paused.
  38117. */
  38118. isPaused: boolean;
  38119. /**
  38120. * Does this sound enables spatial sound.
  38121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38122. */
  38123. spatialSound: boolean;
  38124. /**
  38125. * Define the reference distance the sound should be heard perfectly.
  38126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38127. */
  38128. refDistance: number;
  38129. /**
  38130. * Define the roll off factor of spatial sounds.
  38131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38132. */
  38133. rolloffFactor: number;
  38134. /**
  38135. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38137. */
  38138. maxDistance: number;
  38139. /**
  38140. * Define the distance attenuation model the sound will follow.
  38141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38142. */
  38143. distanceModel: string;
  38144. /**
  38145. * @hidden
  38146. * Back Compat
  38147. **/
  38148. onended: () => any;
  38149. /**
  38150. * Observable event when the current playing sound finishes.
  38151. */
  38152. onEndedObservable: Observable<Sound>;
  38153. private _panningModel;
  38154. private _playbackRate;
  38155. private _streaming;
  38156. private _startTime;
  38157. private _startOffset;
  38158. private _position;
  38159. /** @hidden */
  38160. _positionInEmitterSpace: boolean;
  38161. private _localDirection;
  38162. private _volume;
  38163. private _isReadyToPlay;
  38164. private _isDirectional;
  38165. private _readyToPlayCallback;
  38166. private _audioBuffer;
  38167. private _soundSource;
  38168. private _streamingSource;
  38169. private _soundPanner;
  38170. private _soundGain;
  38171. private _inputAudioNode;
  38172. private _outputAudioNode;
  38173. private _coneInnerAngle;
  38174. private _coneOuterAngle;
  38175. private _coneOuterGain;
  38176. private _scene;
  38177. private _connectedTransformNode;
  38178. private _customAttenuationFunction;
  38179. private _registerFunc;
  38180. private _isOutputConnected;
  38181. private _htmlAudioElement;
  38182. private _urlType;
  38183. private _length?;
  38184. private _offset?;
  38185. /** @hidden */
  38186. static _SceneComponentInitialization: (scene: Scene) => void;
  38187. /**
  38188. * Create a sound and attach it to a scene
  38189. * @param name Name of your sound
  38190. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38191. * @param scene defines the scene the sound belongs to
  38192. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38193. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38194. */
  38195. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38196. /**
  38197. * Release the sound and its associated resources
  38198. */
  38199. dispose(): void;
  38200. /**
  38201. * Gets if the sounds is ready to be played or not.
  38202. * @returns true if ready, otherwise false
  38203. */
  38204. isReady(): boolean;
  38205. private _soundLoaded;
  38206. /**
  38207. * Sets the data of the sound from an audiobuffer
  38208. * @param audioBuffer The audioBuffer containing the data
  38209. */
  38210. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38211. /**
  38212. * Updates the current sounds options such as maxdistance, loop...
  38213. * @param options A JSON object containing values named as the object properties
  38214. */
  38215. updateOptions(options: ISoundOptions): void;
  38216. private _createSpatialParameters;
  38217. private _updateSpatialParameters;
  38218. /**
  38219. * Switch the panning model to HRTF:
  38220. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38222. */
  38223. switchPanningModelToHRTF(): void;
  38224. /**
  38225. * Switch the panning model to Equal Power:
  38226. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38228. */
  38229. switchPanningModelToEqualPower(): void;
  38230. private _switchPanningModel;
  38231. /**
  38232. * Connect this sound to a sound track audio node like gain...
  38233. * @param soundTrackAudioNode the sound track audio node to connect to
  38234. */
  38235. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38236. /**
  38237. * Transform this sound into a directional source
  38238. * @param coneInnerAngle Size of the inner cone in degree
  38239. * @param coneOuterAngle Size of the outer cone in degree
  38240. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38241. */
  38242. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38243. /**
  38244. * Gets or sets the inner angle for the directional cone.
  38245. */
  38246. get directionalConeInnerAngle(): number;
  38247. /**
  38248. * Gets or sets the inner angle for the directional cone.
  38249. */
  38250. set directionalConeInnerAngle(value: number);
  38251. /**
  38252. * Gets or sets the outer angle for the directional cone.
  38253. */
  38254. get directionalConeOuterAngle(): number;
  38255. /**
  38256. * Gets or sets the outer angle for the directional cone.
  38257. */
  38258. set directionalConeOuterAngle(value: number);
  38259. /**
  38260. * Sets the position of the emitter if spatial sound is enabled
  38261. * @param newPosition Defines the new posisiton
  38262. */
  38263. setPosition(newPosition: Vector3): void;
  38264. /**
  38265. * Sets the local direction of the emitter if spatial sound is enabled
  38266. * @param newLocalDirection Defines the new local direction
  38267. */
  38268. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38269. private _updateDirection;
  38270. /** @hidden */
  38271. updateDistanceFromListener(): void;
  38272. /**
  38273. * Sets a new custom attenuation function for the sound.
  38274. * @param callback Defines the function used for the attenuation
  38275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38276. */
  38277. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38278. /**
  38279. * Play the sound
  38280. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38281. * @param offset (optional) Start the sound at a specific time in seconds
  38282. * @param length (optional) Sound duration (in seconds)
  38283. */
  38284. play(time?: number, offset?: number, length?: number): void;
  38285. private _onended;
  38286. /**
  38287. * Stop the sound
  38288. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38289. */
  38290. stop(time?: number): void;
  38291. /**
  38292. * Put the sound in pause
  38293. */
  38294. pause(): void;
  38295. /**
  38296. * Sets a dedicated volume for this sounds
  38297. * @param newVolume Define the new volume of the sound
  38298. * @param time Define time for gradual change to new volume
  38299. */
  38300. setVolume(newVolume: number, time?: number): void;
  38301. /**
  38302. * Set the sound play back rate
  38303. * @param newPlaybackRate Define the playback rate the sound should be played at
  38304. */
  38305. setPlaybackRate(newPlaybackRate: number): void;
  38306. /**
  38307. * Gets the volume of the sound.
  38308. * @returns the volume of the sound
  38309. */
  38310. getVolume(): number;
  38311. /**
  38312. * Attach the sound to a dedicated mesh
  38313. * @param transformNode The transform node to connect the sound with
  38314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38315. */
  38316. attachToMesh(transformNode: TransformNode): void;
  38317. /**
  38318. * Detach the sound from the previously attached mesh
  38319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38320. */
  38321. detachFromMesh(): void;
  38322. private _onRegisterAfterWorldMatrixUpdate;
  38323. /**
  38324. * Clone the current sound in the scene.
  38325. * @returns the new sound clone
  38326. */
  38327. clone(): Nullable<Sound>;
  38328. /**
  38329. * Gets the current underlying audio buffer containing the data
  38330. * @returns the audio buffer
  38331. */
  38332. getAudioBuffer(): Nullable<AudioBuffer>;
  38333. /**
  38334. * Serializes the Sound in a JSON representation
  38335. * @returns the JSON representation of the sound
  38336. */
  38337. serialize(): any;
  38338. /**
  38339. * Parse a JSON representation of a sound to innstantiate in a given scene
  38340. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38341. * @param scene Define the scene the new parsed sound should be created in
  38342. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38343. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38344. * @returns the newly parsed sound
  38345. */
  38346. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38347. }
  38348. }
  38349. declare module "babylonjs/Actions/directAudioActions" {
  38350. import { Action } from "babylonjs/Actions/action";
  38351. import { Condition } from "babylonjs/Actions/condition";
  38352. import { Sound } from "babylonjs/Audio/sound";
  38353. /**
  38354. * This defines an action helpful to play a defined sound on a triggered action.
  38355. */
  38356. export class PlaySoundAction extends Action {
  38357. private _sound;
  38358. /**
  38359. * Instantiate the action
  38360. * @param triggerOptions defines the trigger options
  38361. * @param sound defines the sound to play
  38362. * @param condition defines the trigger related conditions
  38363. */
  38364. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38365. /** @hidden */
  38366. _prepare(): void;
  38367. /**
  38368. * Execute the action and play the sound.
  38369. */
  38370. execute(): void;
  38371. /**
  38372. * Serializes the actions and its related information.
  38373. * @param parent defines the object to serialize in
  38374. * @returns the serialized object
  38375. */
  38376. serialize(parent: any): any;
  38377. }
  38378. /**
  38379. * This defines an action helpful to stop a defined sound on a triggered action.
  38380. */
  38381. export class StopSoundAction extends Action {
  38382. private _sound;
  38383. /**
  38384. * Instantiate the action
  38385. * @param triggerOptions defines the trigger options
  38386. * @param sound defines the sound to stop
  38387. * @param condition defines the trigger related conditions
  38388. */
  38389. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38390. /** @hidden */
  38391. _prepare(): void;
  38392. /**
  38393. * Execute the action and stop the sound.
  38394. */
  38395. execute(): void;
  38396. /**
  38397. * Serializes the actions and its related information.
  38398. * @param parent defines the object to serialize in
  38399. * @returns the serialized object
  38400. */
  38401. serialize(parent: any): any;
  38402. }
  38403. }
  38404. declare module "babylonjs/Actions/interpolateValueAction" {
  38405. import { Action } from "babylonjs/Actions/action";
  38406. import { Condition } from "babylonjs/Actions/condition";
  38407. import { Observable } from "babylonjs/Misc/observable";
  38408. /**
  38409. * This defines an action responsible to change the value of a property
  38410. * by interpolating between its current value and the newly set one once triggered.
  38411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38412. */
  38413. export class InterpolateValueAction extends Action {
  38414. /**
  38415. * Defines the path of the property where the value should be interpolated
  38416. */
  38417. propertyPath: string;
  38418. /**
  38419. * Defines the target value at the end of the interpolation.
  38420. */
  38421. value: any;
  38422. /**
  38423. * Defines the time it will take for the property to interpolate to the value.
  38424. */
  38425. duration: number;
  38426. /**
  38427. * Defines if the other scene animations should be stopped when the action has been triggered
  38428. */
  38429. stopOtherAnimations?: boolean;
  38430. /**
  38431. * Defines a callback raised once the interpolation animation has been done.
  38432. */
  38433. onInterpolationDone?: () => void;
  38434. /**
  38435. * Observable triggered once the interpolation animation has been done.
  38436. */
  38437. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38438. private _target;
  38439. private _effectiveTarget;
  38440. private _property;
  38441. /**
  38442. * Instantiate the action
  38443. * @param triggerOptions defines the trigger options
  38444. * @param target defines the object containing the value to interpolate
  38445. * @param propertyPath defines the path to the property in the target object
  38446. * @param value defines the target value at the end of the interpolation
  38447. * @param duration deines the time it will take for the property to interpolate to the value.
  38448. * @param condition defines the trigger related conditions
  38449. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38450. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38451. */
  38452. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38453. /** @hidden */
  38454. _prepare(): void;
  38455. /**
  38456. * Execute the action starts the value interpolation.
  38457. */
  38458. execute(): void;
  38459. /**
  38460. * Serializes the actions and its related information.
  38461. * @param parent defines the object to serialize in
  38462. * @returns the serialized object
  38463. */
  38464. serialize(parent: any): any;
  38465. }
  38466. }
  38467. declare module "babylonjs/Actions/index" {
  38468. export * from "babylonjs/Actions/abstractActionManager";
  38469. export * from "babylonjs/Actions/action";
  38470. export * from "babylonjs/Actions/actionEvent";
  38471. export * from "babylonjs/Actions/actionManager";
  38472. export * from "babylonjs/Actions/condition";
  38473. export * from "babylonjs/Actions/directActions";
  38474. export * from "babylonjs/Actions/directAudioActions";
  38475. export * from "babylonjs/Actions/interpolateValueAction";
  38476. }
  38477. declare module "babylonjs/Animations/index" {
  38478. export * from "babylonjs/Animations/animatable";
  38479. export * from "babylonjs/Animations/animation";
  38480. export * from "babylonjs/Animations/animationGroup";
  38481. export * from "babylonjs/Animations/animationPropertiesOverride";
  38482. export * from "babylonjs/Animations/easing";
  38483. export * from "babylonjs/Animations/runtimeAnimation";
  38484. export * from "babylonjs/Animations/animationEvent";
  38485. export * from "babylonjs/Animations/animationGroup";
  38486. export * from "babylonjs/Animations/animationKey";
  38487. export * from "babylonjs/Animations/animationRange";
  38488. export * from "babylonjs/Animations/animatable.interface";
  38489. }
  38490. declare module "babylonjs/Audio/soundTrack" {
  38491. import { Sound } from "babylonjs/Audio/sound";
  38492. import { Analyser } from "babylonjs/Audio/analyser";
  38493. import { Scene } from "babylonjs/scene";
  38494. /**
  38495. * Options allowed during the creation of a sound track.
  38496. */
  38497. export interface ISoundTrackOptions {
  38498. /**
  38499. * The volume the sound track should take during creation
  38500. */
  38501. volume?: number;
  38502. /**
  38503. * Define if the sound track is the main sound track of the scene
  38504. */
  38505. mainTrack?: boolean;
  38506. }
  38507. /**
  38508. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38509. * It will be also used in a future release to apply effects on a specific track.
  38510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38511. */
  38512. export class SoundTrack {
  38513. /**
  38514. * The unique identifier of the sound track in the scene.
  38515. */
  38516. id: number;
  38517. /**
  38518. * The list of sounds included in the sound track.
  38519. */
  38520. soundCollection: Array<Sound>;
  38521. private _outputAudioNode;
  38522. private _scene;
  38523. private _connectedAnalyser;
  38524. private _options;
  38525. private _isInitialized;
  38526. /**
  38527. * Creates a new sound track.
  38528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38529. * @param scene Define the scene the sound track belongs to
  38530. * @param options
  38531. */
  38532. constructor(scene: Scene, options?: ISoundTrackOptions);
  38533. private _initializeSoundTrackAudioGraph;
  38534. /**
  38535. * Release the sound track and its associated resources
  38536. */
  38537. dispose(): void;
  38538. /**
  38539. * Adds a sound to this sound track
  38540. * @param sound define the cound to add
  38541. * @ignoreNaming
  38542. */
  38543. AddSound(sound: Sound): void;
  38544. /**
  38545. * Removes a sound to this sound track
  38546. * @param sound define the cound to remove
  38547. * @ignoreNaming
  38548. */
  38549. RemoveSound(sound: Sound): void;
  38550. /**
  38551. * Set a global volume for the full sound track.
  38552. * @param newVolume Define the new volume of the sound track
  38553. */
  38554. setVolume(newVolume: number): void;
  38555. /**
  38556. * Switch the panning model to HRTF:
  38557. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38559. */
  38560. switchPanningModelToHRTF(): void;
  38561. /**
  38562. * Switch the panning model to Equal Power:
  38563. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38565. */
  38566. switchPanningModelToEqualPower(): void;
  38567. /**
  38568. * Connect the sound track to an audio analyser allowing some amazing
  38569. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38571. * @param analyser The analyser to connect to the engine
  38572. */
  38573. connectToAnalyser(analyser: Analyser): void;
  38574. }
  38575. }
  38576. declare module "babylonjs/Audio/audioSceneComponent" {
  38577. import { Sound } from "babylonjs/Audio/sound";
  38578. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38579. import { Nullable } from "babylonjs/types";
  38580. import { Vector3 } from "babylonjs/Maths/math.vector";
  38581. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38582. import { Scene } from "babylonjs/scene";
  38583. import { AbstractScene } from "babylonjs/abstractScene";
  38584. import "babylonjs/Audio/audioEngine";
  38585. module "babylonjs/abstractScene" {
  38586. interface AbstractScene {
  38587. /**
  38588. * The list of sounds used in the scene.
  38589. */
  38590. sounds: Nullable<Array<Sound>>;
  38591. }
  38592. }
  38593. module "babylonjs/scene" {
  38594. interface Scene {
  38595. /**
  38596. * @hidden
  38597. * Backing field
  38598. */
  38599. _mainSoundTrack: SoundTrack;
  38600. /**
  38601. * The main sound track played by the scene.
  38602. * It cotains your primary collection of sounds.
  38603. */
  38604. mainSoundTrack: SoundTrack;
  38605. /**
  38606. * The list of sound tracks added to the scene
  38607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38608. */
  38609. soundTracks: Nullable<Array<SoundTrack>>;
  38610. /**
  38611. * Gets a sound using a given name
  38612. * @param name defines the name to search for
  38613. * @return the found sound or null if not found at all.
  38614. */
  38615. getSoundByName(name: string): Nullable<Sound>;
  38616. /**
  38617. * Gets or sets if audio support is enabled
  38618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38619. */
  38620. audioEnabled: boolean;
  38621. /**
  38622. * Gets or sets if audio will be output to headphones
  38623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38624. */
  38625. headphone: boolean;
  38626. /**
  38627. * Gets or sets custom audio listener position provider
  38628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38629. */
  38630. audioListenerPositionProvider: Nullable<() => Vector3>;
  38631. /**
  38632. * Gets or sets a refresh rate when using 3D audio positioning
  38633. */
  38634. audioPositioningRefreshRate: number;
  38635. }
  38636. }
  38637. /**
  38638. * Defines the sound scene component responsible to manage any sounds
  38639. * in a given scene.
  38640. */
  38641. export class AudioSceneComponent implements ISceneSerializableComponent {
  38642. /**
  38643. * The component name helpfull to identify the component in the list of scene components.
  38644. */
  38645. readonly name: string;
  38646. /**
  38647. * The scene the component belongs to.
  38648. */
  38649. scene: Scene;
  38650. private _audioEnabled;
  38651. /**
  38652. * Gets whether audio is enabled or not.
  38653. * Please use related enable/disable method to switch state.
  38654. */
  38655. get audioEnabled(): boolean;
  38656. private _headphone;
  38657. /**
  38658. * Gets whether audio is outputing to headphone or not.
  38659. * Please use the according Switch methods to change output.
  38660. */
  38661. get headphone(): boolean;
  38662. /**
  38663. * Gets or sets a refresh rate when using 3D audio positioning
  38664. */
  38665. audioPositioningRefreshRate: number;
  38666. private _audioListenerPositionProvider;
  38667. /**
  38668. * Gets the current audio listener position provider
  38669. */
  38670. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38671. /**
  38672. * Sets a custom listener position for all sounds in the scene
  38673. * By default, this is the position of the first active camera
  38674. */
  38675. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38676. /**
  38677. * Creates a new instance of the component for the given scene
  38678. * @param scene Defines the scene to register the component in
  38679. */
  38680. constructor(scene: Scene);
  38681. /**
  38682. * Registers the component in a given scene
  38683. */
  38684. register(): void;
  38685. /**
  38686. * Rebuilds the elements related to this component in case of
  38687. * context lost for instance.
  38688. */
  38689. rebuild(): void;
  38690. /**
  38691. * Serializes the component data to the specified json object
  38692. * @param serializationObject The object to serialize to
  38693. */
  38694. serialize(serializationObject: any): void;
  38695. /**
  38696. * Adds all the elements from the container to the scene
  38697. * @param container the container holding the elements
  38698. */
  38699. addFromContainer(container: AbstractScene): void;
  38700. /**
  38701. * Removes all the elements in the container from the scene
  38702. * @param container contains the elements to remove
  38703. * @param dispose if the removed element should be disposed (default: false)
  38704. */
  38705. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38706. /**
  38707. * Disposes the component and the associated ressources.
  38708. */
  38709. dispose(): void;
  38710. /**
  38711. * Disables audio in the associated scene.
  38712. */
  38713. disableAudio(): void;
  38714. /**
  38715. * Enables audio in the associated scene.
  38716. */
  38717. enableAudio(): void;
  38718. /**
  38719. * Switch audio to headphone output.
  38720. */
  38721. switchAudioModeForHeadphones(): void;
  38722. /**
  38723. * Switch audio to normal speakers.
  38724. */
  38725. switchAudioModeForNormalSpeakers(): void;
  38726. private _cachedCameraDirection;
  38727. private _cachedCameraPosition;
  38728. private _lastCheck;
  38729. private _afterRender;
  38730. }
  38731. }
  38732. declare module "babylonjs/Audio/weightedsound" {
  38733. import { Sound } from "babylonjs/Audio/sound";
  38734. /**
  38735. * Wraps one or more Sound objects and selects one with random weight for playback.
  38736. */
  38737. export class WeightedSound {
  38738. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38739. loop: boolean;
  38740. private _coneInnerAngle;
  38741. private _coneOuterAngle;
  38742. private _volume;
  38743. /** A Sound is currently playing. */
  38744. isPlaying: boolean;
  38745. /** A Sound is currently paused. */
  38746. isPaused: boolean;
  38747. private _sounds;
  38748. private _weights;
  38749. private _currentIndex?;
  38750. /**
  38751. * Creates a new WeightedSound from the list of sounds given.
  38752. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38753. * @param sounds Array of Sounds that will be selected from.
  38754. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38755. */
  38756. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38757. /**
  38758. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38759. */
  38760. get directionalConeInnerAngle(): number;
  38761. /**
  38762. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38763. */
  38764. set directionalConeInnerAngle(value: 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. get directionalConeOuterAngle(): number;
  38770. /**
  38771. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38772. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38773. */
  38774. set directionalConeOuterAngle(value: number);
  38775. /**
  38776. * Playback volume.
  38777. */
  38778. get volume(): number;
  38779. /**
  38780. * Playback volume.
  38781. */
  38782. set volume(value: number);
  38783. private _onended;
  38784. /**
  38785. * Suspend playback
  38786. */
  38787. pause(): void;
  38788. /**
  38789. * Stop playback
  38790. */
  38791. stop(): void;
  38792. /**
  38793. * Start playback.
  38794. * @param startOffset Position the clip head at a specific time in seconds.
  38795. */
  38796. play(startOffset?: number): void;
  38797. }
  38798. }
  38799. declare module "babylonjs/Audio/index" {
  38800. export * from "babylonjs/Audio/analyser";
  38801. export * from "babylonjs/Audio/audioEngine";
  38802. export * from "babylonjs/Audio/audioSceneComponent";
  38803. export * from "babylonjs/Audio/sound";
  38804. export * from "babylonjs/Audio/soundTrack";
  38805. export * from "babylonjs/Audio/weightedsound";
  38806. }
  38807. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38808. import { Behavior } from "babylonjs/Behaviors/behavior";
  38809. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38810. import { BackEase } from "babylonjs/Animations/easing";
  38811. /**
  38812. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38814. */
  38815. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38816. /**
  38817. * Gets the name of the behavior.
  38818. */
  38819. get name(): string;
  38820. /**
  38821. * The easing function used by animations
  38822. */
  38823. static EasingFunction: BackEase;
  38824. /**
  38825. * The easing mode used by animations
  38826. */
  38827. static EasingMode: number;
  38828. /**
  38829. * The duration of the animation, in milliseconds
  38830. */
  38831. transitionDuration: number;
  38832. /**
  38833. * Length of the distance animated by the transition when lower radius is reached
  38834. */
  38835. lowerRadiusTransitionRange: number;
  38836. /**
  38837. * Length of the distance animated by the transition when upper radius is reached
  38838. */
  38839. upperRadiusTransitionRange: number;
  38840. private _autoTransitionRange;
  38841. /**
  38842. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38843. */
  38844. get autoTransitionRange(): boolean;
  38845. /**
  38846. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38847. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38848. */
  38849. set autoTransitionRange(value: boolean);
  38850. private _attachedCamera;
  38851. private _onAfterCheckInputsObserver;
  38852. private _onMeshTargetChangedObserver;
  38853. /**
  38854. * Initializes the behavior.
  38855. */
  38856. init(): void;
  38857. /**
  38858. * Attaches the behavior to its arc rotate camera.
  38859. * @param camera Defines the camera to attach the behavior to
  38860. */
  38861. attach(camera: ArcRotateCamera): void;
  38862. /**
  38863. * Detaches the behavior from its current arc rotate camera.
  38864. */
  38865. detach(): void;
  38866. private _radiusIsAnimating;
  38867. private _radiusBounceTransition;
  38868. private _animatables;
  38869. private _cachedWheelPrecision;
  38870. /**
  38871. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38872. * @param radiusLimit The limit to check against.
  38873. * @return Bool to indicate if at limit.
  38874. */
  38875. private _isRadiusAtLimit;
  38876. /**
  38877. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38878. * @param radiusDelta The delta by which to animate to. Can be negative.
  38879. */
  38880. private _applyBoundRadiusAnimation;
  38881. /**
  38882. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38883. */
  38884. protected _clearAnimationLocks(): void;
  38885. /**
  38886. * Stops and removes all animations that have been applied to the camera
  38887. */
  38888. stopAllAnimations(): void;
  38889. }
  38890. }
  38891. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38892. import { Behavior } from "babylonjs/Behaviors/behavior";
  38893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38894. import { ExponentialEase } from "babylonjs/Animations/easing";
  38895. import { Nullable } from "babylonjs/types";
  38896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38897. import { Vector3 } from "babylonjs/Maths/math.vector";
  38898. /**
  38899. * 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.
  38900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38901. */
  38902. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38903. /**
  38904. * Gets the name of the behavior.
  38905. */
  38906. get name(): string;
  38907. private _mode;
  38908. private _radiusScale;
  38909. private _positionScale;
  38910. private _defaultElevation;
  38911. private _elevationReturnTime;
  38912. private _elevationReturnWaitTime;
  38913. private _zoomStopsAnimation;
  38914. private _framingTime;
  38915. /**
  38916. * The easing function used by animations
  38917. */
  38918. static EasingFunction: ExponentialEase;
  38919. /**
  38920. * The easing mode used by animations
  38921. */
  38922. static EasingMode: number;
  38923. /**
  38924. * Sets the current mode used by the behavior
  38925. */
  38926. set mode(mode: number);
  38927. /**
  38928. * Gets current mode used by the behavior.
  38929. */
  38930. get mode(): number;
  38931. /**
  38932. * Sets the scale applied to the radius (1 by default)
  38933. */
  38934. set radiusScale(radius: number);
  38935. /**
  38936. * Gets the scale applied to the radius
  38937. */
  38938. get radiusScale(): number;
  38939. /**
  38940. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38941. */
  38942. set positionScale(scale: number);
  38943. /**
  38944. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38945. */
  38946. get positionScale(): number;
  38947. /**
  38948. * Sets 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. set defaultElevation(elevation: number);
  38952. /**
  38953. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38954. * behaviour is triggered, in radians.
  38955. */
  38956. get defaultElevation(): number;
  38957. /**
  38958. * Sets the time (in milliseconds) taken to return to the default beta position.
  38959. * Negative value indicates camera should not return to default.
  38960. */
  38961. set elevationReturnTime(speed: number);
  38962. /**
  38963. * Gets the time (in milliseconds) taken to return to the default beta position.
  38964. * Negative value indicates camera should not return to default.
  38965. */
  38966. get elevationReturnTime(): number;
  38967. /**
  38968. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38969. */
  38970. set elevationReturnWaitTime(time: number);
  38971. /**
  38972. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38973. */
  38974. get elevationReturnWaitTime(): number;
  38975. /**
  38976. * Sets the flag that indicates if user zooming should stop animation.
  38977. */
  38978. set zoomStopsAnimation(flag: boolean);
  38979. /**
  38980. * Gets the flag that indicates if user zooming should stop animation.
  38981. */
  38982. get zoomStopsAnimation(): boolean;
  38983. /**
  38984. * Sets the transition time when framing the mesh, in milliseconds
  38985. */
  38986. set framingTime(time: number);
  38987. /**
  38988. * Gets the transition time when framing the mesh, in milliseconds
  38989. */
  38990. get framingTime(): number;
  38991. /**
  38992. * Define if the behavior should automatically change the configured
  38993. * camera limits and sensibilities.
  38994. */
  38995. autoCorrectCameraLimitsAndSensibility: boolean;
  38996. private _onPrePointerObservableObserver;
  38997. private _onAfterCheckInputsObserver;
  38998. private _onMeshTargetChangedObserver;
  38999. private _attachedCamera;
  39000. private _isPointerDown;
  39001. private _lastInteractionTime;
  39002. /**
  39003. * Initializes the behavior.
  39004. */
  39005. init(): void;
  39006. /**
  39007. * Attaches the behavior to its arc rotate camera.
  39008. * @param camera Defines the camera to attach the behavior to
  39009. */
  39010. attach(camera: ArcRotateCamera): void;
  39011. /**
  39012. * Detaches the behavior from its current arc rotate camera.
  39013. */
  39014. detach(): void;
  39015. private _animatables;
  39016. private _betaIsAnimating;
  39017. private _betaTransition;
  39018. private _radiusTransition;
  39019. private _vectorTransition;
  39020. /**
  39021. * Targets the given mesh and updates zoom level accordingly.
  39022. * @param mesh The mesh to target.
  39023. * @param radius Optional. If a cached radius position already exists, overrides default.
  39024. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39025. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39026. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39027. */
  39028. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39029. /**
  39030. * Targets the given mesh with its children and updates zoom level accordingly.
  39031. * @param mesh The mesh to target.
  39032. * @param radius Optional. If a cached radius position already exists, overrides default.
  39033. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39034. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39035. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39036. */
  39037. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39038. /**
  39039. * Targets the given meshes with their children and updates zoom level accordingly.
  39040. * @param meshes The mesh to target.
  39041. * @param radius Optional. If a cached radius position already exists, overrides default.
  39042. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39045. */
  39046. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39047. /**
  39048. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39049. * @param minimumWorld Determines the smaller position of the bounding box extend
  39050. * @param maximumWorld Determines the bigger position of the bounding box extend
  39051. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39052. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39053. */
  39054. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39055. /**
  39056. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39057. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39058. * frustum width.
  39059. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39060. * to fully enclose the mesh in the viewing frustum.
  39061. */
  39062. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39063. /**
  39064. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39065. * is automatically returned to its default position (expected to be above ground plane).
  39066. */
  39067. private _maintainCameraAboveGround;
  39068. /**
  39069. * Returns the frustum slope based on the canvas ratio and camera FOV
  39070. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39071. */
  39072. private _getFrustumSlope;
  39073. /**
  39074. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39075. */
  39076. private _clearAnimationLocks;
  39077. /**
  39078. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39079. */
  39080. private _applyUserInteraction;
  39081. /**
  39082. * Stops and removes all animations that have been applied to the camera
  39083. */
  39084. stopAllAnimations(): void;
  39085. /**
  39086. * Gets a value indicating if the user is moving the camera
  39087. */
  39088. get isUserIsMoving(): boolean;
  39089. /**
  39090. * The camera can move all the way towards the mesh.
  39091. */
  39092. static IgnoreBoundsSizeMode: number;
  39093. /**
  39094. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39095. */
  39096. static FitFrustumSidesMode: number;
  39097. }
  39098. }
  39099. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39100. import { Nullable } from "babylonjs/types";
  39101. import { Camera } from "babylonjs/Cameras/camera";
  39102. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39103. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39104. /**
  39105. * Base class for Camera Pointer Inputs.
  39106. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39107. * for example usage.
  39108. */
  39109. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39110. /**
  39111. * Defines the camera the input is attached to.
  39112. */
  39113. abstract camera: Camera;
  39114. /**
  39115. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39116. */
  39117. protected _altKey: boolean;
  39118. protected _ctrlKey: boolean;
  39119. protected _metaKey: boolean;
  39120. protected _shiftKey: boolean;
  39121. /**
  39122. * Which mouse buttons were pressed at time of last mouse event.
  39123. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39124. */
  39125. protected _buttonsPressed: number;
  39126. /**
  39127. * Defines the buttons associated with the input to handle camera move.
  39128. */
  39129. buttons: number[];
  39130. /**
  39131. * Attach the input controls to a specific dom element to get the input from.
  39132. * @param element Defines the element the controls should be listened from
  39133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39134. */
  39135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39136. /**
  39137. * Detach the current controls from the specified dom element.
  39138. * @param element Defines the element to stop listening the inputs from
  39139. */
  39140. detachControl(element: Nullable<HTMLElement>): void;
  39141. /**
  39142. * Gets the class name of the current input.
  39143. * @returns the class name
  39144. */
  39145. getClassName(): string;
  39146. /**
  39147. * Get the friendly name associated with the input class.
  39148. * @returns the input friendly name
  39149. */
  39150. getSimpleName(): string;
  39151. /**
  39152. * Called on pointer POINTERDOUBLETAP event.
  39153. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39154. */
  39155. protected onDoubleTap(type: string): void;
  39156. /**
  39157. * Called on pointer POINTERMOVE event if only a single touch is active.
  39158. * Override this method to provide functionality.
  39159. */
  39160. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39161. /**
  39162. * Called on pointer POINTERMOVE event if multiple touches are active.
  39163. * Override this method to provide functionality.
  39164. */
  39165. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39166. /**
  39167. * Called on JS contextmenu event.
  39168. * Override this method to provide functionality.
  39169. */
  39170. protected onContextMenu(evt: PointerEvent): void;
  39171. /**
  39172. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39173. * press.
  39174. * Override this method to provide functionality.
  39175. */
  39176. protected onButtonDown(evt: PointerEvent): void;
  39177. /**
  39178. * Called each time a new POINTERUP event occurs. Ie, for each button
  39179. * release.
  39180. * Override this method to provide functionality.
  39181. */
  39182. protected onButtonUp(evt: PointerEvent): void;
  39183. /**
  39184. * Called when window becomes inactive.
  39185. * Override this method to provide functionality.
  39186. */
  39187. protected onLostFocus(): void;
  39188. private _pointerInput;
  39189. private _observer;
  39190. private _onLostFocus;
  39191. private pointA;
  39192. private pointB;
  39193. }
  39194. }
  39195. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39196. import { Nullable } from "babylonjs/types";
  39197. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39198. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39199. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39200. /**
  39201. * Manage the pointers inputs to control an arc rotate camera.
  39202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39203. */
  39204. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39205. /**
  39206. * Defines the camera the input is attached to.
  39207. */
  39208. camera: ArcRotateCamera;
  39209. /**
  39210. * Gets the class name of the current input.
  39211. * @returns the class name
  39212. */
  39213. getClassName(): string;
  39214. /**
  39215. * Defines the buttons associated with the input to handle camera move.
  39216. */
  39217. buttons: number[];
  39218. /**
  39219. * Defines the pointer angular sensibility along the X axis or how fast is
  39220. * the camera rotating.
  39221. */
  39222. angularSensibilityX: number;
  39223. /**
  39224. * Defines the pointer angular sensibility along the Y axis or how fast is
  39225. * the camera rotating.
  39226. */
  39227. angularSensibilityY: number;
  39228. /**
  39229. * Defines the pointer pinch precision or how fast is the camera zooming.
  39230. */
  39231. pinchPrecision: number;
  39232. /**
  39233. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39234. * from 0.
  39235. * It defines the percentage of current camera.radius to use as delta when
  39236. * pinch zoom is used.
  39237. */
  39238. pinchDeltaPercentage: number;
  39239. /**
  39240. * Defines the pointer panning sensibility or how fast is the camera moving.
  39241. */
  39242. panningSensibility: number;
  39243. /**
  39244. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39245. */
  39246. multiTouchPanning: boolean;
  39247. /**
  39248. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39249. * zoom (pinch) through multitouch.
  39250. */
  39251. multiTouchPanAndZoom: boolean;
  39252. /**
  39253. * Revers pinch action direction.
  39254. */
  39255. pinchInwards: boolean;
  39256. private _isPanClick;
  39257. private _twoFingerActivityCount;
  39258. private _isPinching;
  39259. /**
  39260. * Called on pointer POINTERMOVE event if only a single touch is active.
  39261. */
  39262. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39263. /**
  39264. * Called on pointer POINTERDOUBLETAP event.
  39265. */
  39266. protected onDoubleTap(type: string): void;
  39267. /**
  39268. * Called on pointer POINTERMOVE event if multiple touches are active.
  39269. */
  39270. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39271. /**
  39272. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39273. * press.
  39274. */
  39275. protected onButtonDown(evt: PointerEvent): void;
  39276. /**
  39277. * Called each time a new POINTERUP event occurs. Ie, for each button
  39278. * release.
  39279. */
  39280. protected onButtonUp(evt: PointerEvent): void;
  39281. /**
  39282. * Called when window becomes inactive.
  39283. */
  39284. protected onLostFocus(): void;
  39285. }
  39286. }
  39287. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39288. import { Nullable } from "babylonjs/types";
  39289. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39290. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39291. /**
  39292. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39294. */
  39295. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39296. /**
  39297. * Defines the camera the input is attached to.
  39298. */
  39299. camera: ArcRotateCamera;
  39300. /**
  39301. * Defines the list of key codes associated with the up action (increase alpha)
  39302. */
  39303. keysUp: number[];
  39304. /**
  39305. * Defines the list of key codes associated with the down action (decrease alpha)
  39306. */
  39307. keysDown: number[];
  39308. /**
  39309. * Defines the list of key codes associated with the left action (increase beta)
  39310. */
  39311. keysLeft: number[];
  39312. /**
  39313. * Defines the list of key codes associated with the right action (decrease beta)
  39314. */
  39315. keysRight: number[];
  39316. /**
  39317. * Defines the list of key codes associated with the reset action.
  39318. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39319. */
  39320. keysReset: number[];
  39321. /**
  39322. * Defines the panning sensibility of the inputs.
  39323. * (How fast is the camera paning)
  39324. */
  39325. panningSensibility: number;
  39326. /**
  39327. * Defines the zooming sensibility of the inputs.
  39328. * (How fast is the camera zooming)
  39329. */
  39330. zoomingSensibility: number;
  39331. /**
  39332. * Defines wether maintaining the alt key down switch the movement mode from
  39333. * orientation to zoom.
  39334. */
  39335. useAltToZoom: boolean;
  39336. /**
  39337. * Rotation speed of the camera
  39338. */
  39339. angularSpeed: number;
  39340. private _keys;
  39341. private _ctrlPressed;
  39342. private _altPressed;
  39343. private _onCanvasBlurObserver;
  39344. private _onKeyboardObserver;
  39345. private _engine;
  39346. private _scene;
  39347. /**
  39348. * Attach the input controls to a specific dom element to get the input from.
  39349. * @param element Defines the element the controls should be listened from
  39350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39351. */
  39352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39353. /**
  39354. * Detach the current controls from the specified dom element.
  39355. * @param element Defines the element to stop listening the inputs from
  39356. */
  39357. detachControl(element: Nullable<HTMLElement>): void;
  39358. /**
  39359. * Update the current camera state depending on the inputs that have been used this frame.
  39360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39361. */
  39362. checkInputs(): void;
  39363. /**
  39364. * Gets the class name of the current intput.
  39365. * @returns the class name
  39366. */
  39367. getClassName(): string;
  39368. /**
  39369. * Get the friendly name associated with the input class.
  39370. * @returns the input friendly name
  39371. */
  39372. getSimpleName(): string;
  39373. }
  39374. }
  39375. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39376. import { Nullable } from "babylonjs/types";
  39377. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39378. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39379. /**
  39380. * Manage the mouse wheel inputs to control an arc rotate camera.
  39381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39382. */
  39383. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39384. /**
  39385. * Defines the camera the input is attached to.
  39386. */
  39387. camera: ArcRotateCamera;
  39388. /**
  39389. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39390. */
  39391. wheelPrecision: number;
  39392. /**
  39393. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39394. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39395. */
  39396. wheelDeltaPercentage: number;
  39397. private _wheel;
  39398. private _observer;
  39399. private computeDeltaFromMouseWheelLegacyEvent;
  39400. /**
  39401. * Attach the input controls to a specific dom element to get the input from.
  39402. * @param element Defines the element the controls should be listened from
  39403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39404. */
  39405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39406. /**
  39407. * Detach the current controls from the specified dom element.
  39408. * @param element Defines the element to stop listening the inputs from
  39409. */
  39410. detachControl(element: Nullable<HTMLElement>): void;
  39411. /**
  39412. * Gets the class name of the current intput.
  39413. * @returns the class name
  39414. */
  39415. getClassName(): string;
  39416. /**
  39417. * Get the friendly name associated with the input class.
  39418. * @returns the input friendly name
  39419. */
  39420. getSimpleName(): string;
  39421. }
  39422. }
  39423. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39424. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39425. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39426. /**
  39427. * Default Inputs manager for the ArcRotateCamera.
  39428. * It groups all the default supported inputs for ease of use.
  39429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39430. */
  39431. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39432. /**
  39433. * Instantiates a new ArcRotateCameraInputsManager.
  39434. * @param camera Defines the camera the inputs belong to
  39435. */
  39436. constructor(camera: ArcRotateCamera);
  39437. /**
  39438. * Add mouse wheel input support to the input manager.
  39439. * @returns the current input manager
  39440. */
  39441. addMouseWheel(): ArcRotateCameraInputsManager;
  39442. /**
  39443. * Add pointers input support to the input manager.
  39444. * @returns the current input manager
  39445. */
  39446. addPointers(): ArcRotateCameraInputsManager;
  39447. /**
  39448. * Add keyboard input support to the input manager.
  39449. * @returns the current input manager
  39450. */
  39451. addKeyboard(): ArcRotateCameraInputsManager;
  39452. }
  39453. }
  39454. declare module "babylonjs/Cameras/arcRotateCamera" {
  39455. import { Observable } from "babylonjs/Misc/observable";
  39456. import { Nullable } from "babylonjs/types";
  39457. import { Scene } from "babylonjs/scene";
  39458. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39460. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39461. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39462. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39463. import { Camera } from "babylonjs/Cameras/camera";
  39464. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39465. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39466. import { Collider } from "babylonjs/Collisions/collider";
  39467. /**
  39468. * This represents an orbital type of camera.
  39469. *
  39470. * 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.
  39471. * 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.
  39472. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39473. */
  39474. export class ArcRotateCamera extends TargetCamera {
  39475. /**
  39476. * Defines the rotation angle of the camera along the longitudinal axis.
  39477. */
  39478. alpha: number;
  39479. /**
  39480. * Defines the rotation angle of the camera along the latitudinal axis.
  39481. */
  39482. beta: number;
  39483. /**
  39484. * Defines the radius of the camera from it s target point.
  39485. */
  39486. radius: number;
  39487. protected _target: Vector3;
  39488. protected _targetHost: Nullable<AbstractMesh>;
  39489. /**
  39490. * Defines the target point of the camera.
  39491. * The camera looks towards it form the radius distance.
  39492. */
  39493. get target(): Vector3;
  39494. set target(value: Vector3);
  39495. /**
  39496. * Define the current local position of the camera in the scene
  39497. */
  39498. get position(): Vector3;
  39499. set position(newPosition: Vector3);
  39500. protected _upVector: Vector3;
  39501. protected _upToYMatrix: Matrix;
  39502. protected _YToUpMatrix: Matrix;
  39503. /**
  39504. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39505. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39506. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39507. */
  39508. set upVector(vec: Vector3);
  39509. get upVector(): Vector3;
  39510. /**
  39511. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39512. */
  39513. setMatUp(): void;
  39514. /**
  39515. * Current inertia value on the longitudinal axis.
  39516. * The bigger this number the longer it will take for the camera to stop.
  39517. */
  39518. inertialAlphaOffset: number;
  39519. /**
  39520. * Current inertia value on the latitudinal axis.
  39521. * The bigger this number the longer it will take for the camera to stop.
  39522. */
  39523. inertialBetaOffset: number;
  39524. /**
  39525. * Current inertia value on the radius axis.
  39526. * The bigger this number the longer it will take for the camera to stop.
  39527. */
  39528. inertialRadiusOffset: number;
  39529. /**
  39530. * Minimum allowed angle on the longitudinal axis.
  39531. * This can help limiting how the Camera is able to move in the scene.
  39532. */
  39533. lowerAlphaLimit: Nullable<number>;
  39534. /**
  39535. * Maximum allowed angle on the longitudinal axis.
  39536. * This can help limiting how the Camera is able to move in the scene.
  39537. */
  39538. upperAlphaLimit: Nullable<number>;
  39539. /**
  39540. * Minimum allowed angle on the latitudinal axis.
  39541. * This can help limiting how the Camera is able to move in the scene.
  39542. */
  39543. lowerBetaLimit: number;
  39544. /**
  39545. * Maximum allowed angle on the latitudinal axis.
  39546. * This can help limiting how the Camera is able to move in the scene.
  39547. */
  39548. upperBetaLimit: number;
  39549. /**
  39550. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39551. * This can help limiting how the Camera is able to move in the scene.
  39552. */
  39553. lowerRadiusLimit: Nullable<number>;
  39554. /**
  39555. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39556. * This can help limiting how the Camera is able to move in the scene.
  39557. */
  39558. upperRadiusLimit: Nullable<number>;
  39559. /**
  39560. * Defines the current inertia value used during panning of the camera along the X axis.
  39561. */
  39562. inertialPanningX: number;
  39563. /**
  39564. * Defines the current inertia value used during panning of the camera along the Y axis.
  39565. */
  39566. inertialPanningY: number;
  39567. /**
  39568. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39569. * Basically if your fingers moves away from more than this distance you will be considered
  39570. * in pinch mode.
  39571. */
  39572. pinchToPanMaxDistance: number;
  39573. /**
  39574. * Defines the maximum distance the camera can pan.
  39575. * This could help keeping the cammera always in your scene.
  39576. */
  39577. panningDistanceLimit: Nullable<number>;
  39578. /**
  39579. * Defines the target of the camera before paning.
  39580. */
  39581. panningOriginTarget: Vector3;
  39582. /**
  39583. * Defines the value of the inertia used during panning.
  39584. * 0 would mean stop inertia and one would mean no decelleration at all.
  39585. */
  39586. panningInertia: number;
  39587. /**
  39588. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39589. */
  39590. get angularSensibilityX(): number;
  39591. set angularSensibilityX(value: number);
  39592. /**
  39593. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39594. */
  39595. get angularSensibilityY(): number;
  39596. set angularSensibilityY(value: number);
  39597. /**
  39598. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39599. */
  39600. get pinchPrecision(): number;
  39601. set pinchPrecision(value: number);
  39602. /**
  39603. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39604. * It will be used instead of pinchDeltaPrecision if different from 0.
  39605. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39606. */
  39607. get pinchDeltaPercentage(): number;
  39608. set pinchDeltaPercentage(value: number);
  39609. /**
  39610. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39611. */
  39612. get panningSensibility(): number;
  39613. set panningSensibility(value: number);
  39614. /**
  39615. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39616. */
  39617. get keysUp(): number[];
  39618. set keysUp(value: number[]);
  39619. /**
  39620. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39621. */
  39622. get keysDown(): number[];
  39623. set keysDown(value: number[]);
  39624. /**
  39625. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39626. */
  39627. get keysLeft(): number[];
  39628. set keysLeft(value: number[]);
  39629. /**
  39630. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39631. */
  39632. get keysRight(): number[];
  39633. set keysRight(value: number[]);
  39634. /**
  39635. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39636. */
  39637. get wheelPrecision(): number;
  39638. set wheelPrecision(value: number);
  39639. /**
  39640. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39641. * It will be used instead of pinchDeltaPrecision if different from 0.
  39642. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39643. */
  39644. get wheelDeltaPercentage(): number;
  39645. set wheelDeltaPercentage(value: number);
  39646. /**
  39647. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39648. */
  39649. zoomOnFactor: number;
  39650. /**
  39651. * Defines a screen offset for the camera position.
  39652. */
  39653. targetScreenOffset: Vector2;
  39654. /**
  39655. * Allows the camera to be completely reversed.
  39656. * If false the camera can not arrive upside down.
  39657. */
  39658. allowUpsideDown: boolean;
  39659. /**
  39660. * Define if double tap/click is used to restore the previously saved state of the camera.
  39661. */
  39662. useInputToRestoreState: boolean;
  39663. /** @hidden */
  39664. _viewMatrix: Matrix;
  39665. /** @hidden */
  39666. _useCtrlForPanning: boolean;
  39667. /** @hidden */
  39668. _panningMouseButton: number;
  39669. /**
  39670. * Defines the input associated to the camera.
  39671. */
  39672. inputs: ArcRotateCameraInputsManager;
  39673. /** @hidden */
  39674. _reset: () => void;
  39675. /**
  39676. * Defines the allowed panning axis.
  39677. */
  39678. panningAxis: Vector3;
  39679. protected _localDirection: Vector3;
  39680. protected _transformedDirection: Vector3;
  39681. private _bouncingBehavior;
  39682. /**
  39683. * Gets the bouncing behavior of the camera if it has been enabled.
  39684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39685. */
  39686. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39687. /**
  39688. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39690. */
  39691. get useBouncingBehavior(): boolean;
  39692. set useBouncingBehavior(value: boolean);
  39693. private _framingBehavior;
  39694. /**
  39695. * Gets the framing behavior of the camera if it has been enabled.
  39696. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39697. */
  39698. get framingBehavior(): Nullable<FramingBehavior>;
  39699. /**
  39700. * Defines if the framing behavior of the camera is enabled on the camera.
  39701. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39702. */
  39703. get useFramingBehavior(): boolean;
  39704. set useFramingBehavior(value: boolean);
  39705. private _autoRotationBehavior;
  39706. /**
  39707. * Gets the auto rotation behavior of the camera if it has been enabled.
  39708. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39709. */
  39710. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39711. /**
  39712. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39713. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39714. */
  39715. get useAutoRotationBehavior(): boolean;
  39716. set useAutoRotationBehavior(value: boolean);
  39717. /**
  39718. * Observable triggered when the mesh target has been changed on the camera.
  39719. */
  39720. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39721. /**
  39722. * Event raised when the camera is colliding with a mesh.
  39723. */
  39724. onCollide: (collidedMesh: AbstractMesh) => void;
  39725. /**
  39726. * Defines whether the camera should check collision with the objects oh the scene.
  39727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39728. */
  39729. checkCollisions: boolean;
  39730. /**
  39731. * Defines the collision radius of the camera.
  39732. * This simulates a sphere around the camera.
  39733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39734. */
  39735. collisionRadius: Vector3;
  39736. protected _collider: Collider;
  39737. protected _previousPosition: Vector3;
  39738. protected _collisionVelocity: Vector3;
  39739. protected _newPosition: Vector3;
  39740. protected _previousAlpha: number;
  39741. protected _previousBeta: number;
  39742. protected _previousRadius: number;
  39743. protected _collisionTriggered: boolean;
  39744. protected _targetBoundingCenter: Nullable<Vector3>;
  39745. private _computationVector;
  39746. /**
  39747. * Instantiates a new ArcRotateCamera in a given scene
  39748. * @param name Defines the name of the camera
  39749. * @param alpha Defines the camera rotation along the logitudinal axis
  39750. * @param beta Defines the camera rotation along the latitudinal axis
  39751. * @param radius Defines the camera distance from its target
  39752. * @param target Defines the camera target
  39753. * @param scene Defines the scene the camera belongs to
  39754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39755. */
  39756. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39757. /** @hidden */
  39758. _initCache(): void;
  39759. /** @hidden */
  39760. _updateCache(ignoreParentClass?: boolean): void;
  39761. protected _getTargetPosition(): Vector3;
  39762. private _storedAlpha;
  39763. private _storedBeta;
  39764. private _storedRadius;
  39765. private _storedTarget;
  39766. private _storedTargetScreenOffset;
  39767. /**
  39768. * Stores the current state of the camera (alpha, beta, radius and target)
  39769. * @returns the camera itself
  39770. */
  39771. storeState(): Camera;
  39772. /**
  39773. * @hidden
  39774. * Restored camera state. You must call storeState() first
  39775. */
  39776. _restoreStateValues(): boolean;
  39777. /** @hidden */
  39778. _isSynchronizedViewMatrix(): boolean;
  39779. /**
  39780. * Attached controls to the current camera.
  39781. * @param element Defines the element the controls should be listened from
  39782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39783. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39784. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39785. */
  39786. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39787. /**
  39788. * Detach the current controls from the camera.
  39789. * The camera will stop reacting to inputs.
  39790. * @param element Defines the element to stop listening the inputs from
  39791. */
  39792. detachControl(element: HTMLElement): void;
  39793. /** @hidden */
  39794. _checkInputs(): void;
  39795. protected _checkLimits(): void;
  39796. /**
  39797. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39798. */
  39799. rebuildAnglesAndRadius(): void;
  39800. /**
  39801. * Use a position to define the current camera related information like alpha, beta and radius
  39802. * @param position Defines the position to set the camera at
  39803. */
  39804. setPosition(position: Vector3): void;
  39805. /**
  39806. * Defines the target the camera should look at.
  39807. * This will automatically adapt alpha beta and radius to fit within the new target.
  39808. * @param target Defines the new target as a Vector or a mesh
  39809. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39810. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39811. */
  39812. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39813. /** @hidden */
  39814. _getViewMatrix(): Matrix;
  39815. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39816. /**
  39817. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39818. * @param meshes Defines the mesh to zoom on
  39819. * @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)
  39820. */
  39821. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39822. /**
  39823. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39824. * The target will be changed but the radius
  39825. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39826. * @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)
  39827. */
  39828. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39829. min: Vector3;
  39830. max: Vector3;
  39831. distance: number;
  39832. }, doNotUpdateMaxZ?: boolean): void;
  39833. /**
  39834. * @override
  39835. * Override Camera.createRigCamera
  39836. */
  39837. createRigCamera(name: string, cameraIndex: number): Camera;
  39838. /**
  39839. * @hidden
  39840. * @override
  39841. * Override Camera._updateRigCameras
  39842. */
  39843. _updateRigCameras(): void;
  39844. /**
  39845. * Destroy the camera and release the current resources hold by it.
  39846. */
  39847. dispose(): void;
  39848. /**
  39849. * Gets the current object class name.
  39850. * @return the class name
  39851. */
  39852. getClassName(): string;
  39853. }
  39854. }
  39855. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39856. import { Behavior } from "babylonjs/Behaviors/behavior";
  39857. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39858. /**
  39859. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39860. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39861. */
  39862. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39863. /**
  39864. * Gets the name of the behavior.
  39865. */
  39866. get name(): string;
  39867. private _zoomStopsAnimation;
  39868. private _idleRotationSpeed;
  39869. private _idleRotationWaitTime;
  39870. private _idleRotationSpinupTime;
  39871. /**
  39872. * Sets the flag that indicates if user zooming should stop animation.
  39873. */
  39874. set zoomStopsAnimation(flag: boolean);
  39875. /**
  39876. * Gets the flag that indicates if user zooming should stop animation.
  39877. */
  39878. get zoomStopsAnimation(): boolean;
  39879. /**
  39880. * Sets the default speed at which the camera rotates around the model.
  39881. */
  39882. set idleRotationSpeed(speed: number);
  39883. /**
  39884. * Gets the default speed at which the camera rotates around the model.
  39885. */
  39886. get idleRotationSpeed(): number;
  39887. /**
  39888. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39889. */
  39890. set idleRotationWaitTime(time: number);
  39891. /**
  39892. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39893. */
  39894. get idleRotationWaitTime(): number;
  39895. /**
  39896. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39897. */
  39898. set idleRotationSpinupTime(time: number);
  39899. /**
  39900. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39901. */
  39902. get idleRotationSpinupTime(): number;
  39903. /**
  39904. * Gets a value indicating if the camera is currently rotating because of this behavior
  39905. */
  39906. get rotationInProgress(): boolean;
  39907. private _onPrePointerObservableObserver;
  39908. private _onAfterCheckInputsObserver;
  39909. private _attachedCamera;
  39910. private _isPointerDown;
  39911. private _lastFrameTime;
  39912. private _lastInteractionTime;
  39913. private _cameraRotationSpeed;
  39914. /**
  39915. * Initializes the behavior.
  39916. */
  39917. init(): void;
  39918. /**
  39919. * Attaches the behavior to its arc rotate camera.
  39920. * @param camera Defines the camera to attach the behavior to
  39921. */
  39922. attach(camera: ArcRotateCamera): void;
  39923. /**
  39924. * Detaches the behavior from its current arc rotate camera.
  39925. */
  39926. detach(): void;
  39927. /**
  39928. * Returns true if user is scrolling.
  39929. * @return true if user is scrolling.
  39930. */
  39931. private _userIsZooming;
  39932. private _lastFrameRadius;
  39933. private _shouldAnimationStopForInteraction;
  39934. /**
  39935. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39936. */
  39937. private _applyUserInteraction;
  39938. private _userIsMoving;
  39939. }
  39940. }
  39941. declare module "babylonjs/Behaviors/Cameras/index" {
  39942. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39943. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39944. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39945. }
  39946. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39947. import { Mesh } from "babylonjs/Meshes/mesh";
  39948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39949. import { Behavior } from "babylonjs/Behaviors/behavior";
  39950. /**
  39951. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39952. */
  39953. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39954. private ui;
  39955. /**
  39956. * The name of the behavior
  39957. */
  39958. name: string;
  39959. /**
  39960. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39961. */
  39962. distanceAwayFromFace: number;
  39963. /**
  39964. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39965. */
  39966. distanceAwayFromBottomOfFace: number;
  39967. private _faceVectors;
  39968. private _target;
  39969. private _scene;
  39970. private _onRenderObserver;
  39971. private _tmpMatrix;
  39972. private _tmpVector;
  39973. /**
  39974. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39975. * @param ui The transform node that should be attched to the mesh
  39976. */
  39977. constructor(ui: TransformNode);
  39978. /**
  39979. * Initializes the behavior
  39980. */
  39981. init(): void;
  39982. private _closestFace;
  39983. private _zeroVector;
  39984. private _lookAtTmpMatrix;
  39985. private _lookAtToRef;
  39986. /**
  39987. * Attaches the AttachToBoxBehavior to the passed in mesh
  39988. * @param target The mesh that the specified node will be attached to
  39989. */
  39990. attach(target: Mesh): void;
  39991. /**
  39992. * Detaches the behavior from the mesh
  39993. */
  39994. detach(): void;
  39995. }
  39996. }
  39997. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39998. import { Behavior } from "babylonjs/Behaviors/behavior";
  39999. import { Mesh } from "babylonjs/Meshes/mesh";
  40000. /**
  40001. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40002. */
  40003. export class FadeInOutBehavior implements Behavior<Mesh> {
  40004. /**
  40005. * Time in milliseconds to delay before fading in (Default: 0)
  40006. */
  40007. delay: number;
  40008. /**
  40009. * Time in milliseconds for the mesh to fade in (Default: 300)
  40010. */
  40011. fadeInTime: number;
  40012. private _millisecondsPerFrame;
  40013. private _hovered;
  40014. private _hoverValue;
  40015. private _ownerNode;
  40016. /**
  40017. * Instatiates the FadeInOutBehavior
  40018. */
  40019. constructor();
  40020. /**
  40021. * The name of the behavior
  40022. */
  40023. get name(): string;
  40024. /**
  40025. * Initializes the behavior
  40026. */
  40027. init(): void;
  40028. /**
  40029. * Attaches the fade behavior on the passed in mesh
  40030. * @param ownerNode The mesh that will be faded in/out once attached
  40031. */
  40032. attach(ownerNode: Mesh): void;
  40033. /**
  40034. * Detaches the behavior from the mesh
  40035. */
  40036. detach(): void;
  40037. /**
  40038. * Triggers the mesh to begin fading in or out
  40039. * @param value if the object should fade in or out (true to fade in)
  40040. */
  40041. fadeIn(value: boolean): void;
  40042. private _update;
  40043. private _setAllVisibility;
  40044. }
  40045. }
  40046. declare module "babylonjs/Misc/pivotTools" {
  40047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40048. /**
  40049. * Class containing a set of static utilities functions for managing Pivots
  40050. * @hidden
  40051. */
  40052. export class PivotTools {
  40053. private static _PivotCached;
  40054. private static _OldPivotPoint;
  40055. private static _PivotTranslation;
  40056. private static _PivotTmpVector;
  40057. /** @hidden */
  40058. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40059. /** @hidden */
  40060. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40061. }
  40062. }
  40063. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40064. import { Scene } from "babylonjs/scene";
  40065. import { Vector4 } from "babylonjs/Maths/math.vector";
  40066. import { Mesh } from "babylonjs/Meshes/mesh";
  40067. import { Nullable } from "babylonjs/types";
  40068. import { Plane } from "babylonjs/Maths/math.plane";
  40069. /**
  40070. * Class containing static functions to help procedurally build meshes
  40071. */
  40072. export class PlaneBuilder {
  40073. /**
  40074. * Creates a plane mesh
  40075. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40076. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40077. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40081. * @param name defines the name of the mesh
  40082. * @param options defines the options used to create the mesh
  40083. * @param scene defines the hosting scene
  40084. * @returns the plane mesh
  40085. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40086. */
  40087. static CreatePlane(name: string, options: {
  40088. size?: number;
  40089. width?: number;
  40090. height?: number;
  40091. sideOrientation?: number;
  40092. frontUVs?: Vector4;
  40093. backUVs?: Vector4;
  40094. updatable?: boolean;
  40095. sourcePlane?: Plane;
  40096. }, scene?: Nullable<Scene>): Mesh;
  40097. }
  40098. }
  40099. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40100. import { Behavior } from "babylonjs/Behaviors/behavior";
  40101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40102. import { Observable } from "babylonjs/Misc/observable";
  40103. import { Vector3 } from "babylonjs/Maths/math.vector";
  40104. import { Ray } from "babylonjs/Culling/ray";
  40105. import "babylonjs/Meshes/Builders/planeBuilder";
  40106. /**
  40107. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40108. */
  40109. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40110. private static _AnyMouseID;
  40111. /**
  40112. * Abstract mesh the behavior is set on
  40113. */
  40114. attachedNode: AbstractMesh;
  40115. private _dragPlane;
  40116. private _scene;
  40117. private _pointerObserver;
  40118. private _beforeRenderObserver;
  40119. private static _planeScene;
  40120. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40121. /**
  40122. * 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)
  40123. */
  40124. maxDragAngle: number;
  40125. /**
  40126. * @hidden
  40127. */
  40128. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40129. /**
  40130. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40131. */
  40132. currentDraggingPointerID: number;
  40133. /**
  40134. * The last position where the pointer hit the drag plane in world space
  40135. */
  40136. lastDragPosition: Vector3;
  40137. /**
  40138. * If the behavior is currently in a dragging state
  40139. */
  40140. dragging: boolean;
  40141. /**
  40142. * 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)
  40143. */
  40144. dragDeltaRatio: number;
  40145. /**
  40146. * If the drag plane orientation should be updated during the dragging (Default: true)
  40147. */
  40148. updateDragPlane: boolean;
  40149. private _debugMode;
  40150. private _moving;
  40151. /**
  40152. * Fires each time the attached mesh is dragged with the pointer
  40153. * * delta between last drag position and current drag position in world space
  40154. * * dragDistance along the drag axis
  40155. * * dragPlaneNormal normal of the current drag plane used during the drag
  40156. * * dragPlanePoint in world space where the drag intersects the drag plane
  40157. */
  40158. onDragObservable: Observable<{
  40159. delta: Vector3;
  40160. dragPlanePoint: Vector3;
  40161. dragPlaneNormal: Vector3;
  40162. dragDistance: number;
  40163. pointerId: number;
  40164. }>;
  40165. /**
  40166. * Fires each time a drag begins (eg. mouse down on mesh)
  40167. */
  40168. onDragStartObservable: Observable<{
  40169. dragPlanePoint: Vector3;
  40170. pointerId: number;
  40171. }>;
  40172. /**
  40173. * Fires each time a drag ends (eg. mouse release after drag)
  40174. */
  40175. onDragEndObservable: Observable<{
  40176. dragPlanePoint: Vector3;
  40177. pointerId: number;
  40178. }>;
  40179. /**
  40180. * If the attached mesh should be moved when dragged
  40181. */
  40182. moveAttached: boolean;
  40183. /**
  40184. * If the drag behavior will react to drag events (Default: true)
  40185. */
  40186. enabled: boolean;
  40187. /**
  40188. * If pointer events should start and release the drag (Default: true)
  40189. */
  40190. startAndReleaseDragOnPointerEvents: boolean;
  40191. /**
  40192. * If camera controls should be detached during the drag
  40193. */
  40194. detachCameraControls: boolean;
  40195. /**
  40196. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40197. */
  40198. useObjectOrientationForDragging: boolean;
  40199. private _options;
  40200. /**
  40201. * Gets the options used by the behavior
  40202. */
  40203. get options(): {
  40204. dragAxis?: Vector3;
  40205. dragPlaneNormal?: Vector3;
  40206. };
  40207. /**
  40208. * Sets the options used by the behavior
  40209. */
  40210. set options(options: {
  40211. dragAxis?: Vector3;
  40212. dragPlaneNormal?: Vector3;
  40213. });
  40214. /**
  40215. * Creates a pointer drag behavior that can be attached to a mesh
  40216. * @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)
  40217. */
  40218. constructor(options?: {
  40219. dragAxis?: Vector3;
  40220. dragPlaneNormal?: Vector3;
  40221. });
  40222. /**
  40223. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40224. */
  40225. validateDrag: (targetPosition: Vector3) => boolean;
  40226. /**
  40227. * The name of the behavior
  40228. */
  40229. get name(): string;
  40230. /**
  40231. * Initializes the behavior
  40232. */
  40233. init(): void;
  40234. private _tmpVector;
  40235. private _alternatePickedPoint;
  40236. private _worldDragAxis;
  40237. private _targetPosition;
  40238. private _attachedElement;
  40239. /**
  40240. * Attaches the drag behavior the passed in mesh
  40241. * @param ownerNode The mesh that will be dragged around once attached
  40242. * @param predicate Predicate to use for pick filtering
  40243. */
  40244. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40245. /**
  40246. * Force relase the drag action by code.
  40247. */
  40248. releaseDrag(): void;
  40249. private _startDragRay;
  40250. private _lastPointerRay;
  40251. /**
  40252. * Simulates the start of a pointer drag event on the behavior
  40253. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40254. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40255. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40256. */
  40257. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40258. private _startDrag;
  40259. private _dragDelta;
  40260. private _moveDrag;
  40261. private _pickWithRayOnDragPlane;
  40262. private _pointA;
  40263. private _pointB;
  40264. private _pointC;
  40265. private _lineA;
  40266. private _lineB;
  40267. private _localAxis;
  40268. private _lookAt;
  40269. private _updateDragPlanePosition;
  40270. /**
  40271. * Detaches the behavior from the mesh
  40272. */
  40273. detach(): void;
  40274. }
  40275. }
  40276. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40277. import { Mesh } from "babylonjs/Meshes/mesh";
  40278. import { Behavior } from "babylonjs/Behaviors/behavior";
  40279. /**
  40280. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40281. */
  40282. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40283. private _dragBehaviorA;
  40284. private _dragBehaviorB;
  40285. private _startDistance;
  40286. private _initialScale;
  40287. private _targetScale;
  40288. private _ownerNode;
  40289. private _sceneRenderObserver;
  40290. /**
  40291. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40292. */
  40293. constructor();
  40294. /**
  40295. * The name of the behavior
  40296. */
  40297. get name(): string;
  40298. /**
  40299. * Initializes the behavior
  40300. */
  40301. init(): void;
  40302. private _getCurrentDistance;
  40303. /**
  40304. * Attaches the scale behavior the passed in mesh
  40305. * @param ownerNode The mesh that will be scaled around once attached
  40306. */
  40307. attach(ownerNode: Mesh): void;
  40308. /**
  40309. * Detaches the behavior from the mesh
  40310. */
  40311. detach(): void;
  40312. }
  40313. }
  40314. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40315. import { Behavior } from "babylonjs/Behaviors/behavior";
  40316. import { Mesh } from "babylonjs/Meshes/mesh";
  40317. import { Observable } from "babylonjs/Misc/observable";
  40318. /**
  40319. * 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
  40320. */
  40321. export class SixDofDragBehavior implements Behavior<Mesh> {
  40322. private static _virtualScene;
  40323. private _ownerNode;
  40324. private _sceneRenderObserver;
  40325. private _scene;
  40326. private _targetPosition;
  40327. private _virtualOriginMesh;
  40328. private _virtualDragMesh;
  40329. private _pointerObserver;
  40330. private _moving;
  40331. private _startingOrientation;
  40332. /**
  40333. * 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)
  40334. */
  40335. private zDragFactor;
  40336. /**
  40337. * If the object should rotate to face the drag origin
  40338. */
  40339. rotateDraggedObject: boolean;
  40340. /**
  40341. * If the behavior is currently in a dragging state
  40342. */
  40343. dragging: boolean;
  40344. /**
  40345. * 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)
  40346. */
  40347. dragDeltaRatio: number;
  40348. /**
  40349. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40350. */
  40351. currentDraggingPointerID: number;
  40352. /**
  40353. * If camera controls should be detached during the drag
  40354. */
  40355. detachCameraControls: boolean;
  40356. /**
  40357. * Fires each time a drag starts
  40358. */
  40359. onDragStartObservable: Observable<{}>;
  40360. /**
  40361. * Fires each time a drag ends (eg. mouse release after drag)
  40362. */
  40363. onDragEndObservable: Observable<{}>;
  40364. /**
  40365. * 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
  40366. */
  40367. constructor();
  40368. /**
  40369. * The name of the behavior
  40370. */
  40371. get name(): string;
  40372. /**
  40373. * Initializes the behavior
  40374. */
  40375. init(): void;
  40376. /**
  40377. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40378. */
  40379. private get _pointerCamera();
  40380. /**
  40381. * Attaches the scale behavior the passed in mesh
  40382. * @param ownerNode The mesh that will be scaled around once attached
  40383. */
  40384. attach(ownerNode: Mesh): void;
  40385. /**
  40386. * Detaches the behavior from the mesh
  40387. */
  40388. detach(): void;
  40389. }
  40390. }
  40391. declare module "babylonjs/Behaviors/Meshes/index" {
  40392. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40393. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40394. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40395. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40396. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40397. }
  40398. declare module "babylonjs/Behaviors/index" {
  40399. export * from "babylonjs/Behaviors/behavior";
  40400. export * from "babylonjs/Behaviors/Cameras/index";
  40401. export * from "babylonjs/Behaviors/Meshes/index";
  40402. }
  40403. declare module "babylonjs/Bones/boneIKController" {
  40404. import { Bone } from "babylonjs/Bones/bone";
  40405. import { Vector3 } from "babylonjs/Maths/math.vector";
  40406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40407. import { Nullable } from "babylonjs/types";
  40408. /**
  40409. * Class used to apply inverse kinematics to bones
  40410. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40411. */
  40412. export class BoneIKController {
  40413. private static _tmpVecs;
  40414. private static _tmpQuat;
  40415. private static _tmpMats;
  40416. /**
  40417. * Gets or sets the target mesh
  40418. */
  40419. targetMesh: AbstractMesh;
  40420. /** Gets or sets the mesh used as pole */
  40421. poleTargetMesh: AbstractMesh;
  40422. /**
  40423. * Gets or sets the bone used as pole
  40424. */
  40425. poleTargetBone: Nullable<Bone>;
  40426. /**
  40427. * Gets or sets the target position
  40428. */
  40429. targetPosition: Vector3;
  40430. /**
  40431. * Gets or sets the pole target position
  40432. */
  40433. poleTargetPosition: Vector3;
  40434. /**
  40435. * Gets or sets the pole target local offset
  40436. */
  40437. poleTargetLocalOffset: Vector3;
  40438. /**
  40439. * Gets or sets the pole angle
  40440. */
  40441. poleAngle: number;
  40442. /**
  40443. * Gets or sets the mesh associated with the controller
  40444. */
  40445. mesh: AbstractMesh;
  40446. /**
  40447. * 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)
  40448. */
  40449. slerpAmount: number;
  40450. private _bone1Quat;
  40451. private _bone1Mat;
  40452. private _bone2Ang;
  40453. private _bone1;
  40454. private _bone2;
  40455. private _bone1Length;
  40456. private _bone2Length;
  40457. private _maxAngle;
  40458. private _maxReach;
  40459. private _rightHandedSystem;
  40460. private _bendAxis;
  40461. private _slerping;
  40462. private _adjustRoll;
  40463. /**
  40464. * Gets or sets maximum allowed angle
  40465. */
  40466. get maxAngle(): number;
  40467. set maxAngle(value: number);
  40468. /**
  40469. * Creates a new BoneIKController
  40470. * @param mesh defines the mesh to control
  40471. * @param bone defines the bone to control
  40472. * @param options defines options to set up the controller
  40473. */
  40474. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40475. targetMesh?: AbstractMesh;
  40476. poleTargetMesh?: AbstractMesh;
  40477. poleTargetBone?: Bone;
  40478. poleTargetLocalOffset?: Vector3;
  40479. poleAngle?: number;
  40480. bendAxis?: Vector3;
  40481. maxAngle?: number;
  40482. slerpAmount?: number;
  40483. });
  40484. private _setMaxAngle;
  40485. /**
  40486. * Force the controller to update the bones
  40487. */
  40488. update(): void;
  40489. }
  40490. }
  40491. declare module "babylonjs/Bones/boneLookController" {
  40492. import { Vector3 } from "babylonjs/Maths/math.vector";
  40493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40494. import { Bone } from "babylonjs/Bones/bone";
  40495. import { Space } from "babylonjs/Maths/math.axis";
  40496. /**
  40497. * Class used to make a bone look toward a point in space
  40498. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40499. */
  40500. export class BoneLookController {
  40501. private static _tmpVecs;
  40502. private static _tmpQuat;
  40503. private static _tmpMats;
  40504. /**
  40505. * The target Vector3 that the bone will look at
  40506. */
  40507. target: Vector3;
  40508. /**
  40509. * The mesh that the bone is attached to
  40510. */
  40511. mesh: AbstractMesh;
  40512. /**
  40513. * The bone that will be looking to the target
  40514. */
  40515. bone: Bone;
  40516. /**
  40517. * The up axis of the coordinate system that is used when the bone is rotated
  40518. */
  40519. upAxis: Vector3;
  40520. /**
  40521. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40522. */
  40523. upAxisSpace: Space;
  40524. /**
  40525. * Used to make an adjustment to the yaw of the bone
  40526. */
  40527. adjustYaw: number;
  40528. /**
  40529. * Used to make an adjustment to the pitch of the bone
  40530. */
  40531. adjustPitch: number;
  40532. /**
  40533. * Used to make an adjustment to the roll of the bone
  40534. */
  40535. adjustRoll: number;
  40536. /**
  40537. * 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)
  40538. */
  40539. slerpAmount: number;
  40540. private _minYaw;
  40541. private _maxYaw;
  40542. private _minPitch;
  40543. private _maxPitch;
  40544. private _minYawSin;
  40545. private _minYawCos;
  40546. private _maxYawSin;
  40547. private _maxYawCos;
  40548. private _midYawConstraint;
  40549. private _minPitchTan;
  40550. private _maxPitchTan;
  40551. private _boneQuat;
  40552. private _slerping;
  40553. private _transformYawPitch;
  40554. private _transformYawPitchInv;
  40555. private _firstFrameSkipped;
  40556. private _yawRange;
  40557. private _fowardAxis;
  40558. /**
  40559. * Gets or sets the minimum yaw angle that the bone can look to
  40560. */
  40561. get minYaw(): number;
  40562. set minYaw(value: number);
  40563. /**
  40564. * Gets or sets the maximum yaw angle that the bone can look to
  40565. */
  40566. get maxYaw(): number;
  40567. set maxYaw(value: number);
  40568. /**
  40569. * Gets or sets the minimum pitch angle that the bone can look to
  40570. */
  40571. get minPitch(): number;
  40572. set minPitch(value: number);
  40573. /**
  40574. * Gets or sets the maximum pitch angle that the bone can look to
  40575. */
  40576. get maxPitch(): number;
  40577. set maxPitch(value: number);
  40578. /**
  40579. * Create a BoneLookController
  40580. * @param mesh the mesh that the bone belongs to
  40581. * @param bone the bone that will be looking to the target
  40582. * @param target the target Vector3 to look at
  40583. * @param options optional settings:
  40584. * * maxYaw: the maximum angle the bone will yaw to
  40585. * * minYaw: the minimum angle the bone will yaw to
  40586. * * maxPitch: the maximum angle the bone will pitch to
  40587. * * minPitch: the minimum angle the bone will yaw to
  40588. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40589. * * upAxis: the up axis of the coordinate system
  40590. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40591. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40592. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40593. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40594. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40595. * * adjustRoll: used to make an adjustment to the roll of the bone
  40596. **/
  40597. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40598. maxYaw?: number;
  40599. minYaw?: number;
  40600. maxPitch?: number;
  40601. minPitch?: number;
  40602. slerpAmount?: number;
  40603. upAxis?: Vector3;
  40604. upAxisSpace?: Space;
  40605. yawAxis?: Vector3;
  40606. pitchAxis?: Vector3;
  40607. adjustYaw?: number;
  40608. adjustPitch?: number;
  40609. adjustRoll?: number;
  40610. });
  40611. /**
  40612. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40613. */
  40614. update(): void;
  40615. private _getAngleDiff;
  40616. private _getAngleBetween;
  40617. private _isAngleBetween;
  40618. }
  40619. }
  40620. declare module "babylonjs/Bones/index" {
  40621. export * from "babylonjs/Bones/bone";
  40622. export * from "babylonjs/Bones/boneIKController";
  40623. export * from "babylonjs/Bones/boneLookController";
  40624. export * from "babylonjs/Bones/skeleton";
  40625. }
  40626. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40627. import { Nullable } from "babylonjs/types";
  40628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40629. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40630. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40631. /**
  40632. * Manage the gamepad inputs to control an arc rotate camera.
  40633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40634. */
  40635. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40636. /**
  40637. * Defines the camera the input is attached to.
  40638. */
  40639. camera: ArcRotateCamera;
  40640. /**
  40641. * Defines the gamepad the input is gathering event from.
  40642. */
  40643. gamepad: Nullable<Gamepad>;
  40644. /**
  40645. * Defines the gamepad rotation sensiblity.
  40646. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40647. */
  40648. gamepadRotationSensibility: number;
  40649. /**
  40650. * Defines the gamepad move sensiblity.
  40651. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40652. */
  40653. gamepadMoveSensibility: number;
  40654. private _yAxisScale;
  40655. /**
  40656. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40657. */
  40658. get invertYAxis(): boolean;
  40659. set invertYAxis(value: boolean);
  40660. private _onGamepadConnectedObserver;
  40661. private _onGamepadDisconnectedObserver;
  40662. /**
  40663. * Attach the input controls to a specific dom element to get the input from.
  40664. * @param element Defines the element the controls should be listened from
  40665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40666. */
  40667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40668. /**
  40669. * Detach the current controls from the specified dom element.
  40670. * @param element Defines the element to stop listening the inputs from
  40671. */
  40672. detachControl(element: Nullable<HTMLElement>): void;
  40673. /**
  40674. * Update the current camera state depending on the inputs that have been used this frame.
  40675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40676. */
  40677. checkInputs(): void;
  40678. /**
  40679. * Gets the class name of the current intput.
  40680. * @returns the class name
  40681. */
  40682. getClassName(): string;
  40683. /**
  40684. * Get the friendly name associated with the input class.
  40685. * @returns the input friendly name
  40686. */
  40687. getSimpleName(): string;
  40688. }
  40689. }
  40690. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40691. import { Nullable } from "babylonjs/types";
  40692. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40693. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40694. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40695. interface ArcRotateCameraInputsManager {
  40696. /**
  40697. * Add orientation input support to the input manager.
  40698. * @returns the current input manager
  40699. */
  40700. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40701. }
  40702. }
  40703. /**
  40704. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40706. */
  40707. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40708. /**
  40709. * Defines the camera the input is attached to.
  40710. */
  40711. camera: ArcRotateCamera;
  40712. /**
  40713. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40714. */
  40715. alphaCorrection: number;
  40716. /**
  40717. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40718. */
  40719. gammaCorrection: number;
  40720. private _alpha;
  40721. private _gamma;
  40722. private _dirty;
  40723. private _deviceOrientationHandler;
  40724. /**
  40725. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40726. */
  40727. constructor();
  40728. /**
  40729. * Attach the input controls to a specific dom element to get the input from.
  40730. * @param element Defines the element the controls should be listened from
  40731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40732. */
  40733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40734. /** @hidden */
  40735. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40736. /**
  40737. * Update the current camera state depending on the inputs that have been used this frame.
  40738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40739. */
  40740. checkInputs(): void;
  40741. /**
  40742. * Detach the current controls from the specified dom element.
  40743. * @param element Defines the element to stop listening the inputs from
  40744. */
  40745. detachControl(element: Nullable<HTMLElement>): void;
  40746. /**
  40747. * Gets the class name of the current intput.
  40748. * @returns the class name
  40749. */
  40750. getClassName(): string;
  40751. /**
  40752. * Get the friendly name associated with the input class.
  40753. * @returns the input friendly name
  40754. */
  40755. getSimpleName(): string;
  40756. }
  40757. }
  40758. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40759. import { Nullable } from "babylonjs/types";
  40760. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40761. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40762. /**
  40763. * Listen to mouse events to control the camera.
  40764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40765. */
  40766. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40767. /**
  40768. * Defines the camera the input is attached to.
  40769. */
  40770. camera: FlyCamera;
  40771. /**
  40772. * Defines if touch is enabled. (Default is true.)
  40773. */
  40774. touchEnabled: boolean;
  40775. /**
  40776. * Defines the buttons associated with the input to handle camera rotation.
  40777. */
  40778. buttons: number[];
  40779. /**
  40780. * Assign buttons for Yaw control.
  40781. */
  40782. buttonsYaw: number[];
  40783. /**
  40784. * Assign buttons for Pitch control.
  40785. */
  40786. buttonsPitch: number[];
  40787. /**
  40788. * Assign buttons for Roll control.
  40789. */
  40790. buttonsRoll: number[];
  40791. /**
  40792. * Detect if any button is being pressed while mouse is moved.
  40793. * -1 = Mouse locked.
  40794. * 0 = Left button.
  40795. * 1 = Middle Button.
  40796. * 2 = Right Button.
  40797. */
  40798. activeButton: number;
  40799. /**
  40800. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40801. * Higher values reduce its sensitivity.
  40802. */
  40803. angularSensibility: number;
  40804. private _mousemoveCallback;
  40805. private _observer;
  40806. private _rollObserver;
  40807. private previousPosition;
  40808. private noPreventDefault;
  40809. private element;
  40810. /**
  40811. * Listen to mouse events to control the camera.
  40812. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40814. */
  40815. constructor(touchEnabled?: boolean);
  40816. /**
  40817. * Attach the mouse control to the HTML DOM element.
  40818. * @param element Defines the element that listens to the input events.
  40819. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40820. */
  40821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40822. /**
  40823. * Detach the current controls from the specified dom element.
  40824. * @param element Defines the element to stop listening the inputs from
  40825. */
  40826. detachControl(element: Nullable<HTMLElement>): void;
  40827. /**
  40828. * Gets the class name of the current input.
  40829. * @returns the class name.
  40830. */
  40831. getClassName(): string;
  40832. /**
  40833. * Get the friendly name associated with the input class.
  40834. * @returns the input's friendly name.
  40835. */
  40836. getSimpleName(): string;
  40837. private _pointerInput;
  40838. private _onMouseMove;
  40839. /**
  40840. * Rotate camera by mouse offset.
  40841. */
  40842. private rotateCamera;
  40843. }
  40844. }
  40845. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40846. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40847. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40848. /**
  40849. * Default Inputs manager for the FlyCamera.
  40850. * It groups all the default supported inputs for ease of use.
  40851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40852. */
  40853. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40854. /**
  40855. * Instantiates a new FlyCameraInputsManager.
  40856. * @param camera Defines the camera the inputs belong to.
  40857. */
  40858. constructor(camera: FlyCamera);
  40859. /**
  40860. * Add keyboard input support to the input manager.
  40861. * @returns the new FlyCameraKeyboardMoveInput().
  40862. */
  40863. addKeyboard(): FlyCameraInputsManager;
  40864. /**
  40865. * Add mouse input support to the input manager.
  40866. * @param touchEnabled Enable touch screen support.
  40867. * @returns the new FlyCameraMouseInput().
  40868. */
  40869. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40870. }
  40871. }
  40872. declare module "babylonjs/Cameras/flyCamera" {
  40873. import { Scene } from "babylonjs/scene";
  40874. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40876. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40877. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40878. /**
  40879. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40880. * such as in a 3D Space Shooter or a Flight Simulator.
  40881. */
  40882. export class FlyCamera extends TargetCamera {
  40883. /**
  40884. * Define the collision ellipsoid of the camera.
  40885. * This is helpful for simulating a camera body, like a player's body.
  40886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40887. */
  40888. ellipsoid: Vector3;
  40889. /**
  40890. * Define an offset for the position of the ellipsoid around the camera.
  40891. * This can be helpful if the camera is attached away from the player's body center,
  40892. * such as at its head.
  40893. */
  40894. ellipsoidOffset: Vector3;
  40895. /**
  40896. * Enable or disable collisions of the camera with the rest of the scene objects.
  40897. */
  40898. checkCollisions: boolean;
  40899. /**
  40900. * Enable or disable gravity on the camera.
  40901. */
  40902. applyGravity: boolean;
  40903. /**
  40904. * Define the current direction the camera is moving to.
  40905. */
  40906. cameraDirection: Vector3;
  40907. /**
  40908. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40909. * This overrides and empties cameraRotation.
  40910. */
  40911. rotationQuaternion: Quaternion;
  40912. /**
  40913. * Track Roll to maintain the wanted Rolling when looking around.
  40914. */
  40915. _trackRoll: number;
  40916. /**
  40917. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40918. */
  40919. rollCorrect: number;
  40920. /**
  40921. * Mimic a banked turn, Rolling the camera when Yawing.
  40922. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40923. */
  40924. bankedTurn: boolean;
  40925. /**
  40926. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40927. */
  40928. bankedTurnLimit: number;
  40929. /**
  40930. * Value of 0 disables the banked Roll.
  40931. * Value of 1 is equal to the Yaw angle in radians.
  40932. */
  40933. bankedTurnMultiplier: number;
  40934. /**
  40935. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40936. */
  40937. inputs: FlyCameraInputsManager;
  40938. /**
  40939. * Gets the input sensibility for mouse input.
  40940. * Higher values reduce sensitivity.
  40941. */
  40942. get angularSensibility(): number;
  40943. /**
  40944. * Sets the input sensibility for a mouse input.
  40945. * Higher values reduce sensitivity.
  40946. */
  40947. set angularSensibility(value: number);
  40948. /**
  40949. * Get the keys for camera movement forward.
  40950. */
  40951. get keysForward(): number[];
  40952. /**
  40953. * Set the keys for camera movement forward.
  40954. */
  40955. set keysForward(value: number[]);
  40956. /**
  40957. * Get the keys for camera movement backward.
  40958. */
  40959. get keysBackward(): number[];
  40960. set keysBackward(value: number[]);
  40961. /**
  40962. * Get the keys for camera movement up.
  40963. */
  40964. get keysUp(): number[];
  40965. /**
  40966. * Set the keys for camera movement up.
  40967. */
  40968. set keysUp(value: number[]);
  40969. /**
  40970. * Get the keys for camera movement down.
  40971. */
  40972. get keysDown(): number[];
  40973. /**
  40974. * Set the keys for camera movement down.
  40975. */
  40976. set keysDown(value: number[]);
  40977. /**
  40978. * Get the keys for camera movement left.
  40979. */
  40980. get keysLeft(): number[];
  40981. /**
  40982. * Set the keys for camera movement left.
  40983. */
  40984. set keysLeft(value: number[]);
  40985. /**
  40986. * Set the keys for camera movement right.
  40987. */
  40988. get keysRight(): number[];
  40989. /**
  40990. * Set the keys for camera movement right.
  40991. */
  40992. set keysRight(value: number[]);
  40993. /**
  40994. * Event raised when the camera collides with a mesh in the scene.
  40995. */
  40996. onCollide: (collidedMesh: AbstractMesh) => void;
  40997. private _collider;
  40998. private _needMoveForGravity;
  40999. private _oldPosition;
  41000. private _diffPosition;
  41001. private _newPosition;
  41002. /** @hidden */
  41003. _localDirection: Vector3;
  41004. /** @hidden */
  41005. _transformedDirection: Vector3;
  41006. /**
  41007. * Instantiates a FlyCamera.
  41008. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41009. * such as in a 3D Space Shooter or a Flight Simulator.
  41010. * @param name Define the name of the camera in the scene.
  41011. * @param position Define the starting position of the camera in the scene.
  41012. * @param scene Define the scene the camera belongs to.
  41013. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41014. */
  41015. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41016. /**
  41017. * Attach a control to the HTML DOM element.
  41018. * @param element Defines the element that listens to the input events.
  41019. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41020. */
  41021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41022. /**
  41023. * Detach a control from the HTML DOM element.
  41024. * The camera will stop reacting to that input.
  41025. * @param element Defines the element that listens to the input events.
  41026. */
  41027. detachControl(element: HTMLElement): void;
  41028. private _collisionMask;
  41029. /**
  41030. * Get the mask that the camera ignores in collision events.
  41031. */
  41032. get collisionMask(): number;
  41033. /**
  41034. * Set the mask that the camera ignores in collision events.
  41035. */
  41036. set collisionMask(mask: number);
  41037. /** @hidden */
  41038. _collideWithWorld(displacement: Vector3): void;
  41039. /** @hidden */
  41040. private _onCollisionPositionChange;
  41041. /** @hidden */
  41042. _checkInputs(): void;
  41043. /** @hidden */
  41044. _decideIfNeedsToMove(): boolean;
  41045. /** @hidden */
  41046. _updatePosition(): void;
  41047. /**
  41048. * Restore the Roll to its target value at the rate specified.
  41049. * @param rate - Higher means slower restoring.
  41050. * @hidden
  41051. */
  41052. restoreRoll(rate: number): void;
  41053. /**
  41054. * Destroy the camera and release the current resources held by it.
  41055. */
  41056. dispose(): void;
  41057. /**
  41058. * Get the current object class name.
  41059. * @returns the class name.
  41060. */
  41061. getClassName(): string;
  41062. }
  41063. }
  41064. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41065. import { Nullable } from "babylonjs/types";
  41066. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41067. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41068. /**
  41069. * Listen to keyboard events to control the camera.
  41070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41071. */
  41072. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41073. /**
  41074. * Defines the camera the input is attached to.
  41075. */
  41076. camera: FlyCamera;
  41077. /**
  41078. * The list of keyboard keys used to control the forward move of the camera.
  41079. */
  41080. keysForward: number[];
  41081. /**
  41082. * The list of keyboard keys used to control the backward move of the camera.
  41083. */
  41084. keysBackward: number[];
  41085. /**
  41086. * The list of keyboard keys used to control the forward move of the camera.
  41087. */
  41088. keysUp: number[];
  41089. /**
  41090. * The list of keyboard keys used to control the backward move of the camera.
  41091. */
  41092. keysDown: number[];
  41093. /**
  41094. * The list of keyboard keys used to control the right strafe move of the camera.
  41095. */
  41096. keysRight: number[];
  41097. /**
  41098. * The list of keyboard keys used to control the left strafe move of the camera.
  41099. */
  41100. keysLeft: number[];
  41101. private _keys;
  41102. private _onCanvasBlurObserver;
  41103. private _onKeyboardObserver;
  41104. private _engine;
  41105. private _scene;
  41106. /**
  41107. * Attach the input controls to a specific dom element to get the input from.
  41108. * @param element Defines the element the controls should be listened from
  41109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41110. */
  41111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41112. /**
  41113. * Detach the current controls from the specified dom element.
  41114. * @param element Defines the element to stop listening the inputs from
  41115. */
  41116. detachControl(element: Nullable<HTMLElement>): void;
  41117. /**
  41118. * Gets the class name of the current intput.
  41119. * @returns the class name
  41120. */
  41121. getClassName(): string;
  41122. /** @hidden */
  41123. _onLostFocus(e: FocusEvent): void;
  41124. /**
  41125. * Get the friendly name associated with the input class.
  41126. * @returns the input friendly name
  41127. */
  41128. getSimpleName(): string;
  41129. /**
  41130. * Update the current camera state depending on the inputs that have been used this frame.
  41131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41132. */
  41133. checkInputs(): void;
  41134. }
  41135. }
  41136. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41137. import { Nullable } from "babylonjs/types";
  41138. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41139. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41140. /**
  41141. * Manage the mouse wheel inputs to control a follow camera.
  41142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41143. */
  41144. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41145. /**
  41146. * Defines the camera the input is attached to.
  41147. */
  41148. camera: FollowCamera;
  41149. /**
  41150. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41151. */
  41152. axisControlRadius: boolean;
  41153. /**
  41154. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41155. */
  41156. axisControlHeight: boolean;
  41157. /**
  41158. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41159. */
  41160. axisControlRotation: boolean;
  41161. /**
  41162. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41163. * relation to mouseWheel events.
  41164. */
  41165. wheelPrecision: number;
  41166. /**
  41167. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41168. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41169. */
  41170. wheelDeltaPercentage: number;
  41171. private _wheel;
  41172. private _observer;
  41173. /**
  41174. * Attach the input controls to a specific dom element to get the input from.
  41175. * @param element Defines the element the controls should be listened from
  41176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41177. */
  41178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41179. /**
  41180. * Detach the current controls from the specified dom element.
  41181. * @param element Defines the element to stop listening the inputs from
  41182. */
  41183. detachControl(element: Nullable<HTMLElement>): void;
  41184. /**
  41185. * Gets the class name of the current intput.
  41186. * @returns the class name
  41187. */
  41188. getClassName(): string;
  41189. /**
  41190. * Get the friendly name associated with the input class.
  41191. * @returns the input friendly name
  41192. */
  41193. getSimpleName(): string;
  41194. }
  41195. }
  41196. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41197. import { Nullable } from "babylonjs/types";
  41198. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41199. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41200. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41201. /**
  41202. * Manage the pointers inputs to control an follow camera.
  41203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41204. */
  41205. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41206. /**
  41207. * Defines the camera the input is attached to.
  41208. */
  41209. camera: FollowCamera;
  41210. /**
  41211. * Gets the class name of the current input.
  41212. * @returns the class name
  41213. */
  41214. getClassName(): string;
  41215. /**
  41216. * Defines the pointer angular sensibility along the X axis or how fast is
  41217. * the camera rotating.
  41218. * A negative number will reverse the axis direction.
  41219. */
  41220. angularSensibilityX: number;
  41221. /**
  41222. * Defines the pointer angular sensibility along the Y axis or how fast is
  41223. * the camera rotating.
  41224. * A negative number will reverse the axis direction.
  41225. */
  41226. angularSensibilityY: number;
  41227. /**
  41228. * Defines the pointer pinch precision or how fast is the camera zooming.
  41229. * A negative number will reverse the axis direction.
  41230. */
  41231. pinchPrecision: number;
  41232. /**
  41233. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41234. * from 0.
  41235. * It defines the percentage of current camera.radius to use as delta when
  41236. * pinch zoom is used.
  41237. */
  41238. pinchDeltaPercentage: number;
  41239. /**
  41240. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41241. */
  41242. axisXControlRadius: boolean;
  41243. /**
  41244. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41245. */
  41246. axisXControlHeight: boolean;
  41247. /**
  41248. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41249. */
  41250. axisXControlRotation: boolean;
  41251. /**
  41252. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41253. */
  41254. axisYControlRadius: boolean;
  41255. /**
  41256. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41257. */
  41258. axisYControlHeight: boolean;
  41259. /**
  41260. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41261. */
  41262. axisYControlRotation: boolean;
  41263. /**
  41264. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41265. */
  41266. axisPinchControlRadius: boolean;
  41267. /**
  41268. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41269. */
  41270. axisPinchControlHeight: boolean;
  41271. /**
  41272. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41273. */
  41274. axisPinchControlRotation: boolean;
  41275. /**
  41276. * Log error messages if basic misconfiguration has occurred.
  41277. */
  41278. warningEnable: boolean;
  41279. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41280. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41281. private _warningCounter;
  41282. private _warning;
  41283. }
  41284. }
  41285. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41286. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41287. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41288. /**
  41289. * Default Inputs manager for the FollowCamera.
  41290. * It groups all the default supported inputs for ease of use.
  41291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41292. */
  41293. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41294. /**
  41295. * Instantiates a new FollowCameraInputsManager.
  41296. * @param camera Defines the camera the inputs belong to
  41297. */
  41298. constructor(camera: FollowCamera);
  41299. /**
  41300. * Add keyboard input support to the input manager.
  41301. * @returns the current input manager
  41302. */
  41303. addKeyboard(): FollowCameraInputsManager;
  41304. /**
  41305. * Add mouse wheel input support to the input manager.
  41306. * @returns the current input manager
  41307. */
  41308. addMouseWheel(): FollowCameraInputsManager;
  41309. /**
  41310. * Add pointers input support to the input manager.
  41311. * @returns the current input manager
  41312. */
  41313. addPointers(): FollowCameraInputsManager;
  41314. /**
  41315. * Add orientation input support to the input manager.
  41316. * @returns the current input manager
  41317. */
  41318. addVRDeviceOrientation(): FollowCameraInputsManager;
  41319. }
  41320. }
  41321. declare module "babylonjs/Cameras/followCamera" {
  41322. import { Nullable } from "babylonjs/types";
  41323. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41324. import { Scene } from "babylonjs/scene";
  41325. import { Vector3 } from "babylonjs/Maths/math.vector";
  41326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41327. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41328. /**
  41329. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41330. * an arc rotate version arcFollowCamera are available.
  41331. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41332. */
  41333. export class FollowCamera extends TargetCamera {
  41334. /**
  41335. * Distance the follow camera should follow an object at
  41336. */
  41337. radius: number;
  41338. /**
  41339. * Minimum allowed distance of the camera to the axis of rotation
  41340. * (The camera can not get closer).
  41341. * This can help limiting how the Camera is able to move in the scene.
  41342. */
  41343. lowerRadiusLimit: Nullable<number>;
  41344. /**
  41345. * Maximum allowed distance of the camera to the axis of rotation
  41346. * (The camera can not get further).
  41347. * This can help limiting how the Camera is able to move in the scene.
  41348. */
  41349. upperRadiusLimit: Nullable<number>;
  41350. /**
  41351. * Define a rotation offset between the camera and the object it follows
  41352. */
  41353. rotationOffset: number;
  41354. /**
  41355. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  41359. /**
  41360. * Maximum allowed angle to camera position relative to target object.
  41361. * This can help limiting how the Camera is able to move in the scene.
  41362. */
  41363. upperRotationOffsetLimit: Nullable<number>;
  41364. /**
  41365. * Define a height offset between the camera and the object it follows.
  41366. * It can help following an object from the top (like a car chaing a plane)
  41367. */
  41368. heightOffset: number;
  41369. /**
  41370. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  41374. /**
  41375. * Maximum allowed height of camera position relative to target object.
  41376. * This can help limiting how the Camera is able to move in the scene.
  41377. */
  41378. upperHeightOffsetLimit: Nullable<number>;
  41379. /**
  41380. * Define how fast the camera can accelerate to follow it s target.
  41381. */
  41382. cameraAcceleration: number;
  41383. /**
  41384. * Define the speed limit of the camera following an object.
  41385. */
  41386. maxCameraSpeed: number;
  41387. /**
  41388. * Define the target of the camera.
  41389. */
  41390. lockedTarget: Nullable<AbstractMesh>;
  41391. /**
  41392. * Defines the input associated with the camera.
  41393. */
  41394. inputs: FollowCameraInputsManager;
  41395. /**
  41396. * Instantiates the follow camera.
  41397. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41398. * @param name Define the name of the camera in the scene
  41399. * @param position Define the position of the camera
  41400. * @param scene Define the scene the camera belong to
  41401. * @param lockedTarget Define the target of the camera
  41402. */
  41403. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41404. private _follow;
  41405. /**
  41406. * Attached controls to the current camera.
  41407. * @param element Defines the element the controls should be listened from
  41408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41409. */
  41410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41411. /**
  41412. * Detach the current controls from the camera.
  41413. * The camera will stop reacting to inputs.
  41414. * @param element Defines the element to stop listening the inputs from
  41415. */
  41416. detachControl(element: HTMLElement): void;
  41417. /** @hidden */
  41418. _checkInputs(): void;
  41419. private _checkLimits;
  41420. /**
  41421. * Gets the camera class name.
  41422. * @returns the class name
  41423. */
  41424. getClassName(): string;
  41425. }
  41426. /**
  41427. * Arc Rotate version of the follow camera.
  41428. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41429. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41430. */
  41431. export class ArcFollowCamera extends TargetCamera {
  41432. /** The longitudinal angle of the camera */
  41433. alpha: number;
  41434. /** The latitudinal angle of the camera */
  41435. beta: number;
  41436. /** The radius of the camera from its target */
  41437. radius: number;
  41438. /** Define the camera target (the messh it should follow) */
  41439. target: Nullable<AbstractMesh>;
  41440. private _cartesianCoordinates;
  41441. /**
  41442. * Instantiates a new ArcFollowCamera
  41443. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41444. * @param name Define the name of the camera
  41445. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41446. * @param beta Define the rotation angle of the camera around the elevation axis
  41447. * @param radius Define the radius of the camera from its target point
  41448. * @param target Define the target of the camera
  41449. * @param scene Define the scene the camera belongs to
  41450. */
  41451. constructor(name: string,
  41452. /** The longitudinal angle of the camera */
  41453. alpha: number,
  41454. /** The latitudinal angle of the camera */
  41455. beta: number,
  41456. /** The radius of the camera from its target */
  41457. radius: number,
  41458. /** Define the camera target (the messh it should follow) */
  41459. target: Nullable<AbstractMesh>, scene: Scene);
  41460. private _follow;
  41461. /** @hidden */
  41462. _checkInputs(): void;
  41463. /**
  41464. * Returns the class name of the object.
  41465. * It is mostly used internally for serialization purposes.
  41466. */
  41467. getClassName(): string;
  41468. }
  41469. }
  41470. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41471. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41472. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41473. import { Nullable } from "babylonjs/types";
  41474. /**
  41475. * Manage the keyboard inputs to control the movement of a follow camera.
  41476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41477. */
  41478. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41479. /**
  41480. * Defines the camera the input is attached to.
  41481. */
  41482. camera: FollowCamera;
  41483. /**
  41484. * Defines the list of key codes associated with the up action (increase heightOffset)
  41485. */
  41486. keysHeightOffsetIncr: number[];
  41487. /**
  41488. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41489. */
  41490. keysHeightOffsetDecr: number[];
  41491. /**
  41492. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41493. */
  41494. keysHeightOffsetModifierAlt: boolean;
  41495. /**
  41496. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41497. */
  41498. keysHeightOffsetModifierCtrl: boolean;
  41499. /**
  41500. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41501. */
  41502. keysHeightOffsetModifierShift: boolean;
  41503. /**
  41504. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41505. */
  41506. keysRotationOffsetIncr: number[];
  41507. /**
  41508. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41509. */
  41510. keysRotationOffsetDecr: number[];
  41511. /**
  41512. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41513. */
  41514. keysRotationOffsetModifierAlt: boolean;
  41515. /**
  41516. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41517. */
  41518. keysRotationOffsetModifierCtrl: boolean;
  41519. /**
  41520. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41521. */
  41522. keysRotationOffsetModifierShift: boolean;
  41523. /**
  41524. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41525. */
  41526. keysRadiusIncr: number[];
  41527. /**
  41528. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41529. */
  41530. keysRadiusDecr: number[];
  41531. /**
  41532. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41533. */
  41534. keysRadiusModifierAlt: boolean;
  41535. /**
  41536. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41537. */
  41538. keysRadiusModifierCtrl: boolean;
  41539. /**
  41540. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41541. */
  41542. keysRadiusModifierShift: boolean;
  41543. /**
  41544. * Defines the rate of change of heightOffset.
  41545. */
  41546. heightSensibility: number;
  41547. /**
  41548. * Defines the rate of change of rotationOffset.
  41549. */
  41550. rotationSensibility: number;
  41551. /**
  41552. * Defines the rate of change of radius.
  41553. */
  41554. radiusSensibility: number;
  41555. private _keys;
  41556. private _ctrlPressed;
  41557. private _altPressed;
  41558. private _shiftPressed;
  41559. private _onCanvasBlurObserver;
  41560. private _onKeyboardObserver;
  41561. private _engine;
  41562. private _scene;
  41563. /**
  41564. * Attach the input controls to a specific dom element to get the input from.
  41565. * @param element Defines the element the controls should be listened from
  41566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41567. */
  41568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41569. /**
  41570. * Detach the current controls from the specified dom element.
  41571. * @param element Defines the element to stop listening the inputs from
  41572. */
  41573. detachControl(element: Nullable<HTMLElement>): void;
  41574. /**
  41575. * Update the current camera state depending on the inputs that have been used this frame.
  41576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41577. */
  41578. checkInputs(): void;
  41579. /**
  41580. * Gets the class name of the current input.
  41581. * @returns the class name
  41582. */
  41583. getClassName(): string;
  41584. /**
  41585. * Get the friendly name associated with the input class.
  41586. * @returns the input friendly name
  41587. */
  41588. getSimpleName(): string;
  41589. /**
  41590. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41591. * allow modification of the heightOffset value.
  41592. */
  41593. private _modifierHeightOffset;
  41594. /**
  41595. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41596. * allow modification of the rotationOffset value.
  41597. */
  41598. private _modifierRotationOffset;
  41599. /**
  41600. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41601. * allow modification of the radius value.
  41602. */
  41603. private _modifierRadius;
  41604. }
  41605. }
  41606. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41607. import { Nullable } from "babylonjs/types";
  41608. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41609. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41610. import { Observable } from "babylonjs/Misc/observable";
  41611. module "babylonjs/Cameras/freeCameraInputsManager" {
  41612. interface FreeCameraInputsManager {
  41613. /**
  41614. * @hidden
  41615. */
  41616. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41617. /**
  41618. * Add orientation input support to the input manager.
  41619. * @returns the current input manager
  41620. */
  41621. addDeviceOrientation(): FreeCameraInputsManager;
  41622. }
  41623. }
  41624. /**
  41625. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41626. * Screen rotation is taken into account.
  41627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41628. */
  41629. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41630. private _camera;
  41631. private _screenOrientationAngle;
  41632. private _constantTranform;
  41633. private _screenQuaternion;
  41634. private _alpha;
  41635. private _beta;
  41636. private _gamma;
  41637. /**
  41638. * Can be used to detect if a device orientation sensor is available on a device
  41639. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41640. * @returns a promise that will resolve on orientation change
  41641. */
  41642. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41643. /**
  41644. * @hidden
  41645. */
  41646. _onDeviceOrientationChangedObservable: Observable<void>;
  41647. /**
  41648. * Instantiates a new input
  41649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41650. */
  41651. constructor();
  41652. /**
  41653. * Define the camera controlled by the input.
  41654. */
  41655. get camera(): FreeCamera;
  41656. set camera(camera: FreeCamera);
  41657. /**
  41658. * Attach the input controls to a specific dom element to get the input from.
  41659. * @param element Defines the element the controls should be listened from
  41660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41661. */
  41662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41663. private _orientationChanged;
  41664. private _deviceOrientation;
  41665. /**
  41666. * Detach the current controls from the specified dom element.
  41667. * @param element Defines the element to stop listening the inputs from
  41668. */
  41669. detachControl(element: Nullable<HTMLElement>): void;
  41670. /**
  41671. * Update the current camera state depending on the inputs that have been used this frame.
  41672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41673. */
  41674. checkInputs(): void;
  41675. /**
  41676. * Gets the class name of the current intput.
  41677. * @returns the class name
  41678. */
  41679. getClassName(): string;
  41680. /**
  41681. * Get the friendly name associated with the input class.
  41682. * @returns the input friendly name
  41683. */
  41684. getSimpleName(): string;
  41685. }
  41686. }
  41687. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41688. import { Nullable } from "babylonjs/types";
  41689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41691. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41692. /**
  41693. * Manage the gamepad inputs to control a free camera.
  41694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41695. */
  41696. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41697. /**
  41698. * Define the camera the input is attached to.
  41699. */
  41700. camera: FreeCamera;
  41701. /**
  41702. * Define the Gamepad controlling the input
  41703. */
  41704. gamepad: Nullable<Gamepad>;
  41705. /**
  41706. * Defines the gamepad rotation sensiblity.
  41707. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41708. */
  41709. gamepadAngularSensibility: number;
  41710. /**
  41711. * Defines the gamepad move sensiblity.
  41712. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41713. */
  41714. gamepadMoveSensibility: number;
  41715. private _yAxisScale;
  41716. /**
  41717. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41718. */
  41719. get invertYAxis(): boolean;
  41720. set invertYAxis(value: boolean);
  41721. private _onGamepadConnectedObserver;
  41722. private _onGamepadDisconnectedObserver;
  41723. private _cameraTransform;
  41724. private _deltaTransform;
  41725. private _vector3;
  41726. private _vector2;
  41727. /**
  41728. * Attach the input controls to a specific dom element to get the input from.
  41729. * @param element Defines the element the controls should be listened from
  41730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41731. */
  41732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41733. /**
  41734. * Detach the current controls from the specified dom element.
  41735. * @param element Defines the element to stop listening the inputs from
  41736. */
  41737. detachControl(element: Nullable<HTMLElement>): void;
  41738. /**
  41739. * Update the current camera state depending on the inputs that have been used this frame.
  41740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41741. */
  41742. checkInputs(): void;
  41743. /**
  41744. * Gets the class name of the current intput.
  41745. * @returns the class name
  41746. */
  41747. getClassName(): string;
  41748. /**
  41749. * Get the friendly name associated with the input class.
  41750. * @returns the input friendly name
  41751. */
  41752. getSimpleName(): string;
  41753. }
  41754. }
  41755. declare module "babylonjs/Misc/virtualJoystick" {
  41756. import { Nullable } from "babylonjs/types";
  41757. import { Vector3 } from "babylonjs/Maths/math.vector";
  41758. /**
  41759. * Defines the potential axis of a Joystick
  41760. */
  41761. export enum JoystickAxis {
  41762. /** X axis */
  41763. X = 0,
  41764. /** Y axis */
  41765. Y = 1,
  41766. /** Z axis */
  41767. Z = 2
  41768. }
  41769. /**
  41770. * Class used to define virtual joystick (used in touch mode)
  41771. */
  41772. export class VirtualJoystick {
  41773. /**
  41774. * Gets or sets a boolean indicating that left and right values must be inverted
  41775. */
  41776. reverseLeftRight: boolean;
  41777. /**
  41778. * Gets or sets a boolean indicating that up and down values must be inverted
  41779. */
  41780. reverseUpDown: boolean;
  41781. /**
  41782. * Gets the offset value for the position (ie. the change of the position value)
  41783. */
  41784. deltaPosition: Vector3;
  41785. /**
  41786. * Gets a boolean indicating if the virtual joystick was pressed
  41787. */
  41788. pressed: boolean;
  41789. /**
  41790. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41791. */
  41792. static Canvas: Nullable<HTMLCanvasElement>;
  41793. private static _globalJoystickIndex;
  41794. private static vjCanvasContext;
  41795. private static vjCanvasWidth;
  41796. private static vjCanvasHeight;
  41797. private static halfWidth;
  41798. private _action;
  41799. private _axisTargetedByLeftAndRight;
  41800. private _axisTargetedByUpAndDown;
  41801. private _joystickSensibility;
  41802. private _inversedSensibility;
  41803. private _joystickPointerID;
  41804. private _joystickColor;
  41805. private _joystickPointerPos;
  41806. private _joystickPreviousPointerPos;
  41807. private _joystickPointerStartPos;
  41808. private _deltaJoystickVector;
  41809. private _leftJoystick;
  41810. private _touches;
  41811. private _onPointerDownHandlerRef;
  41812. private _onPointerMoveHandlerRef;
  41813. private _onPointerUpHandlerRef;
  41814. private _onResize;
  41815. /**
  41816. * Creates a new virtual joystick
  41817. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41818. */
  41819. constructor(leftJoystick?: boolean);
  41820. /**
  41821. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41822. * @param newJoystickSensibility defines the new sensibility
  41823. */
  41824. setJoystickSensibility(newJoystickSensibility: number): void;
  41825. private _onPointerDown;
  41826. private _onPointerMove;
  41827. private _onPointerUp;
  41828. /**
  41829. * Change the color of the virtual joystick
  41830. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41831. */
  41832. setJoystickColor(newColor: string): void;
  41833. /**
  41834. * Defines a callback to call when the joystick is touched
  41835. * @param action defines the callback
  41836. */
  41837. setActionOnTouch(action: () => any): void;
  41838. /**
  41839. * Defines which axis you'd like to control for left & right
  41840. * @param axis defines the axis to use
  41841. */
  41842. setAxisForLeftRight(axis: JoystickAxis): void;
  41843. /**
  41844. * Defines which axis you'd like to control for up & down
  41845. * @param axis defines the axis to use
  41846. */
  41847. setAxisForUpDown(axis: JoystickAxis): void;
  41848. private _drawVirtualJoystick;
  41849. /**
  41850. * Release internal HTML canvas
  41851. */
  41852. releaseCanvas(): void;
  41853. }
  41854. }
  41855. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41856. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41857. import { Nullable } from "babylonjs/types";
  41858. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41859. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41860. module "babylonjs/Cameras/freeCameraInputsManager" {
  41861. interface FreeCameraInputsManager {
  41862. /**
  41863. * Add virtual joystick input support to the input manager.
  41864. * @returns the current input manager
  41865. */
  41866. addVirtualJoystick(): FreeCameraInputsManager;
  41867. }
  41868. }
  41869. /**
  41870. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41872. */
  41873. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41874. /**
  41875. * Defines the camera the input is attached to.
  41876. */
  41877. camera: FreeCamera;
  41878. private _leftjoystick;
  41879. private _rightjoystick;
  41880. /**
  41881. * Gets the left stick of the virtual joystick.
  41882. * @returns The virtual Joystick
  41883. */
  41884. getLeftJoystick(): VirtualJoystick;
  41885. /**
  41886. * Gets the right stick of the virtual joystick.
  41887. * @returns The virtual Joystick
  41888. */
  41889. getRightJoystick(): VirtualJoystick;
  41890. /**
  41891. * Update the current camera state depending on the inputs that have been used this frame.
  41892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41893. */
  41894. checkInputs(): void;
  41895. /**
  41896. * Attach the input controls to a specific dom element to get the input from.
  41897. * @param element Defines the element the controls should be listened from
  41898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41899. */
  41900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41901. /**
  41902. * Detach the current controls from the specified dom element.
  41903. * @param element Defines the element to stop listening the inputs from
  41904. */
  41905. detachControl(element: Nullable<HTMLElement>): void;
  41906. /**
  41907. * Gets the class name of the current intput.
  41908. * @returns the class name
  41909. */
  41910. getClassName(): string;
  41911. /**
  41912. * Get the friendly name associated with the input class.
  41913. * @returns the input friendly name
  41914. */
  41915. getSimpleName(): string;
  41916. }
  41917. }
  41918. declare module "babylonjs/Cameras/Inputs/index" {
  41919. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41920. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41921. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41922. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41923. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41924. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41925. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41926. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41927. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41928. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41929. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41930. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41931. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41932. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41933. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41934. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41935. }
  41936. declare module "babylonjs/Cameras/touchCamera" {
  41937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41938. import { Scene } from "babylonjs/scene";
  41939. import { Vector3 } from "babylonjs/Maths/math.vector";
  41940. /**
  41941. * This represents a FPS type of camera controlled by touch.
  41942. * This is like a universal camera minus the Gamepad controls.
  41943. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41944. */
  41945. export class TouchCamera extends FreeCamera {
  41946. /**
  41947. * Defines the touch sensibility for rotation.
  41948. * The higher the faster.
  41949. */
  41950. get touchAngularSensibility(): number;
  41951. set touchAngularSensibility(value: number);
  41952. /**
  41953. * Defines the touch sensibility for move.
  41954. * The higher the faster.
  41955. */
  41956. get touchMoveSensibility(): number;
  41957. set touchMoveSensibility(value: number);
  41958. /**
  41959. * Instantiates a new touch camera.
  41960. * This represents a FPS type of camera controlled by touch.
  41961. * This is like a universal camera minus the Gamepad controls.
  41962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41963. * @param name Define the name of the camera in the scene
  41964. * @param position Define the start position of the camera in the scene
  41965. * @param scene Define the scene the camera belongs to
  41966. */
  41967. constructor(name: string, position: Vector3, scene: Scene);
  41968. /**
  41969. * Gets the current object class name.
  41970. * @return the class name
  41971. */
  41972. getClassName(): string;
  41973. /** @hidden */
  41974. _setupInputs(): void;
  41975. }
  41976. }
  41977. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41979. import { Scene } from "babylonjs/scene";
  41980. import { Vector3 } from "babylonjs/Maths/math.vector";
  41981. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41982. import { Axis } from "babylonjs/Maths/math.axis";
  41983. /**
  41984. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41985. * being tilted forward or back and left or right.
  41986. */
  41987. export class DeviceOrientationCamera extends FreeCamera {
  41988. private _initialQuaternion;
  41989. private _quaternionCache;
  41990. private _tmpDragQuaternion;
  41991. private _disablePointerInputWhenUsingDeviceOrientation;
  41992. /**
  41993. * Creates a new device orientation camera
  41994. * @param name The name of the camera
  41995. * @param position The start position camera
  41996. * @param scene The scene the camera belongs to
  41997. */
  41998. constructor(name: string, position: Vector3, scene: Scene);
  41999. /**
  42000. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42001. */
  42002. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42003. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42004. private _dragFactor;
  42005. /**
  42006. * Enabled turning on the y axis when the orientation sensor is active
  42007. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42008. */
  42009. enableHorizontalDragging(dragFactor?: number): void;
  42010. /**
  42011. * Gets the current instance class name ("DeviceOrientationCamera").
  42012. * This helps avoiding instanceof at run time.
  42013. * @returns the class name
  42014. */
  42015. getClassName(): string;
  42016. /**
  42017. * @hidden
  42018. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42019. */
  42020. _checkInputs(): void;
  42021. /**
  42022. * Reset the camera to its default orientation on the specified axis only.
  42023. * @param axis The axis to reset
  42024. */
  42025. resetToCurrentRotation(axis?: Axis): void;
  42026. }
  42027. }
  42028. declare module "babylonjs/Gamepads/xboxGamepad" {
  42029. import { Observable } from "babylonjs/Misc/observable";
  42030. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42031. /**
  42032. * Defines supported buttons for XBox360 compatible gamepads
  42033. */
  42034. export enum Xbox360Button {
  42035. /** A */
  42036. A = 0,
  42037. /** B */
  42038. B = 1,
  42039. /** X */
  42040. X = 2,
  42041. /** Y */
  42042. Y = 3,
  42043. /** Start */
  42044. Start = 4,
  42045. /** Back */
  42046. Back = 5,
  42047. /** Left button */
  42048. LB = 6,
  42049. /** Right button */
  42050. RB = 7,
  42051. /** Left stick */
  42052. LeftStick = 8,
  42053. /** Right stick */
  42054. RightStick = 9
  42055. }
  42056. /** Defines values for XBox360 DPad */
  42057. export enum Xbox360Dpad {
  42058. /** Up */
  42059. Up = 0,
  42060. /** Down */
  42061. Down = 1,
  42062. /** Left */
  42063. Left = 2,
  42064. /** Right */
  42065. Right = 3
  42066. }
  42067. /**
  42068. * Defines a XBox360 gamepad
  42069. */
  42070. export class Xbox360Pad extends Gamepad {
  42071. private _leftTrigger;
  42072. private _rightTrigger;
  42073. private _onlefttriggerchanged;
  42074. private _onrighttriggerchanged;
  42075. private _onbuttondown;
  42076. private _onbuttonup;
  42077. private _ondpaddown;
  42078. private _ondpadup;
  42079. /** Observable raised when a button is pressed */
  42080. onButtonDownObservable: Observable<Xbox360Button>;
  42081. /** Observable raised when a button is released */
  42082. onButtonUpObservable: Observable<Xbox360Button>;
  42083. /** Observable raised when a pad is pressed */
  42084. onPadDownObservable: Observable<Xbox360Dpad>;
  42085. /** Observable raised when a pad is released */
  42086. onPadUpObservable: Observable<Xbox360Dpad>;
  42087. private _buttonA;
  42088. private _buttonB;
  42089. private _buttonX;
  42090. private _buttonY;
  42091. private _buttonBack;
  42092. private _buttonStart;
  42093. private _buttonLB;
  42094. private _buttonRB;
  42095. private _buttonLeftStick;
  42096. private _buttonRightStick;
  42097. private _dPadUp;
  42098. private _dPadDown;
  42099. private _dPadLeft;
  42100. private _dPadRight;
  42101. private _isXboxOnePad;
  42102. /**
  42103. * Creates a new XBox360 gamepad object
  42104. * @param id defines the id of this gamepad
  42105. * @param index defines its index
  42106. * @param gamepad defines the internal HTML gamepad object
  42107. * @param xboxOne defines if it is a XBox One gamepad
  42108. */
  42109. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42110. /**
  42111. * Defines the callback to call when left trigger is pressed
  42112. * @param callback defines the callback to use
  42113. */
  42114. onlefttriggerchanged(callback: (value: number) => void): void;
  42115. /**
  42116. * Defines the callback to call when right trigger is pressed
  42117. * @param callback defines the callback to use
  42118. */
  42119. onrighttriggerchanged(callback: (value: number) => void): void;
  42120. /**
  42121. * Gets the left trigger value
  42122. */
  42123. get leftTrigger(): number;
  42124. /**
  42125. * Sets the left trigger value
  42126. */
  42127. set leftTrigger(newValue: number);
  42128. /**
  42129. * Gets the right trigger value
  42130. */
  42131. get rightTrigger(): number;
  42132. /**
  42133. * Sets the right trigger value
  42134. */
  42135. set rightTrigger(newValue: number);
  42136. /**
  42137. * Defines the callback to call when a button is pressed
  42138. * @param callback defines the callback to use
  42139. */
  42140. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42141. /**
  42142. * Defines the callback to call when a button is released
  42143. * @param callback defines the callback to use
  42144. */
  42145. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42146. /**
  42147. * Defines the callback to call when a pad is pressed
  42148. * @param callback defines the callback to use
  42149. */
  42150. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42151. /**
  42152. * Defines the callback to call when a pad is released
  42153. * @param callback defines the callback to use
  42154. */
  42155. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42156. private _setButtonValue;
  42157. private _setDPadValue;
  42158. /**
  42159. * Gets the value of the `A` button
  42160. */
  42161. get buttonA(): number;
  42162. /**
  42163. * Sets the value of the `A` button
  42164. */
  42165. set buttonA(value: number);
  42166. /**
  42167. * Gets the value of the `B` button
  42168. */
  42169. get buttonB(): number;
  42170. /**
  42171. * Sets the value of the `B` button
  42172. */
  42173. set buttonB(value: number);
  42174. /**
  42175. * Gets the value of the `X` button
  42176. */
  42177. get buttonX(): number;
  42178. /**
  42179. * Sets the value of the `X` button
  42180. */
  42181. set buttonX(value: number);
  42182. /**
  42183. * Gets the value of the `Y` button
  42184. */
  42185. get buttonY(): number;
  42186. /**
  42187. * Sets the value of the `Y` button
  42188. */
  42189. set buttonY(value: number);
  42190. /**
  42191. * Gets the value of the `Start` button
  42192. */
  42193. get buttonStart(): number;
  42194. /**
  42195. * Sets the value of the `Start` button
  42196. */
  42197. set buttonStart(value: number);
  42198. /**
  42199. * Gets the value of the `Back` button
  42200. */
  42201. get buttonBack(): number;
  42202. /**
  42203. * Sets the value of the `Back` button
  42204. */
  42205. set buttonBack(value: number);
  42206. /**
  42207. * Gets the value of the `Left` button
  42208. */
  42209. get buttonLB(): number;
  42210. /**
  42211. * Sets the value of the `Left` button
  42212. */
  42213. set buttonLB(value: number);
  42214. /**
  42215. * Gets the value of the `Right` button
  42216. */
  42217. get buttonRB(): number;
  42218. /**
  42219. * Sets the value of the `Right` button
  42220. */
  42221. set buttonRB(value: number);
  42222. /**
  42223. * Gets the value of the Left joystick
  42224. */
  42225. get buttonLeftStick(): number;
  42226. /**
  42227. * Sets the value of the Left joystick
  42228. */
  42229. set buttonLeftStick(value: number);
  42230. /**
  42231. * Gets the value of the Right joystick
  42232. */
  42233. get buttonRightStick(): number;
  42234. /**
  42235. * Sets the value of the Right joystick
  42236. */
  42237. set buttonRightStick(value: number);
  42238. /**
  42239. * Gets the value of D-pad up
  42240. */
  42241. get dPadUp(): number;
  42242. /**
  42243. * Sets the value of D-pad up
  42244. */
  42245. set dPadUp(value: number);
  42246. /**
  42247. * Gets the value of D-pad down
  42248. */
  42249. get dPadDown(): number;
  42250. /**
  42251. * Sets the value of D-pad down
  42252. */
  42253. set dPadDown(value: number);
  42254. /**
  42255. * Gets the value of D-pad left
  42256. */
  42257. get dPadLeft(): number;
  42258. /**
  42259. * Sets the value of D-pad left
  42260. */
  42261. set dPadLeft(value: number);
  42262. /**
  42263. * Gets the value of D-pad right
  42264. */
  42265. get dPadRight(): number;
  42266. /**
  42267. * Sets the value of D-pad right
  42268. */
  42269. set dPadRight(value: number);
  42270. /**
  42271. * Force the gamepad to synchronize with device values
  42272. */
  42273. update(): void;
  42274. /**
  42275. * Disposes the gamepad
  42276. */
  42277. dispose(): void;
  42278. }
  42279. }
  42280. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42281. import { Observable } from "babylonjs/Misc/observable";
  42282. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42283. /**
  42284. * Defines supported buttons for DualShock compatible gamepads
  42285. */
  42286. export enum DualShockButton {
  42287. /** Cross */
  42288. Cross = 0,
  42289. /** Circle */
  42290. Circle = 1,
  42291. /** Square */
  42292. Square = 2,
  42293. /** Triangle */
  42294. Triangle = 3,
  42295. /** Options */
  42296. Options = 4,
  42297. /** Share */
  42298. Share = 5,
  42299. /** L1 */
  42300. L1 = 6,
  42301. /** R1 */
  42302. R1 = 7,
  42303. /** Left stick */
  42304. LeftStick = 8,
  42305. /** Right stick */
  42306. RightStick = 9
  42307. }
  42308. /** Defines values for DualShock DPad */
  42309. export enum DualShockDpad {
  42310. /** Up */
  42311. Up = 0,
  42312. /** Down */
  42313. Down = 1,
  42314. /** Left */
  42315. Left = 2,
  42316. /** Right */
  42317. Right = 3
  42318. }
  42319. /**
  42320. * Defines a DualShock gamepad
  42321. */
  42322. export class DualShockPad extends Gamepad {
  42323. private _leftTrigger;
  42324. private _rightTrigger;
  42325. private _onlefttriggerchanged;
  42326. private _onrighttriggerchanged;
  42327. private _onbuttondown;
  42328. private _onbuttonup;
  42329. private _ondpaddown;
  42330. private _ondpadup;
  42331. /** Observable raised when a button is pressed */
  42332. onButtonDownObservable: Observable<DualShockButton>;
  42333. /** Observable raised when a button is released */
  42334. onButtonUpObservable: Observable<DualShockButton>;
  42335. /** Observable raised when a pad is pressed */
  42336. onPadDownObservable: Observable<DualShockDpad>;
  42337. /** Observable raised when a pad is released */
  42338. onPadUpObservable: Observable<DualShockDpad>;
  42339. private _buttonCross;
  42340. private _buttonCircle;
  42341. private _buttonSquare;
  42342. private _buttonTriangle;
  42343. private _buttonShare;
  42344. private _buttonOptions;
  42345. private _buttonL1;
  42346. private _buttonR1;
  42347. private _buttonLeftStick;
  42348. private _buttonRightStick;
  42349. private _dPadUp;
  42350. private _dPadDown;
  42351. private _dPadLeft;
  42352. private _dPadRight;
  42353. /**
  42354. * Creates a new DualShock gamepad object
  42355. * @param id defines the id of this gamepad
  42356. * @param index defines its index
  42357. * @param gamepad defines the internal HTML gamepad object
  42358. */
  42359. constructor(id: string, index: number, gamepad: any);
  42360. /**
  42361. * Defines the callback to call when left trigger is pressed
  42362. * @param callback defines the callback to use
  42363. */
  42364. onlefttriggerchanged(callback: (value: number) => void): void;
  42365. /**
  42366. * Defines the callback to call when right trigger is pressed
  42367. * @param callback defines the callback to use
  42368. */
  42369. onrighttriggerchanged(callback: (value: number) => void): void;
  42370. /**
  42371. * Gets the left trigger value
  42372. */
  42373. get leftTrigger(): number;
  42374. /**
  42375. * Sets the left trigger value
  42376. */
  42377. set leftTrigger(newValue: number);
  42378. /**
  42379. * Gets the right trigger value
  42380. */
  42381. get rightTrigger(): number;
  42382. /**
  42383. * Sets the right trigger value
  42384. */
  42385. set rightTrigger(newValue: number);
  42386. /**
  42387. * Defines the callback to call when a button is pressed
  42388. * @param callback defines the callback to use
  42389. */
  42390. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42391. /**
  42392. * Defines the callback to call when a button is released
  42393. * @param callback defines the callback to use
  42394. */
  42395. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42396. /**
  42397. * Defines the callback to call when a pad is pressed
  42398. * @param callback defines the callback to use
  42399. */
  42400. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42401. /**
  42402. * Defines the callback to call when a pad is released
  42403. * @param callback defines the callback to use
  42404. */
  42405. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42406. private _setButtonValue;
  42407. private _setDPadValue;
  42408. /**
  42409. * Gets the value of the `Cross` button
  42410. */
  42411. get buttonCross(): number;
  42412. /**
  42413. * Sets the value of the `Cross` button
  42414. */
  42415. set buttonCross(value: number);
  42416. /**
  42417. * Gets the value of the `Circle` button
  42418. */
  42419. get buttonCircle(): number;
  42420. /**
  42421. * Sets the value of the `Circle` button
  42422. */
  42423. set buttonCircle(value: number);
  42424. /**
  42425. * Gets the value of the `Square` button
  42426. */
  42427. get buttonSquare(): number;
  42428. /**
  42429. * Sets the value of the `Square` button
  42430. */
  42431. set buttonSquare(value: number);
  42432. /**
  42433. * Gets the value of the `Triangle` button
  42434. */
  42435. get buttonTriangle(): number;
  42436. /**
  42437. * Sets the value of the `Triangle` button
  42438. */
  42439. set buttonTriangle(value: number);
  42440. /**
  42441. * Gets the value of the `Options` button
  42442. */
  42443. get buttonOptions(): number;
  42444. /**
  42445. * Sets the value of the `Options` button
  42446. */
  42447. set buttonOptions(value: number);
  42448. /**
  42449. * Gets the value of the `Share` button
  42450. */
  42451. get buttonShare(): number;
  42452. /**
  42453. * Sets the value of the `Share` button
  42454. */
  42455. set buttonShare(value: number);
  42456. /**
  42457. * Gets the value of the `L1` button
  42458. */
  42459. get buttonL1(): number;
  42460. /**
  42461. * Sets the value of the `L1` button
  42462. */
  42463. set buttonL1(value: number);
  42464. /**
  42465. * Gets the value of the `R1` button
  42466. */
  42467. get buttonR1(): number;
  42468. /**
  42469. * Sets the value of the `R1` button
  42470. */
  42471. set buttonR1(value: number);
  42472. /**
  42473. * Gets the value of the Left joystick
  42474. */
  42475. get buttonLeftStick(): number;
  42476. /**
  42477. * Sets the value of the Left joystick
  42478. */
  42479. set buttonLeftStick(value: number);
  42480. /**
  42481. * Gets the value of the Right joystick
  42482. */
  42483. get buttonRightStick(): number;
  42484. /**
  42485. * Sets the value of the Right joystick
  42486. */
  42487. set buttonRightStick(value: number);
  42488. /**
  42489. * Gets the value of D-pad up
  42490. */
  42491. get dPadUp(): number;
  42492. /**
  42493. * Sets the value of D-pad up
  42494. */
  42495. set dPadUp(value: number);
  42496. /**
  42497. * Gets the value of D-pad down
  42498. */
  42499. get dPadDown(): number;
  42500. /**
  42501. * Sets the value of D-pad down
  42502. */
  42503. set dPadDown(value: number);
  42504. /**
  42505. * Gets the value of D-pad left
  42506. */
  42507. get dPadLeft(): number;
  42508. /**
  42509. * Sets the value of D-pad left
  42510. */
  42511. set dPadLeft(value: number);
  42512. /**
  42513. * Gets the value of D-pad right
  42514. */
  42515. get dPadRight(): number;
  42516. /**
  42517. * Sets the value of D-pad right
  42518. */
  42519. set dPadRight(value: number);
  42520. /**
  42521. * Force the gamepad to synchronize with device values
  42522. */
  42523. update(): void;
  42524. /**
  42525. * Disposes the gamepad
  42526. */
  42527. dispose(): void;
  42528. }
  42529. }
  42530. declare module "babylonjs/Gamepads/gamepadManager" {
  42531. import { Observable } from "babylonjs/Misc/observable";
  42532. import { Nullable } from "babylonjs/types";
  42533. import { Scene } from "babylonjs/scene";
  42534. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42535. /**
  42536. * Manager for handling gamepads
  42537. */
  42538. export class GamepadManager {
  42539. private _scene?;
  42540. private _babylonGamepads;
  42541. private _oneGamepadConnected;
  42542. /** @hidden */
  42543. _isMonitoring: boolean;
  42544. private _gamepadEventSupported;
  42545. private _gamepadSupport?;
  42546. /**
  42547. * observable to be triggered when the gamepad controller has been connected
  42548. */
  42549. onGamepadConnectedObservable: Observable<Gamepad>;
  42550. /**
  42551. * observable to be triggered when the gamepad controller has been disconnected
  42552. */
  42553. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42554. private _onGamepadConnectedEvent;
  42555. private _onGamepadDisconnectedEvent;
  42556. /**
  42557. * Initializes the gamepad manager
  42558. * @param _scene BabylonJS scene
  42559. */
  42560. constructor(_scene?: Scene | undefined);
  42561. /**
  42562. * The gamepads in the game pad manager
  42563. */
  42564. get gamepads(): Gamepad[];
  42565. /**
  42566. * Get the gamepad controllers based on type
  42567. * @param type The type of gamepad controller
  42568. * @returns Nullable gamepad
  42569. */
  42570. getGamepadByType(type?: number): Nullable<Gamepad>;
  42571. /**
  42572. * Disposes the gamepad manager
  42573. */
  42574. dispose(): void;
  42575. private _addNewGamepad;
  42576. private _startMonitoringGamepads;
  42577. private _stopMonitoringGamepads;
  42578. /** @hidden */
  42579. _checkGamepadsStatus(): void;
  42580. private _updateGamepadObjects;
  42581. }
  42582. }
  42583. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42584. import { Nullable } from "babylonjs/types";
  42585. import { Scene } from "babylonjs/scene";
  42586. import { ISceneComponent } from "babylonjs/sceneComponent";
  42587. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42588. module "babylonjs/scene" {
  42589. interface Scene {
  42590. /** @hidden */
  42591. _gamepadManager: Nullable<GamepadManager>;
  42592. /**
  42593. * Gets the gamepad manager associated with the scene
  42594. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42595. */
  42596. gamepadManager: GamepadManager;
  42597. }
  42598. }
  42599. module "babylonjs/Cameras/freeCameraInputsManager" {
  42600. /**
  42601. * Interface representing a free camera inputs manager
  42602. */
  42603. interface FreeCameraInputsManager {
  42604. /**
  42605. * Adds gamepad input support to the FreeCameraInputsManager.
  42606. * @returns the FreeCameraInputsManager
  42607. */
  42608. addGamepad(): FreeCameraInputsManager;
  42609. }
  42610. }
  42611. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42612. /**
  42613. * Interface representing an arc rotate camera inputs manager
  42614. */
  42615. interface ArcRotateCameraInputsManager {
  42616. /**
  42617. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42618. * @returns the camera inputs manager
  42619. */
  42620. addGamepad(): ArcRotateCameraInputsManager;
  42621. }
  42622. }
  42623. /**
  42624. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42625. */
  42626. export class GamepadSystemSceneComponent implements ISceneComponent {
  42627. /**
  42628. * The component name helpfull to identify the component in the list of scene components.
  42629. */
  42630. readonly name: string;
  42631. /**
  42632. * The scene the component belongs to.
  42633. */
  42634. scene: Scene;
  42635. /**
  42636. * Creates a new instance of the component for the given scene
  42637. * @param scene Defines the scene to register the component in
  42638. */
  42639. constructor(scene: Scene);
  42640. /**
  42641. * Registers the component in a given scene
  42642. */
  42643. register(): void;
  42644. /**
  42645. * Rebuilds the elements related to this component in case of
  42646. * context lost for instance.
  42647. */
  42648. rebuild(): void;
  42649. /**
  42650. * Disposes the component and the associated ressources
  42651. */
  42652. dispose(): void;
  42653. private _beforeCameraUpdate;
  42654. }
  42655. }
  42656. declare module "babylonjs/Cameras/universalCamera" {
  42657. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42658. import { Scene } from "babylonjs/scene";
  42659. import { Vector3 } from "babylonjs/Maths/math.vector";
  42660. import "babylonjs/Gamepads/gamepadSceneComponent";
  42661. /**
  42662. * 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,
  42663. * which still works and will still be found in many Playgrounds.
  42664. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42665. */
  42666. export class UniversalCamera extends TouchCamera {
  42667. /**
  42668. * Defines the gamepad rotation sensiblity.
  42669. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42670. */
  42671. get gamepadAngularSensibility(): number;
  42672. set gamepadAngularSensibility(value: number);
  42673. /**
  42674. * Defines the gamepad move sensiblity.
  42675. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42676. */
  42677. get gamepadMoveSensibility(): number;
  42678. set gamepadMoveSensibility(value: number);
  42679. /**
  42680. * 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,
  42681. * which still works and will still be found in many Playgrounds.
  42682. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42683. * @param name Define the name of the camera in the scene
  42684. * @param position Define the start position of the camera in the scene
  42685. * @param scene Define the scene the camera belongs to
  42686. */
  42687. constructor(name: string, position: Vector3, scene: Scene);
  42688. /**
  42689. * Gets the current object class name.
  42690. * @return the class name
  42691. */
  42692. getClassName(): string;
  42693. }
  42694. }
  42695. declare module "babylonjs/Cameras/gamepadCamera" {
  42696. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42697. import { Scene } from "babylonjs/scene";
  42698. import { Vector3 } from "babylonjs/Maths/math.vector";
  42699. /**
  42700. * This represents a FPS type of camera. This is only here for back compat purpose.
  42701. * Please use the UniversalCamera instead as both are identical.
  42702. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42703. */
  42704. export class GamepadCamera extends UniversalCamera {
  42705. /**
  42706. * Instantiates a new Gamepad Camera
  42707. * This represents a FPS type of camera. This is only here for back compat purpose.
  42708. * Please use the UniversalCamera instead as both are identical.
  42709. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42710. * @param name Define the name of the camera in the scene
  42711. * @param position Define the start position of the camera in the scene
  42712. * @param scene Define the scene the camera belongs to
  42713. */
  42714. constructor(name: string, position: Vector3, scene: Scene);
  42715. /**
  42716. * Gets the current object class name.
  42717. * @return the class name
  42718. */
  42719. getClassName(): string;
  42720. }
  42721. }
  42722. declare module "babylonjs/Shaders/pass.fragment" {
  42723. /** @hidden */
  42724. export var passPixelShader: {
  42725. name: string;
  42726. shader: string;
  42727. };
  42728. }
  42729. declare module "babylonjs/Shaders/passCube.fragment" {
  42730. /** @hidden */
  42731. export var passCubePixelShader: {
  42732. name: string;
  42733. shader: string;
  42734. };
  42735. }
  42736. declare module "babylonjs/PostProcesses/passPostProcess" {
  42737. import { Nullable } from "babylonjs/types";
  42738. import { Camera } from "babylonjs/Cameras/camera";
  42739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42740. import { Engine } from "babylonjs/Engines/engine";
  42741. import "babylonjs/Shaders/pass.fragment";
  42742. import "babylonjs/Shaders/passCube.fragment";
  42743. /**
  42744. * PassPostProcess which produces an output the same as it's input
  42745. */
  42746. export class PassPostProcess extends PostProcess {
  42747. /**
  42748. * Creates the PassPostProcess
  42749. * @param name The name of the effect.
  42750. * @param options The required width/height ratio to downsize to before computing the render pass.
  42751. * @param camera The camera to apply the render pass to.
  42752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42753. * @param engine The engine which the post process will be applied. (default: current engine)
  42754. * @param reusable If the post process can be reused on the same frame. (default: false)
  42755. * @param textureType The type of texture to be used when performing the post processing.
  42756. * @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)
  42757. */
  42758. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42759. }
  42760. /**
  42761. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42762. */
  42763. export class PassCubePostProcess extends PostProcess {
  42764. private _face;
  42765. /**
  42766. * Gets or sets the cube face to display.
  42767. * * 0 is +X
  42768. * * 1 is -X
  42769. * * 2 is +Y
  42770. * * 3 is -Y
  42771. * * 4 is +Z
  42772. * * 5 is -Z
  42773. */
  42774. get face(): number;
  42775. set face(value: number);
  42776. /**
  42777. * Creates the PassCubePostProcess
  42778. * @param name The name of the effect.
  42779. * @param options The required width/height ratio to downsize to before computing the render pass.
  42780. * @param camera The camera to apply the render pass to.
  42781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42782. * @param engine The engine which the post process will be applied. (default: current engine)
  42783. * @param reusable If the post process can be reused on the same frame. (default: false)
  42784. * @param textureType The type of texture to be used when performing the post processing.
  42785. * @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)
  42786. */
  42787. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42788. }
  42789. }
  42790. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42791. /** @hidden */
  42792. export var anaglyphPixelShader: {
  42793. name: string;
  42794. shader: string;
  42795. };
  42796. }
  42797. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42798. import { Engine } from "babylonjs/Engines/engine";
  42799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42800. import { Camera } from "babylonjs/Cameras/camera";
  42801. import "babylonjs/Shaders/anaglyph.fragment";
  42802. /**
  42803. * Postprocess used to generate anaglyphic rendering
  42804. */
  42805. export class AnaglyphPostProcess extends PostProcess {
  42806. private _passedProcess;
  42807. /**
  42808. * Creates a new AnaglyphPostProcess
  42809. * @param name defines postprocess name
  42810. * @param options defines creation options or target ratio scale
  42811. * @param rigCameras defines cameras using this postprocess
  42812. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42813. * @param engine defines hosting engine
  42814. * @param reusable defines if the postprocess will be reused multiple times per frame
  42815. */
  42816. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42817. }
  42818. }
  42819. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42820. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42821. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42822. import { Scene } from "babylonjs/scene";
  42823. import { Vector3 } from "babylonjs/Maths/math.vector";
  42824. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42825. /**
  42826. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42827. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42828. */
  42829. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42830. /**
  42831. * Creates a new AnaglyphArcRotateCamera
  42832. * @param name defines camera name
  42833. * @param alpha defines alpha angle (in radians)
  42834. * @param beta defines beta angle (in radians)
  42835. * @param radius defines radius
  42836. * @param target defines camera target
  42837. * @param interaxialDistance defines distance between each color axis
  42838. * @param scene defines the hosting scene
  42839. */
  42840. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42841. /**
  42842. * Gets camera class name
  42843. * @returns AnaglyphArcRotateCamera
  42844. */
  42845. getClassName(): string;
  42846. }
  42847. }
  42848. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42849. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42850. import { Scene } from "babylonjs/scene";
  42851. import { Vector3 } from "babylonjs/Maths/math.vector";
  42852. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42853. /**
  42854. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42855. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42856. */
  42857. export class AnaglyphFreeCamera extends FreeCamera {
  42858. /**
  42859. * Creates a new AnaglyphFreeCamera
  42860. * @param name defines camera name
  42861. * @param position defines initial position
  42862. * @param interaxialDistance defines distance between each color axis
  42863. * @param scene defines the hosting scene
  42864. */
  42865. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42866. /**
  42867. * Gets camera class name
  42868. * @returns AnaglyphFreeCamera
  42869. */
  42870. getClassName(): string;
  42871. }
  42872. }
  42873. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42874. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42875. import { Scene } from "babylonjs/scene";
  42876. import { Vector3 } from "babylonjs/Maths/math.vector";
  42877. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42878. /**
  42879. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42880. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42881. */
  42882. export class AnaglyphGamepadCamera extends GamepadCamera {
  42883. /**
  42884. * Creates a new AnaglyphGamepadCamera
  42885. * @param name defines camera name
  42886. * @param position defines initial position
  42887. * @param interaxialDistance defines distance between each color axis
  42888. * @param scene defines the hosting scene
  42889. */
  42890. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42891. /**
  42892. * Gets camera class name
  42893. * @returns AnaglyphGamepadCamera
  42894. */
  42895. getClassName(): string;
  42896. }
  42897. }
  42898. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42899. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42900. import { Scene } from "babylonjs/scene";
  42901. import { Vector3 } from "babylonjs/Maths/math.vector";
  42902. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42903. /**
  42904. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42905. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42906. */
  42907. export class AnaglyphUniversalCamera extends UniversalCamera {
  42908. /**
  42909. * Creates a new AnaglyphUniversalCamera
  42910. * @param name defines camera name
  42911. * @param position defines initial position
  42912. * @param interaxialDistance defines distance between each color axis
  42913. * @param scene defines the hosting scene
  42914. */
  42915. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42916. /**
  42917. * Gets camera class name
  42918. * @returns AnaglyphUniversalCamera
  42919. */
  42920. getClassName(): string;
  42921. }
  42922. }
  42923. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42924. /** @hidden */
  42925. export var stereoscopicInterlacePixelShader: {
  42926. name: string;
  42927. shader: string;
  42928. };
  42929. }
  42930. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42931. import { Camera } from "babylonjs/Cameras/camera";
  42932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42933. import { Engine } from "babylonjs/Engines/engine";
  42934. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42935. /**
  42936. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42937. */
  42938. export class StereoscopicInterlacePostProcess extends PostProcess {
  42939. private _stepSize;
  42940. private _passedProcess;
  42941. /**
  42942. * Initializes a StereoscopicInterlacePostProcess
  42943. * @param name The name of the effect.
  42944. * @param rigCameras The rig cameras to be appled to the post process
  42945. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42947. * @param engine The engine which the post process will be applied. (default: current engine)
  42948. * @param reusable If the post process can be reused on the same frame. (default: false)
  42949. */
  42950. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42951. }
  42952. }
  42953. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42954. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42955. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42956. import { Scene } from "babylonjs/scene";
  42957. import { Vector3 } from "babylonjs/Maths/math.vector";
  42958. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42959. /**
  42960. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42961. * @see http://doc.babylonjs.com/features/cameras
  42962. */
  42963. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42964. /**
  42965. * Creates a new StereoscopicArcRotateCamera
  42966. * @param name defines camera name
  42967. * @param alpha defines alpha angle (in radians)
  42968. * @param beta defines beta angle (in radians)
  42969. * @param radius defines radius
  42970. * @param target defines camera target
  42971. * @param interaxialDistance defines distance between each color axis
  42972. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42973. * @param scene defines the hosting scene
  42974. */
  42975. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42976. /**
  42977. * Gets camera class name
  42978. * @returns StereoscopicArcRotateCamera
  42979. */
  42980. getClassName(): string;
  42981. }
  42982. }
  42983. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42984. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42985. import { Scene } from "babylonjs/scene";
  42986. import { Vector3 } from "babylonjs/Maths/math.vector";
  42987. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42988. /**
  42989. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42990. * @see http://doc.babylonjs.com/features/cameras
  42991. */
  42992. export class StereoscopicFreeCamera extends FreeCamera {
  42993. /**
  42994. * Creates a new StereoscopicFreeCamera
  42995. * @param name defines camera name
  42996. * @param position defines initial position
  42997. * @param interaxialDistance defines distance between each color axis
  42998. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42999. * @param scene defines the hosting scene
  43000. */
  43001. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43002. /**
  43003. * Gets camera class name
  43004. * @returns StereoscopicFreeCamera
  43005. */
  43006. getClassName(): string;
  43007. }
  43008. }
  43009. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43010. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43011. import { Scene } from "babylonjs/scene";
  43012. import { Vector3 } from "babylonjs/Maths/math.vector";
  43013. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43014. /**
  43015. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43016. * @see http://doc.babylonjs.com/features/cameras
  43017. */
  43018. export class StereoscopicGamepadCamera extends GamepadCamera {
  43019. /**
  43020. * Creates a new StereoscopicGamepadCamera
  43021. * @param name defines camera name
  43022. * @param position defines initial position
  43023. * @param interaxialDistance defines distance between each color axis
  43024. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43025. * @param scene defines the hosting scene
  43026. */
  43027. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43028. /**
  43029. * Gets camera class name
  43030. * @returns StereoscopicGamepadCamera
  43031. */
  43032. getClassName(): string;
  43033. }
  43034. }
  43035. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43036. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43037. import { Scene } from "babylonjs/scene";
  43038. import { Vector3 } from "babylonjs/Maths/math.vector";
  43039. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43040. /**
  43041. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43042. * @see http://doc.babylonjs.com/features/cameras
  43043. */
  43044. export class StereoscopicUniversalCamera extends UniversalCamera {
  43045. /**
  43046. * Creates a new StereoscopicUniversalCamera
  43047. * @param name defines camera name
  43048. * @param position defines initial position
  43049. * @param interaxialDistance defines distance between each color axis
  43050. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43051. * @param scene defines the hosting scene
  43052. */
  43053. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43054. /**
  43055. * Gets camera class name
  43056. * @returns StereoscopicUniversalCamera
  43057. */
  43058. getClassName(): string;
  43059. }
  43060. }
  43061. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43062. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43063. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43064. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43065. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43066. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43067. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43068. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43069. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43070. }
  43071. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43072. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43073. import { Scene } from "babylonjs/scene";
  43074. import { Vector3 } from "babylonjs/Maths/math.vector";
  43075. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43076. /**
  43077. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43078. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43079. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43080. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43081. */
  43082. export class VirtualJoysticksCamera extends FreeCamera {
  43083. /**
  43084. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43085. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43086. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43087. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43088. * @param name Define the name of the camera in the scene
  43089. * @param position Define the start position of the camera in the scene
  43090. * @param scene Define the scene the camera belongs to
  43091. */
  43092. constructor(name: string, position: Vector3, scene: Scene);
  43093. /**
  43094. * Gets the current object class name.
  43095. * @return the class name
  43096. */
  43097. getClassName(): string;
  43098. }
  43099. }
  43100. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43101. import { Matrix } from "babylonjs/Maths/math.vector";
  43102. /**
  43103. * This represents all the required metrics to create a VR camera.
  43104. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43105. */
  43106. export class VRCameraMetrics {
  43107. /**
  43108. * Define the horizontal resolution off the screen.
  43109. */
  43110. hResolution: number;
  43111. /**
  43112. * Define the vertical resolution off the screen.
  43113. */
  43114. vResolution: number;
  43115. /**
  43116. * Define the horizontal screen size.
  43117. */
  43118. hScreenSize: number;
  43119. /**
  43120. * Define the vertical screen size.
  43121. */
  43122. vScreenSize: number;
  43123. /**
  43124. * Define the vertical screen center position.
  43125. */
  43126. vScreenCenter: number;
  43127. /**
  43128. * Define the distance of the eyes to the screen.
  43129. */
  43130. eyeToScreenDistance: number;
  43131. /**
  43132. * Define the distance between both lenses
  43133. */
  43134. lensSeparationDistance: number;
  43135. /**
  43136. * Define the distance between both viewer's eyes.
  43137. */
  43138. interpupillaryDistance: number;
  43139. /**
  43140. * Define the distortion factor of the VR postprocess.
  43141. * Please, touch with care.
  43142. */
  43143. distortionK: number[];
  43144. /**
  43145. * Define the chromatic aberration correction factors for the VR post process.
  43146. */
  43147. chromaAbCorrection: number[];
  43148. /**
  43149. * Define the scale factor of the post process.
  43150. * The smaller the better but the slower.
  43151. */
  43152. postProcessScaleFactor: number;
  43153. /**
  43154. * Define an offset for the lens center.
  43155. */
  43156. lensCenterOffset: number;
  43157. /**
  43158. * Define if the current vr camera should compensate the distortion of the lense or not.
  43159. */
  43160. compensateDistortion: boolean;
  43161. /**
  43162. * Defines if multiview should be enabled when rendering (Default: false)
  43163. */
  43164. multiviewEnabled: boolean;
  43165. /**
  43166. * Gets the rendering aspect ratio based on the provided resolutions.
  43167. */
  43168. get aspectRatio(): number;
  43169. /**
  43170. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43171. */
  43172. get aspectRatioFov(): number;
  43173. /**
  43174. * @hidden
  43175. */
  43176. get leftHMatrix(): Matrix;
  43177. /**
  43178. * @hidden
  43179. */
  43180. get rightHMatrix(): Matrix;
  43181. /**
  43182. * @hidden
  43183. */
  43184. get leftPreViewMatrix(): Matrix;
  43185. /**
  43186. * @hidden
  43187. */
  43188. get rightPreViewMatrix(): Matrix;
  43189. /**
  43190. * Get the default VRMetrics based on the most generic setup.
  43191. * @returns the default vr metrics
  43192. */
  43193. static GetDefault(): VRCameraMetrics;
  43194. }
  43195. }
  43196. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43197. /** @hidden */
  43198. export var vrDistortionCorrectionPixelShader: {
  43199. name: string;
  43200. shader: string;
  43201. };
  43202. }
  43203. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43204. import { Camera } from "babylonjs/Cameras/camera";
  43205. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43206. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43207. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43208. /**
  43209. * VRDistortionCorrectionPostProcess used for mobile VR
  43210. */
  43211. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43212. private _isRightEye;
  43213. private _distortionFactors;
  43214. private _postProcessScaleFactor;
  43215. private _lensCenterOffset;
  43216. private _scaleIn;
  43217. private _scaleFactor;
  43218. private _lensCenter;
  43219. /**
  43220. * Initializes the VRDistortionCorrectionPostProcess
  43221. * @param name The name of the effect.
  43222. * @param camera The camera to apply the render pass to.
  43223. * @param isRightEye If this is for the right eye distortion
  43224. * @param vrMetrics All the required metrics for the VR camera
  43225. */
  43226. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43227. }
  43228. }
  43229. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43230. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43232. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43233. import { Scene } from "babylonjs/scene";
  43234. import { Vector3 } from "babylonjs/Maths/math.vector";
  43235. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43236. import "babylonjs/Cameras/RigModes/vrRigMode";
  43237. /**
  43238. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43239. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43240. */
  43241. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43242. /**
  43243. * Creates a new VRDeviceOrientationArcRotateCamera
  43244. * @param name defines camera name
  43245. * @param alpha defines the camera rotation along the logitudinal axis
  43246. * @param beta defines the camera rotation along the latitudinal axis
  43247. * @param radius defines the camera distance from its target
  43248. * @param target defines the camera target
  43249. * @param scene defines the scene the camera belongs to
  43250. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43251. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43252. */
  43253. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43254. /**
  43255. * Gets camera class name
  43256. * @returns VRDeviceOrientationArcRotateCamera
  43257. */
  43258. getClassName(): string;
  43259. }
  43260. }
  43261. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43262. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43263. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43264. import { Scene } from "babylonjs/scene";
  43265. import { Vector3 } from "babylonjs/Maths/math.vector";
  43266. import "babylonjs/Cameras/RigModes/vrRigMode";
  43267. /**
  43268. * Camera used to simulate VR rendering (based on FreeCamera)
  43269. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43270. */
  43271. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43272. /**
  43273. * Creates a new VRDeviceOrientationFreeCamera
  43274. * @param name defines camera name
  43275. * @param position defines the start position of the camera
  43276. * @param scene defines the scene the camera belongs to
  43277. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43278. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43279. */
  43280. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43281. /**
  43282. * Gets camera class name
  43283. * @returns VRDeviceOrientationFreeCamera
  43284. */
  43285. getClassName(): string;
  43286. }
  43287. }
  43288. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43289. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43290. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43291. import { Scene } from "babylonjs/scene";
  43292. import { Vector3 } from "babylonjs/Maths/math.vector";
  43293. import "babylonjs/Gamepads/gamepadSceneComponent";
  43294. /**
  43295. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43296. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43297. */
  43298. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43299. /**
  43300. * Creates a new VRDeviceOrientationGamepadCamera
  43301. * @param name defines camera name
  43302. * @param position defines the start position of the camera
  43303. * @param scene defines the scene the camera belongs to
  43304. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43305. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43306. */
  43307. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43308. /**
  43309. * Gets camera class name
  43310. * @returns VRDeviceOrientationGamepadCamera
  43311. */
  43312. getClassName(): string;
  43313. }
  43314. }
  43315. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43316. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43317. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43318. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43319. /** @hidden */
  43320. export var imageProcessingPixelShader: {
  43321. name: string;
  43322. shader: string;
  43323. };
  43324. }
  43325. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43326. import { Nullable } from "babylonjs/types";
  43327. import { Color4 } from "babylonjs/Maths/math.color";
  43328. import { Camera } from "babylonjs/Cameras/camera";
  43329. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43330. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43331. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43332. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43333. import { Engine } from "babylonjs/Engines/engine";
  43334. import "babylonjs/Shaders/imageProcessing.fragment";
  43335. import "babylonjs/Shaders/postprocess.vertex";
  43336. /**
  43337. * ImageProcessingPostProcess
  43338. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43339. */
  43340. export class ImageProcessingPostProcess extends PostProcess {
  43341. /**
  43342. * Default configuration related to image processing available in the PBR Material.
  43343. */
  43344. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43345. /**
  43346. * Gets the image processing configuration used either in this material.
  43347. */
  43348. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43349. /**
  43350. * Sets the Default image processing configuration used either in the this material.
  43351. *
  43352. * If sets to null, the scene one is in use.
  43353. */
  43354. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43355. /**
  43356. * Keep track of the image processing observer to allow dispose and replace.
  43357. */
  43358. private _imageProcessingObserver;
  43359. /**
  43360. * Attaches a new image processing configuration to the PBR Material.
  43361. * @param configuration
  43362. */
  43363. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43364. /**
  43365. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43366. */
  43367. get colorCurves(): Nullable<ColorCurves>;
  43368. /**
  43369. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43370. */
  43371. set colorCurves(value: Nullable<ColorCurves>);
  43372. /**
  43373. * Gets wether the color curves effect is enabled.
  43374. */
  43375. get colorCurvesEnabled(): boolean;
  43376. /**
  43377. * Sets wether the color curves effect is enabled.
  43378. */
  43379. set colorCurvesEnabled(value: boolean);
  43380. /**
  43381. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43382. */
  43383. get colorGradingTexture(): Nullable<BaseTexture>;
  43384. /**
  43385. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43386. */
  43387. set colorGradingTexture(value: Nullable<BaseTexture>);
  43388. /**
  43389. * Gets wether the color grading effect is enabled.
  43390. */
  43391. get colorGradingEnabled(): boolean;
  43392. /**
  43393. * Gets wether the color grading effect is enabled.
  43394. */
  43395. set colorGradingEnabled(value: boolean);
  43396. /**
  43397. * Gets exposure used in the effect.
  43398. */
  43399. get exposure(): number;
  43400. /**
  43401. * Sets exposure used in the effect.
  43402. */
  43403. set exposure(value: number);
  43404. /**
  43405. * Gets wether tonemapping is enabled or not.
  43406. */
  43407. get toneMappingEnabled(): boolean;
  43408. /**
  43409. * Sets wether tonemapping is enabled or not
  43410. */
  43411. set toneMappingEnabled(value: boolean);
  43412. /**
  43413. * Gets the type of tone mapping effect.
  43414. */
  43415. get toneMappingType(): number;
  43416. /**
  43417. * Sets the type of tone mapping effect.
  43418. */
  43419. set toneMappingType(value: number);
  43420. /**
  43421. * Gets contrast used in the effect.
  43422. */
  43423. get contrast(): number;
  43424. /**
  43425. * Sets contrast used in the effect.
  43426. */
  43427. set contrast(value: number);
  43428. /**
  43429. * Gets Vignette stretch size.
  43430. */
  43431. get vignetteStretch(): number;
  43432. /**
  43433. * Sets Vignette stretch size.
  43434. */
  43435. set vignetteStretch(value: number);
  43436. /**
  43437. * Gets Vignette centre X Offset.
  43438. */
  43439. get vignetteCentreX(): number;
  43440. /**
  43441. * Sets Vignette centre X Offset.
  43442. */
  43443. set vignetteCentreX(value: number);
  43444. /**
  43445. * Gets Vignette centre Y Offset.
  43446. */
  43447. get vignetteCentreY(): number;
  43448. /**
  43449. * Sets Vignette centre Y Offset.
  43450. */
  43451. set vignetteCentreY(value: number);
  43452. /**
  43453. * Gets Vignette weight or intensity of the vignette effect.
  43454. */
  43455. get vignetteWeight(): number;
  43456. /**
  43457. * Sets Vignette weight or intensity of the vignette effect.
  43458. */
  43459. set vignetteWeight(value: number);
  43460. /**
  43461. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43462. * if vignetteEnabled is set to true.
  43463. */
  43464. get vignetteColor(): Color4;
  43465. /**
  43466. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43467. * if vignetteEnabled is set to true.
  43468. */
  43469. set vignetteColor(value: Color4);
  43470. /**
  43471. * Gets Camera field of view used by the Vignette effect.
  43472. */
  43473. get vignetteCameraFov(): number;
  43474. /**
  43475. * Sets Camera field of view used by the Vignette effect.
  43476. */
  43477. set vignetteCameraFov(value: number);
  43478. /**
  43479. * Gets the vignette blend mode allowing different kind of effect.
  43480. */
  43481. get vignetteBlendMode(): number;
  43482. /**
  43483. * Sets the vignette blend mode allowing different kind of effect.
  43484. */
  43485. set vignetteBlendMode(value: number);
  43486. /**
  43487. * Gets wether the vignette effect is enabled.
  43488. */
  43489. get vignetteEnabled(): boolean;
  43490. /**
  43491. * Sets wether the vignette effect is enabled.
  43492. */
  43493. set vignetteEnabled(value: boolean);
  43494. private _fromLinearSpace;
  43495. /**
  43496. * Gets wether the input of the processing is in Gamma or Linear Space.
  43497. */
  43498. get fromLinearSpace(): boolean;
  43499. /**
  43500. * Sets wether the input of the processing is in Gamma or Linear Space.
  43501. */
  43502. set fromLinearSpace(value: boolean);
  43503. /**
  43504. * Defines cache preventing GC.
  43505. */
  43506. private _defines;
  43507. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43508. /**
  43509. * "ImageProcessingPostProcess"
  43510. * @returns "ImageProcessingPostProcess"
  43511. */
  43512. getClassName(): string;
  43513. protected _updateParameters(): void;
  43514. dispose(camera?: Camera): void;
  43515. }
  43516. }
  43517. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43518. import { Scene } from "babylonjs/scene";
  43519. import { Color3 } from "babylonjs/Maths/math.color";
  43520. import { Mesh } from "babylonjs/Meshes/mesh";
  43521. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43522. import { Nullable } from "babylonjs/types";
  43523. /**
  43524. * Class containing static functions to help procedurally build meshes
  43525. */
  43526. export class GroundBuilder {
  43527. /**
  43528. * Creates a ground mesh
  43529. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43530. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43532. * @param name defines the name of the mesh
  43533. * @param options defines the options used to create the mesh
  43534. * @param scene defines the hosting scene
  43535. * @returns the ground mesh
  43536. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43537. */
  43538. static CreateGround(name: string, options: {
  43539. width?: number;
  43540. height?: number;
  43541. subdivisions?: number;
  43542. subdivisionsX?: number;
  43543. subdivisionsY?: number;
  43544. updatable?: boolean;
  43545. }, scene: any): Mesh;
  43546. /**
  43547. * Creates a tiled ground mesh
  43548. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43549. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43550. * * 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
  43551. * * 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
  43552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43553. * @param name defines the name of the mesh
  43554. * @param options defines the options used to create the mesh
  43555. * @param scene defines the hosting scene
  43556. * @returns the tiled ground mesh
  43557. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43558. */
  43559. static CreateTiledGround(name: string, options: {
  43560. xmin: number;
  43561. zmin: number;
  43562. xmax: number;
  43563. zmax: number;
  43564. subdivisions?: {
  43565. w: number;
  43566. h: number;
  43567. };
  43568. precision?: {
  43569. w: number;
  43570. h: number;
  43571. };
  43572. updatable?: boolean;
  43573. }, scene?: Nullable<Scene>): Mesh;
  43574. /**
  43575. * Creates a ground mesh from a height map
  43576. * * The parameter `url` sets the URL of the height map image resource.
  43577. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43578. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43579. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43580. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43581. * * 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.
  43582. * * 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).
  43583. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43585. * @param name defines the name of the mesh
  43586. * @param url defines the url to the height map
  43587. * @param options defines the options used to create the mesh
  43588. * @param scene defines the hosting scene
  43589. * @returns the ground mesh
  43590. * @see https://doc.babylonjs.com/babylon101/height_map
  43591. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43592. */
  43593. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43594. width?: number;
  43595. height?: number;
  43596. subdivisions?: number;
  43597. minHeight?: number;
  43598. maxHeight?: number;
  43599. colorFilter?: Color3;
  43600. alphaFilter?: number;
  43601. updatable?: boolean;
  43602. onReady?: (mesh: GroundMesh) => void;
  43603. }, scene?: Nullable<Scene>): GroundMesh;
  43604. }
  43605. }
  43606. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43607. import { Vector4 } from "babylonjs/Maths/math.vector";
  43608. import { Mesh } from "babylonjs/Meshes/mesh";
  43609. /**
  43610. * Class containing static functions to help procedurally build meshes
  43611. */
  43612. export class TorusBuilder {
  43613. /**
  43614. * Creates a torus mesh
  43615. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43616. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43617. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43621. * @param name defines the name of the mesh
  43622. * @param options defines the options used to create the mesh
  43623. * @param scene defines the hosting scene
  43624. * @returns the torus mesh
  43625. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43626. */
  43627. static CreateTorus(name: string, options: {
  43628. diameter?: number;
  43629. thickness?: number;
  43630. tessellation?: number;
  43631. updatable?: boolean;
  43632. sideOrientation?: number;
  43633. frontUVs?: Vector4;
  43634. backUVs?: Vector4;
  43635. }, scene: any): Mesh;
  43636. }
  43637. }
  43638. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43639. import { Vector4 } from "babylonjs/Maths/math.vector";
  43640. import { Color4 } from "babylonjs/Maths/math.color";
  43641. import { Mesh } from "babylonjs/Meshes/mesh";
  43642. /**
  43643. * Class containing static functions to help procedurally build meshes
  43644. */
  43645. export class CylinderBuilder {
  43646. /**
  43647. * Creates a cylinder or a cone mesh
  43648. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43649. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43650. * * 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.
  43651. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43652. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43653. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43654. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43655. * * 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).
  43656. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43657. * * 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).
  43658. * * 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
  43659. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43660. * * 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
  43661. * * 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.
  43662. * * If `enclose` is false, a ring surface is one element.
  43663. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43664. * * 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
  43665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43668. * @param name defines the name of the mesh
  43669. * @param options defines the options used to create the mesh
  43670. * @param scene defines the hosting scene
  43671. * @returns the cylinder mesh
  43672. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43673. */
  43674. static CreateCylinder(name: string, options: {
  43675. height?: number;
  43676. diameterTop?: number;
  43677. diameterBottom?: number;
  43678. diameter?: number;
  43679. tessellation?: number;
  43680. subdivisions?: number;
  43681. arc?: number;
  43682. faceColors?: Color4[];
  43683. faceUV?: Vector4[];
  43684. updatable?: boolean;
  43685. hasRings?: boolean;
  43686. enclose?: boolean;
  43687. cap?: number;
  43688. sideOrientation?: number;
  43689. frontUVs?: Vector4;
  43690. backUVs?: Vector4;
  43691. }, scene: any): Mesh;
  43692. }
  43693. }
  43694. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43695. import { Nullable } from "babylonjs/types";
  43696. import { IDisposable } from "babylonjs/scene";
  43697. /**
  43698. * States of the webXR experience
  43699. */
  43700. export enum WebXRState {
  43701. /**
  43702. * Transitioning to being in XR mode
  43703. */
  43704. ENTERING_XR = 0,
  43705. /**
  43706. * Transitioning to non XR mode
  43707. */
  43708. EXITING_XR = 1,
  43709. /**
  43710. * In XR mode and presenting
  43711. */
  43712. IN_XR = 2,
  43713. /**
  43714. * Not entered XR mode
  43715. */
  43716. NOT_IN_XR = 3
  43717. }
  43718. /**
  43719. * Abstraction of the XR render target
  43720. */
  43721. export interface WebXRRenderTarget extends IDisposable {
  43722. /**
  43723. * xrpresent context of the canvas which can be used to display/mirror xr content
  43724. */
  43725. canvasContext: WebGLRenderingContext;
  43726. /**
  43727. * xr layer for the canvas
  43728. */
  43729. xrLayer: Nullable<XRWebGLLayer>;
  43730. /**
  43731. * Initializes the xr layer for the session
  43732. * @param xrSession xr session
  43733. * @returns a promise that will resolve once the XR Layer has been created
  43734. */
  43735. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43736. }
  43737. }
  43738. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43739. import { Nullable } from "babylonjs/types";
  43740. import { Observable } from "babylonjs/Misc/observable";
  43741. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43742. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43743. /**
  43744. * COnfiguration object for WebXR output canvas
  43745. */
  43746. export class WebXRManagedOutputCanvasOptions {
  43747. /**
  43748. * Options for this XR Layer output
  43749. */
  43750. canvasOptions: XRWebGLLayerOptions;
  43751. /**
  43752. * CSS styling for a newly created canvas (if not provided)
  43753. */
  43754. newCanvasCssStyle?: string;
  43755. /**
  43756. * Get the default values of the configuration object
  43757. * @returns default values of this configuration object
  43758. */
  43759. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43760. }
  43761. /**
  43762. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43763. */
  43764. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43765. private configuration;
  43766. private _engine;
  43767. private _canvas;
  43768. /**
  43769. * xrpresent context of the canvas which can be used to display/mirror xr content
  43770. */
  43771. canvasContext: WebGLRenderingContext;
  43772. /**
  43773. * xr layer for the canvas
  43774. */
  43775. xrLayer: Nullable<XRWebGLLayer>;
  43776. /**
  43777. * Initializes the xr layer for the session
  43778. * @param xrSession xr session
  43779. * @returns a promise that will resolve once the XR Layer has been created
  43780. */
  43781. initializeXRLayerAsync(xrSession: any): any;
  43782. /**
  43783. * Initializes the canvas to be added/removed upon entering/exiting xr
  43784. * @param engine the Babylon engine
  43785. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43786. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43787. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43788. */
  43789. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43790. /**
  43791. * Disposes of the object
  43792. */
  43793. dispose(): void;
  43794. private _setManagedOutputCanvas;
  43795. private _addCanvas;
  43796. private _removeCanvas;
  43797. }
  43798. }
  43799. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43800. import { Observable } from "babylonjs/Misc/observable";
  43801. import { Nullable } from "babylonjs/types";
  43802. import { IDisposable, Scene } from "babylonjs/scene";
  43803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43804. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43805. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43806. /**
  43807. * Manages an XRSession to work with Babylon's engine
  43808. * @see https://doc.babylonjs.com/how_to/webxr
  43809. */
  43810. export class WebXRSessionManager implements IDisposable {
  43811. /** The scene which the session should be created for */
  43812. scene: Scene;
  43813. /**
  43814. * Fires every time a new xrFrame arrives which can be used to update the camera
  43815. */
  43816. onXRFrameObservable: Observable<XRFrame>;
  43817. /**
  43818. * Fires when the xr session is ended either by the device or manually done
  43819. */
  43820. onXRSessionEnded: Observable<any>;
  43821. /**
  43822. * Fires when the xr session is ended either by the device or manually done
  43823. */
  43824. onXRSessionInit: Observable<XRSession>;
  43825. /**
  43826. * Underlying xr session
  43827. */
  43828. session: XRSession;
  43829. /**
  43830. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43831. * or get the offset the player is currently at.
  43832. */
  43833. viewerReferenceSpace: XRReferenceSpace;
  43834. /**
  43835. * The current reference space used in this session. This reference space can constantly change!
  43836. * It is mainly used to offset the camera's position.
  43837. */
  43838. referenceSpace: XRReferenceSpace;
  43839. /**
  43840. * The base reference space from which the session started. good if you want to reset your
  43841. * reference space
  43842. */
  43843. baseReferenceSpace: XRReferenceSpace;
  43844. /**
  43845. * Used just in case of a failure to initialize an immersive session.
  43846. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43847. */
  43848. defaultHeightCompensation: number;
  43849. /**
  43850. * Current XR frame
  43851. */
  43852. currentFrame: Nullable<XRFrame>;
  43853. /** WebXR timestamp updated every frame */
  43854. currentTimestamp: number;
  43855. private _xrNavigator;
  43856. private baseLayer;
  43857. private _rttProvider;
  43858. private _sessionEnded;
  43859. /**
  43860. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43861. * @param scene The scene which the session should be created for
  43862. */
  43863. constructor(
  43864. /** The scene which the session should be created for */
  43865. scene: Scene);
  43866. /**
  43867. * Initializes the manager
  43868. * After initialization enterXR can be called to start an XR session
  43869. * @returns Promise which resolves after it is initialized
  43870. */
  43871. initializeAsync(): Promise<void>;
  43872. /**
  43873. * Initializes an xr session
  43874. * @param xrSessionMode mode to initialize
  43875. * @param optionalFeatures defines optional values to pass to the session builder
  43876. * @returns a promise which will resolve once the session has been initialized
  43877. */
  43878. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43879. /**
  43880. * Sets the reference space on the xr session
  43881. * @param referenceSpace space to set
  43882. * @returns a promise that will resolve once the reference space has been set
  43883. */
  43884. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43885. /**
  43886. * Updates the render state of the session
  43887. * @param state state to set
  43888. * @returns a promise that resolves once the render state has been updated
  43889. */
  43890. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43891. /**
  43892. * Starts rendering to the xr layer
  43893. * @returns a promise that will resolve once rendering has started
  43894. */
  43895. startRenderingToXRAsync(): Promise<void>;
  43896. /**
  43897. * Gets the correct render target texture to be rendered this frame for this eye
  43898. * @param eye the eye for which to get the render target
  43899. * @returns the render target for the specified eye
  43900. */
  43901. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43902. /**
  43903. * Stops the xrSession and restores the renderloop
  43904. * @returns Promise which resolves after it exits XR
  43905. */
  43906. exitXRAsync(): Promise<void>;
  43907. /**
  43908. * Checks if a session would be supported for the creation options specified
  43909. * @param sessionMode session mode to check if supported eg. immersive-vr
  43910. * @returns true if supported
  43911. */
  43912. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43913. /**
  43914. * Creates a WebXRRenderTarget object for the XR session
  43915. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43916. * @param options optional options to provide when creating a new render target
  43917. * @returns a WebXR render target to which the session can render
  43918. */
  43919. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43920. /**
  43921. * @hidden
  43922. * Converts the render layer of xrSession to a render target
  43923. * @param session session to create render target for
  43924. * @param scene scene the new render target should be created for
  43925. * @param baseLayer the webgl layer to create the render target for
  43926. */
  43927. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43928. /**
  43929. * Disposes of the session manager
  43930. */
  43931. dispose(): void;
  43932. /**
  43933. * Gets a promise returning true when fullfiled if the given session mode is supported
  43934. * @param sessionMode defines the session to test
  43935. * @returns a promise
  43936. */
  43937. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43938. }
  43939. }
  43940. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43941. import { Scene } from "babylonjs/scene";
  43942. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43943. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43944. /**
  43945. * WebXR Camera which holds the views for the xrSession
  43946. * @see https://doc.babylonjs.com/how_to/webxr
  43947. */
  43948. export class WebXRCamera extends FreeCamera {
  43949. private _xrSessionManager;
  43950. /**
  43951. * Is the camera in debug mode. Used when using an emulator
  43952. */
  43953. debugMode: boolean;
  43954. private _firstFrame;
  43955. private _referencedPosition;
  43956. private _referenceQuaternion;
  43957. private _xrInvPositionCache;
  43958. private _xrInvQuaternionCache;
  43959. /**
  43960. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43961. * @param name the name of the camera
  43962. * @param scene the scene to add the camera to
  43963. */
  43964. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43965. private _updateNumberOfRigCameras;
  43966. /** @hidden */
  43967. _updateForDualEyeDebugging(): void;
  43968. /**
  43969. * Updates the cameras position from the current pose information of the XR session
  43970. * @param xrSessionManager the session containing pose information
  43971. */
  43972. update(): void;
  43973. private _updateReferenceSpace;
  43974. private _updateReferenceSpaceOffset;
  43975. private _updateFromXRSession;
  43976. }
  43977. }
  43978. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43979. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43980. import { IDisposable } from "babylonjs/scene";
  43981. /**
  43982. * Defining the interface required for a (webxr) feature
  43983. */
  43984. export interface IWebXRFeature extends IDisposable {
  43985. /**
  43986. * Attach the feature to the session
  43987. * Will usually be called by the features manager
  43988. *
  43989. * @returns true if successful.
  43990. */
  43991. attach(): boolean;
  43992. /**
  43993. * Detach the feature from the session
  43994. * Will usually be called by the features manager
  43995. *
  43996. * @returns true if successful.
  43997. */
  43998. detach(): boolean;
  43999. }
  44000. /**
  44001. * Defining the constructor of a feature. Used to register the modules.
  44002. */
  44003. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44004. /**
  44005. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44006. * It is mainly used in AR sessions.
  44007. *
  44008. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44009. */
  44010. export class WebXRFeaturesManager implements IDisposable {
  44011. private _xrSessionManager;
  44012. private static readonly _AvailableFeatures;
  44013. /**
  44014. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44015. * Mainly used internally.
  44016. *
  44017. * @param featureName the name of the feature to register
  44018. * @param constructorFunction the function used to construct the module
  44019. * @param version the (babylon) version of the module
  44020. * @param stable is that a stable version of this module
  44021. */
  44022. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44023. /**
  44024. * Returns a constructor of a specific feature.
  44025. *
  44026. * @param featureName the name of the feature to construct
  44027. * @param version the version of the feature to load
  44028. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44029. * @param options optional options provided to the module.
  44030. * @returns a function that, when called, will return a new instance of this feature
  44031. */
  44032. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44033. /**
  44034. * Return the latest unstable version of this feature
  44035. * @param featureName the name of the feature to search
  44036. * @returns the version number. if not found will return -1
  44037. */
  44038. static GetLatestVersionOfFeature(featureName: string): number;
  44039. /**
  44040. * Return the latest stable version of this feature
  44041. * @param featureName the name of the feature to search
  44042. * @returns the version number. if not found will return -1
  44043. */
  44044. static GetStableVersionOfFeature(featureName: string): number;
  44045. /**
  44046. * Can be used to return the list of features currently registered
  44047. *
  44048. * @returns an Array of available features
  44049. */
  44050. static GetAvailableFeatures(): string[];
  44051. /**
  44052. * Gets the versions available for a specific feature
  44053. * @param featureName the name of the feature
  44054. * @returns an array with the available versions
  44055. */
  44056. static GetAvailableVersions(featureName: string): string[];
  44057. private _features;
  44058. /**
  44059. * constructs a new features manages.
  44060. *
  44061. * @param _xrSessionManager an instance of WebXRSessionManager
  44062. */
  44063. constructor(_xrSessionManager: WebXRSessionManager);
  44064. /**
  44065. * 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.
  44066. *
  44067. * @param featureName the name of the feature to load or the class of the feature
  44068. * @param version optional version to load. if not provided the latest version will be enabled
  44069. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44070. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44071. * @returns a new constructed feature or throws an error if feature not found.
  44072. */
  44073. enableFeature(featureName: string | {
  44074. Name: string;
  44075. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44076. /**
  44077. * Used to disable an already-enabled feature
  44078. * @param featureName the feature to disable
  44079. * @returns true if disable was successful
  44080. */
  44081. disableFeature(featureName: string | {
  44082. Name: string;
  44083. }): boolean;
  44084. /**
  44085. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44086. * Can be used during a session to start a feature
  44087. * @param featureName the name of feature to attach
  44088. */
  44089. attachFeature(featureName: string): void;
  44090. /**
  44091. * Can be used inside a session or when the session ends to detach a specific feature
  44092. * @param featureName the name of the feature to detach
  44093. */
  44094. detachFeature(featureName: string): void;
  44095. /**
  44096. * Get the list of enabled features
  44097. * @returns an array of enabled features
  44098. */
  44099. getEnabledFeatures(): string[];
  44100. /**
  44101. * get the implementation of an enabled feature.
  44102. * @param featureName the name of the feature to load
  44103. * @returns the feature class, if found
  44104. */
  44105. getEnabledFeature(featureName: string): IWebXRFeature;
  44106. /**
  44107. * dispose this features manager
  44108. */
  44109. dispose(): void;
  44110. }
  44111. }
  44112. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44113. import { Observable } from "babylonjs/Misc/observable";
  44114. import { IDisposable, Scene } from "babylonjs/scene";
  44115. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44116. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44117. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44118. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44119. /**
  44120. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44121. * @see https://doc.babylonjs.com/how_to/webxr
  44122. */
  44123. export class WebXRExperienceHelper implements IDisposable {
  44124. private scene;
  44125. /**
  44126. * Camera used to render xr content
  44127. */
  44128. camera: WebXRCamera;
  44129. /**
  44130. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44131. */
  44132. state: WebXRState;
  44133. private _setState;
  44134. /**
  44135. * Fires when the state of the experience helper has changed
  44136. */
  44137. onStateChangedObservable: Observable<WebXRState>;
  44138. /**
  44139. * Observers registered here will be triggered after the camera's initial transformation is set
  44140. * This can be used to set a different ground level or an extra rotation.
  44141. *
  44142. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44143. * to the position set after this observable is done executing.
  44144. */
  44145. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44146. /** Session manager used to keep track of xr session */
  44147. sessionManager: WebXRSessionManager;
  44148. /** A features manager for this xr session */
  44149. featuresManager: WebXRFeaturesManager;
  44150. private _nonVRCamera;
  44151. private _originalSceneAutoClear;
  44152. private _supported;
  44153. /**
  44154. * Creates the experience helper
  44155. * @param scene the scene to attach the experience helper to
  44156. * @returns a promise for the experience helper
  44157. */
  44158. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44159. /**
  44160. * Creates a WebXRExperienceHelper
  44161. * @param scene The scene the helper should be created in
  44162. */
  44163. private constructor();
  44164. /**
  44165. * Exits XR mode and returns the scene to its original state
  44166. * @returns promise that resolves after xr mode has exited
  44167. */
  44168. exitXRAsync(): Promise<void>;
  44169. /**
  44170. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44171. * @param sessionMode options for the XR session
  44172. * @param referenceSpaceType frame of reference of the XR session
  44173. * @param renderTarget the output canvas that will be used to enter XR mode
  44174. * @returns promise that resolves after xr mode has entered
  44175. */
  44176. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44177. /**
  44178. * Disposes of the experience helper
  44179. */
  44180. dispose(): void;
  44181. private _nonXRToXRCamera;
  44182. }
  44183. }
  44184. declare module "babylonjs/Cameras/XR/webXRController" {
  44185. import { Nullable } from "babylonjs/types";
  44186. import { Observable } from "babylonjs/Misc/observable";
  44187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44188. import { Ray } from "babylonjs/Culling/ray";
  44189. import { Scene } from "babylonjs/scene";
  44190. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44191. /**
  44192. * Represents an XR input
  44193. */
  44194. export class WebXRController {
  44195. private scene;
  44196. /** The underlying input source for the controller */
  44197. inputSource: XRInputSource;
  44198. private parentContainer;
  44199. /**
  44200. * 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
  44201. */
  44202. grip?: AbstractMesh;
  44203. /**
  44204. * Pointer which can be used to select objects or attach a visible laser to
  44205. */
  44206. pointer: AbstractMesh;
  44207. private _gamepadMode;
  44208. /**
  44209. * If available, this is the gamepad object related to this controller.
  44210. * Using this object it is possible to get click events and trackpad changes of the
  44211. * webxr controller that is currently being used.
  44212. */
  44213. gamepadController?: WebVRController;
  44214. /**
  44215. * Event that fires when the controller is removed/disposed
  44216. */
  44217. onDisposeObservable: Observable<{}>;
  44218. private _tmpQuaternion;
  44219. private _tmpVector;
  44220. /**
  44221. * Creates the controller
  44222. * @see https://doc.babylonjs.com/how_to/webxr
  44223. * @param scene the scene which the controller should be associated to
  44224. * @param inputSource the underlying input source for the controller
  44225. * @param parentContainer parent that the controller meshes should be children of
  44226. */
  44227. constructor(scene: Scene,
  44228. /** The underlying input source for the controller */
  44229. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44230. /**
  44231. * Updates the controller pose based on the given XRFrame
  44232. * @param xrFrame xr frame to update the pose with
  44233. * @param referenceSpace reference space to use
  44234. */
  44235. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44236. /**
  44237. * Gets a world space ray coming from the controller
  44238. * @param result the resulting ray
  44239. */
  44240. getWorldPointerRayToRef(result: Ray): void;
  44241. /**
  44242. * Get the scene associated with this controller
  44243. * @returns the scene object
  44244. */
  44245. getScene(): Scene;
  44246. /**
  44247. * Disposes of the object
  44248. */
  44249. dispose(): void;
  44250. }
  44251. }
  44252. declare module "babylonjs/Cameras/XR/webXRInput" {
  44253. import { Observable } from "babylonjs/Misc/observable";
  44254. import { IDisposable } from "babylonjs/scene";
  44255. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44256. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44257. /**
  44258. * XR input used to track XR inputs such as controllers/rays
  44259. */
  44260. export class WebXRInput implements IDisposable {
  44261. /**
  44262. * Base experience the input listens to
  44263. */
  44264. baseExperience: WebXRExperienceHelper;
  44265. /**
  44266. * XR controllers being tracked
  44267. */
  44268. controllers: Array<WebXRController>;
  44269. private _frameObserver;
  44270. private _stateObserver;
  44271. /**
  44272. * Event when a controller has been connected/added
  44273. */
  44274. onControllerAddedObservable: Observable<WebXRController>;
  44275. /**
  44276. * Event when a controller has been removed/disconnected
  44277. */
  44278. onControllerRemovedObservable: Observable<WebXRController>;
  44279. /**
  44280. * Initializes the WebXRInput
  44281. * @param baseExperience experience helper which the input should be created for
  44282. */
  44283. constructor(
  44284. /**
  44285. * Base experience the input listens to
  44286. */
  44287. baseExperience: WebXRExperienceHelper);
  44288. private _onInputSourcesChange;
  44289. private _addAndRemoveControllers;
  44290. /**
  44291. * Disposes of the object
  44292. */
  44293. dispose(): void;
  44294. }
  44295. }
  44296. declare module "babylonjs/Loading/sceneLoader" {
  44297. import { Observable } from "babylonjs/Misc/observable";
  44298. import { Nullable } from "babylonjs/types";
  44299. import { Scene } from "babylonjs/scene";
  44300. import { Engine } from "babylonjs/Engines/engine";
  44301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44302. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44303. import { AssetContainer } from "babylonjs/assetContainer";
  44304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44305. import { Skeleton } from "babylonjs/Bones/skeleton";
  44306. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44307. import { WebRequest } from "babylonjs/Misc/webRequest";
  44308. /**
  44309. * Class used to represent data loading progression
  44310. */
  44311. export class SceneLoaderProgressEvent {
  44312. /** defines if data length to load can be evaluated */
  44313. readonly lengthComputable: boolean;
  44314. /** defines the loaded data length */
  44315. readonly loaded: number;
  44316. /** defines the data length to load */
  44317. readonly total: number;
  44318. /**
  44319. * Create a new progress event
  44320. * @param lengthComputable defines if data length to load can be evaluated
  44321. * @param loaded defines the loaded data length
  44322. * @param total defines the data length to load
  44323. */
  44324. constructor(
  44325. /** defines if data length to load can be evaluated */
  44326. lengthComputable: boolean,
  44327. /** defines the loaded data length */
  44328. loaded: number,
  44329. /** defines the data length to load */
  44330. total: number);
  44331. /**
  44332. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44333. * @param event defines the source event
  44334. * @returns a new SceneLoaderProgressEvent
  44335. */
  44336. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44337. }
  44338. /**
  44339. * Interface used by SceneLoader plugins to define supported file extensions
  44340. */
  44341. export interface ISceneLoaderPluginExtensions {
  44342. /**
  44343. * Defines the list of supported extensions
  44344. */
  44345. [extension: string]: {
  44346. isBinary: boolean;
  44347. };
  44348. }
  44349. /**
  44350. * Interface used by SceneLoader plugin factory
  44351. */
  44352. export interface ISceneLoaderPluginFactory {
  44353. /**
  44354. * Defines the name of the factory
  44355. */
  44356. name: string;
  44357. /**
  44358. * Function called to create a new plugin
  44359. * @return the new plugin
  44360. */
  44361. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44362. /**
  44363. * The callback that returns true if the data can be directly loaded.
  44364. * @param data string containing the file data
  44365. * @returns if the data can be loaded directly
  44366. */
  44367. canDirectLoad?(data: string): boolean;
  44368. }
  44369. /**
  44370. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44371. */
  44372. export interface ISceneLoaderPluginBase {
  44373. /**
  44374. * The friendly name of this plugin.
  44375. */
  44376. name: string;
  44377. /**
  44378. * The file extensions supported by this plugin.
  44379. */
  44380. extensions: string | ISceneLoaderPluginExtensions;
  44381. /**
  44382. * The callback called when loading from a url.
  44383. * @param scene scene loading this url
  44384. * @param url url to load
  44385. * @param onSuccess callback called when the file successfully loads
  44386. * @param onProgress callback called while file is loading (if the server supports this mode)
  44387. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44388. * @param onError callback called when the file fails to load
  44389. * @returns a file request object
  44390. */
  44391. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44392. /**
  44393. * The callback called when loading from a file object.
  44394. * @param scene scene loading this file
  44395. * @param file defines the file to load
  44396. * @param onSuccess defines the callback to call when data is loaded
  44397. * @param onProgress defines the callback to call during loading process
  44398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44399. * @param onError defines the callback to call when an error occurs
  44400. * @returns a file request object
  44401. */
  44402. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44403. /**
  44404. * The callback that returns true if the data can be directly loaded.
  44405. * @param data string containing the file data
  44406. * @returns if the data can be loaded directly
  44407. */
  44408. canDirectLoad?(data: string): boolean;
  44409. /**
  44410. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44411. * @param scene scene loading this data
  44412. * @param data string containing the data
  44413. * @returns data to pass to the plugin
  44414. */
  44415. directLoad?(scene: Scene, data: string): any;
  44416. /**
  44417. * The callback that allows custom handling of the root url based on the response url.
  44418. * @param rootUrl the original root url
  44419. * @param responseURL the response url if available
  44420. * @returns the new root url
  44421. */
  44422. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44423. }
  44424. /**
  44425. * Interface used to define a SceneLoader plugin
  44426. */
  44427. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44428. /**
  44429. * Import meshes into a scene.
  44430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44431. * @param scene The scene to import into
  44432. * @param data The data to import
  44433. * @param rootUrl The root url for scene and resources
  44434. * @param meshes The meshes array to import into
  44435. * @param particleSystems The particle systems array to import into
  44436. * @param skeletons The skeletons array to import into
  44437. * @param onError The callback when import fails
  44438. * @returns True if successful or false otherwise
  44439. */
  44440. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44441. /**
  44442. * Load into a scene.
  44443. * @param scene The scene to load into
  44444. * @param data The data to import
  44445. * @param rootUrl The root url for scene and resources
  44446. * @param onError The callback when import fails
  44447. * @returns True if successful or false otherwise
  44448. */
  44449. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44450. /**
  44451. * Load into an asset container.
  44452. * @param scene The scene to load into
  44453. * @param data The data to import
  44454. * @param rootUrl The root url for scene and resources
  44455. * @param onError The callback when import fails
  44456. * @returns The loaded asset container
  44457. */
  44458. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44459. }
  44460. /**
  44461. * Interface used to define an async SceneLoader plugin
  44462. */
  44463. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44464. /**
  44465. * Import meshes into a scene.
  44466. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44467. * @param scene The scene to import into
  44468. * @param data The data to import
  44469. * @param rootUrl The root url for scene and resources
  44470. * @param onProgress The callback when the load progresses
  44471. * @param fileName Defines the name of the file to load
  44472. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44473. */
  44474. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44475. meshes: AbstractMesh[];
  44476. particleSystems: IParticleSystem[];
  44477. skeletons: Skeleton[];
  44478. animationGroups: AnimationGroup[];
  44479. }>;
  44480. /**
  44481. * Load into a scene.
  44482. * @param scene The scene to load into
  44483. * @param data The data to import
  44484. * @param rootUrl The root url for scene and resources
  44485. * @param onProgress The callback when the load progresses
  44486. * @param fileName Defines the name of the file to load
  44487. * @returns Nothing
  44488. */
  44489. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44490. /**
  44491. * Load into an asset container.
  44492. * @param scene The scene to load into
  44493. * @param data The data to import
  44494. * @param rootUrl The root url for scene and resources
  44495. * @param onProgress The callback when the load progresses
  44496. * @param fileName Defines the name of the file to load
  44497. * @returns The loaded asset container
  44498. */
  44499. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44500. }
  44501. /**
  44502. * Mode that determines how to handle old animation groups before loading new ones.
  44503. */
  44504. export enum SceneLoaderAnimationGroupLoadingMode {
  44505. /**
  44506. * Reset all old animations to initial state then dispose them.
  44507. */
  44508. Clean = 0,
  44509. /**
  44510. * Stop all old animations.
  44511. */
  44512. Stop = 1,
  44513. /**
  44514. * Restart old animations from first frame.
  44515. */
  44516. Sync = 2,
  44517. /**
  44518. * Old animations remains untouched.
  44519. */
  44520. NoSync = 3
  44521. }
  44522. /**
  44523. * Class used to load scene from various file formats using registered plugins
  44524. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44525. */
  44526. export class SceneLoader {
  44527. /**
  44528. * No logging while loading
  44529. */
  44530. static readonly NO_LOGGING: number;
  44531. /**
  44532. * Minimal logging while loading
  44533. */
  44534. static readonly MINIMAL_LOGGING: number;
  44535. /**
  44536. * Summary logging while loading
  44537. */
  44538. static readonly SUMMARY_LOGGING: number;
  44539. /**
  44540. * Detailled logging while loading
  44541. */
  44542. static readonly DETAILED_LOGGING: number;
  44543. /**
  44544. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44545. */
  44546. static get ForceFullSceneLoadingForIncremental(): boolean;
  44547. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44548. /**
  44549. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44550. */
  44551. static get ShowLoadingScreen(): boolean;
  44552. static set ShowLoadingScreen(value: boolean);
  44553. /**
  44554. * Defines the current logging level (while loading the scene)
  44555. * @ignorenaming
  44556. */
  44557. static get loggingLevel(): number;
  44558. static set loggingLevel(value: number);
  44559. /**
  44560. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44561. */
  44562. static get CleanBoneMatrixWeights(): boolean;
  44563. static set CleanBoneMatrixWeights(value: boolean);
  44564. /**
  44565. * Event raised when a plugin is used to load a scene
  44566. */
  44567. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44568. private static _registeredPlugins;
  44569. private static _getDefaultPlugin;
  44570. private static _getPluginForExtension;
  44571. private static _getPluginForDirectLoad;
  44572. private static _getPluginForFilename;
  44573. private static _getDirectLoad;
  44574. private static _loadData;
  44575. private static _getFileInfo;
  44576. /**
  44577. * Gets a plugin that can load the given extension
  44578. * @param extension defines the extension to load
  44579. * @returns a plugin or null if none works
  44580. */
  44581. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44582. /**
  44583. * Gets a boolean indicating that the given extension can be loaded
  44584. * @param extension defines the extension to load
  44585. * @returns true if the extension is supported
  44586. */
  44587. static IsPluginForExtensionAvailable(extension: string): boolean;
  44588. /**
  44589. * Adds a new plugin to the list of registered plugins
  44590. * @param plugin defines the plugin to add
  44591. */
  44592. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44593. /**
  44594. * Import meshes into a scene
  44595. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44596. * @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)
  44597. * @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)
  44598. * @param scene the instance of BABYLON.Scene to append to
  44599. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44600. * @param onProgress a callback with a progress event for each file being loaded
  44601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44602. * @param pluginExtension the extension used to determine the plugin
  44603. * @returns The loaded plugin
  44604. */
  44605. 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>;
  44606. /**
  44607. * Import meshes into a scene
  44608. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44609. * @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)
  44610. * @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)
  44611. * @param scene the instance of BABYLON.Scene to append to
  44612. * @param onProgress a callback with a progress event for each file being loaded
  44613. * @param pluginExtension the extension used to determine the plugin
  44614. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44615. */
  44616. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44617. meshes: AbstractMesh[];
  44618. particleSystems: IParticleSystem[];
  44619. skeletons: Skeleton[];
  44620. animationGroups: AnimationGroup[];
  44621. }>;
  44622. /**
  44623. * Load a scene
  44624. * @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)
  44625. * @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)
  44626. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44627. * @param onSuccess a callback with the scene when import succeeds
  44628. * @param onProgress a callback with a progress event for each file being loaded
  44629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44630. * @param pluginExtension the extension used to determine the plugin
  44631. * @returns The loaded plugin
  44632. */
  44633. 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>;
  44634. /**
  44635. * Load a scene
  44636. * @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)
  44637. * @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)
  44638. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44639. * @param onProgress a callback with a progress event for each file being loaded
  44640. * @param pluginExtension the extension used to determine the plugin
  44641. * @returns The loaded scene
  44642. */
  44643. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44644. /**
  44645. * Append a scene
  44646. * @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)
  44647. * @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)
  44648. * @param scene is the instance of BABYLON.Scene to append to
  44649. * @param onSuccess a callback with the scene when import succeeds
  44650. * @param onProgress a callback with a progress event for each file being loaded
  44651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44652. * @param pluginExtension the extension used to determine the plugin
  44653. * @returns The loaded plugin
  44654. */
  44655. 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>;
  44656. /**
  44657. * Append a scene
  44658. * @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)
  44659. * @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)
  44660. * @param scene is the instance of BABYLON.Scene to append to
  44661. * @param onProgress a callback with a progress event for each file being loaded
  44662. * @param pluginExtension the extension used to determine the plugin
  44663. * @returns The given scene
  44664. */
  44665. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44666. /**
  44667. * Load a scene into an asset container
  44668. * @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)
  44669. * @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)
  44670. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44671. * @param onSuccess a callback with the scene when import succeeds
  44672. * @param onProgress a callback with a progress event for each file being loaded
  44673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44674. * @param pluginExtension the extension used to determine the plugin
  44675. * @returns The loaded plugin
  44676. */
  44677. 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>;
  44678. /**
  44679. * Load a scene into an asset container
  44680. * @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)
  44681. * @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)
  44682. * @param scene is the instance of Scene to append to
  44683. * @param onProgress a callback with a progress event for each file being loaded
  44684. * @param pluginExtension the extension used to determine the plugin
  44685. * @returns The loaded asset container
  44686. */
  44687. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44688. /**
  44689. * Import animations from a file into a scene
  44690. * @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)
  44691. * @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)
  44692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44693. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44694. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44695. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44696. * @param onSuccess a callback with the scene when import succeeds
  44697. * @param onProgress a callback with a progress event for each file being loaded
  44698. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44699. */
  44700. 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;
  44701. /**
  44702. * Import animations from a file into a scene
  44703. * @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)
  44704. * @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)
  44705. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44706. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44707. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44708. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44709. * @param onSuccess a callback with the scene when import succeeds
  44710. * @param onProgress a callback with a progress event for each file being loaded
  44711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44712. * @returns the updated scene with imported animations
  44713. */
  44714. 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>;
  44715. }
  44716. }
  44717. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44718. import { Scene } from "babylonjs/scene";
  44719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44720. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44721. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44722. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44723. /**
  44724. * Generic Controller
  44725. */
  44726. export class GenericController extends WebVRController {
  44727. /**
  44728. * Base Url for the controller model.
  44729. */
  44730. static readonly MODEL_BASE_URL: string;
  44731. /**
  44732. * File name for the controller model.
  44733. */
  44734. static readonly MODEL_FILENAME: string;
  44735. /**
  44736. * Creates a new GenericController from a gamepad
  44737. * @param vrGamepad the gamepad that the controller should be created from
  44738. */
  44739. constructor(vrGamepad: any);
  44740. /**
  44741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44742. * @param scene scene in which to add meshes
  44743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44744. */
  44745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44746. /**
  44747. * Called once for each button that changed state since the last frame
  44748. * @param buttonIdx Which button index changed
  44749. * @param state New state of the button
  44750. * @param changes Which properties on the state changed since last frame
  44751. */
  44752. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44753. }
  44754. }
  44755. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44756. import { Observable } from "babylonjs/Misc/observable";
  44757. import { Scene } from "babylonjs/scene";
  44758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44759. import { Ray } from "babylonjs/Culling/ray";
  44760. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44761. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44762. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44763. /**
  44764. * Defines the WindowsMotionController object that the state of the windows motion controller
  44765. */
  44766. export class WindowsMotionController extends WebVRController {
  44767. /**
  44768. * The base url used to load the left and right controller models
  44769. */
  44770. static MODEL_BASE_URL: string;
  44771. /**
  44772. * The name of the left controller model file
  44773. */
  44774. static MODEL_LEFT_FILENAME: string;
  44775. /**
  44776. * The name of the right controller model file
  44777. */
  44778. static MODEL_RIGHT_FILENAME: string;
  44779. /**
  44780. * The controller name prefix for this controller type
  44781. */
  44782. static readonly GAMEPAD_ID_PREFIX: string;
  44783. /**
  44784. * The controller id pattern for this controller type
  44785. */
  44786. private static readonly GAMEPAD_ID_PATTERN;
  44787. private _loadedMeshInfo;
  44788. protected readonly _mapping: {
  44789. buttons: string[];
  44790. buttonMeshNames: {
  44791. 'trigger': string;
  44792. 'menu': string;
  44793. 'grip': string;
  44794. 'thumbstick': string;
  44795. 'trackpad': string;
  44796. };
  44797. buttonObservableNames: {
  44798. 'trigger': string;
  44799. 'menu': string;
  44800. 'grip': string;
  44801. 'thumbstick': string;
  44802. 'trackpad': string;
  44803. };
  44804. axisMeshNames: string[];
  44805. pointingPoseMeshName: string;
  44806. };
  44807. /**
  44808. * Fired when the trackpad on this controller is clicked
  44809. */
  44810. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44811. /**
  44812. * Fired when the trackpad on this controller is modified
  44813. */
  44814. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44815. /**
  44816. * The current x and y values of this controller's trackpad
  44817. */
  44818. trackpad: StickValues;
  44819. /**
  44820. * Creates a new WindowsMotionController from a gamepad
  44821. * @param vrGamepad the gamepad that the controller should be created from
  44822. */
  44823. constructor(vrGamepad: any);
  44824. /**
  44825. * Fired when the trigger on this controller is modified
  44826. */
  44827. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44828. /**
  44829. * Fired when the menu button on this controller is modified
  44830. */
  44831. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44832. /**
  44833. * Fired when the grip button on this controller is modified
  44834. */
  44835. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44836. /**
  44837. * Fired when the thumbstick button on this controller is modified
  44838. */
  44839. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44840. /**
  44841. * Fired when the touchpad button on this controller is modified
  44842. */
  44843. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44844. /**
  44845. * Fired when the touchpad values on this controller are modified
  44846. */
  44847. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44848. protected _updateTrackpad(): void;
  44849. /**
  44850. * Called once per frame by the engine.
  44851. */
  44852. update(): void;
  44853. /**
  44854. * Called once for each button that changed state since the last frame
  44855. * @param buttonIdx Which button index changed
  44856. * @param state New state of the button
  44857. * @param changes Which properties on the state changed since last frame
  44858. */
  44859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44860. /**
  44861. * Moves the buttons on the controller mesh based on their current state
  44862. * @param buttonName the name of the button to move
  44863. * @param buttonValue the value of the button which determines the buttons new position
  44864. */
  44865. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44866. /**
  44867. * Moves the axis on the controller mesh based on its current state
  44868. * @param axis the index of the axis
  44869. * @param axisValue the value of the axis which determines the meshes new position
  44870. * @hidden
  44871. */
  44872. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44873. /**
  44874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44875. * @param scene scene in which to add meshes
  44876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44877. */
  44878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44879. /**
  44880. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44881. * can be transformed by button presses and axes values, based on this._mapping.
  44882. *
  44883. * @param scene scene in which the meshes exist
  44884. * @param meshes list of meshes that make up the controller model to process
  44885. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44886. */
  44887. private processModel;
  44888. private createMeshInfo;
  44889. /**
  44890. * Gets the ray of the controller in the direction the controller is pointing
  44891. * @param length the length the resulting ray should be
  44892. * @returns a ray in the direction the controller is pointing
  44893. */
  44894. getForwardRay(length?: number): Ray;
  44895. /**
  44896. * Disposes of the controller
  44897. */
  44898. dispose(): void;
  44899. }
  44900. /**
  44901. * This class represents a new windows motion controller in XR.
  44902. */
  44903. export class XRWindowsMotionController extends WindowsMotionController {
  44904. /**
  44905. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44906. */
  44907. protected readonly _mapping: {
  44908. buttons: string[];
  44909. buttonMeshNames: {
  44910. 'trigger': string;
  44911. 'menu': string;
  44912. 'grip': string;
  44913. 'thumbstick': string;
  44914. 'trackpad': string;
  44915. };
  44916. buttonObservableNames: {
  44917. 'trigger': string;
  44918. 'menu': string;
  44919. 'grip': string;
  44920. 'thumbstick': string;
  44921. 'trackpad': string;
  44922. };
  44923. axisMeshNames: string[];
  44924. pointingPoseMeshName: string;
  44925. };
  44926. /**
  44927. * Construct a new XR-Based windows motion controller
  44928. *
  44929. * @param gamepadInfo the gamepad object from the browser
  44930. */
  44931. constructor(gamepadInfo: any);
  44932. /**
  44933. * holds the thumbstick values (X,Y)
  44934. */
  44935. thumbstickValues: StickValues;
  44936. /**
  44937. * Fired when the thumbstick on this controller is clicked
  44938. */
  44939. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44940. /**
  44941. * Fired when the thumbstick on this controller is modified
  44942. */
  44943. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44944. /**
  44945. * Fired when the touchpad button on this controller is modified
  44946. */
  44947. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44948. /**
  44949. * Fired when the touchpad values on this controller are modified
  44950. */
  44951. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44952. /**
  44953. * Fired when the thumbstick button on this controller is modified
  44954. * here to prevent breaking changes
  44955. */
  44956. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44957. /**
  44958. * updating the thumbstick(!) and not the trackpad.
  44959. * This is named this way due to the difference between WebVR and XR and to avoid
  44960. * changing the parent class.
  44961. */
  44962. protected _updateTrackpad(): void;
  44963. /**
  44964. * Disposes the class with joy
  44965. */
  44966. dispose(): void;
  44967. }
  44968. }
  44969. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44970. import { Observable } from "babylonjs/Misc/observable";
  44971. import { Scene } from "babylonjs/scene";
  44972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44973. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44974. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44975. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44976. /**
  44977. * Oculus Touch Controller
  44978. */
  44979. export class OculusTouchController extends WebVRController {
  44980. /**
  44981. * Base Url for the controller model.
  44982. */
  44983. static MODEL_BASE_URL: string;
  44984. /**
  44985. * File name for the left controller model.
  44986. */
  44987. static MODEL_LEFT_FILENAME: string;
  44988. /**
  44989. * File name for the right controller model.
  44990. */
  44991. static MODEL_RIGHT_FILENAME: string;
  44992. /**
  44993. * Base Url for the Quest controller model.
  44994. */
  44995. static QUEST_MODEL_BASE_URL: string;
  44996. /**
  44997. * @hidden
  44998. * If the controllers are running on a device that needs the updated Quest controller models
  44999. */
  45000. static _IsQuest: boolean;
  45001. /**
  45002. * Fired when the secondary trigger on this controller is modified
  45003. */
  45004. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  45005. /**
  45006. * Fired when the thumb rest on this controller is modified
  45007. */
  45008. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  45009. /**
  45010. * Creates a new OculusTouchController from a gamepad
  45011. * @param vrGamepad the gamepad that the controller should be created from
  45012. */
  45013. constructor(vrGamepad: any);
  45014. /**
  45015. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45016. * @param scene scene in which to add meshes
  45017. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45018. */
  45019. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45020. /**
  45021. * Fired when the A button on this controller is modified
  45022. */
  45023. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45024. /**
  45025. * Fired when the B button on this controller is modified
  45026. */
  45027. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45028. /**
  45029. * Fired when the X button on this controller is modified
  45030. */
  45031. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45032. /**
  45033. * Fired when the Y button on this controller is modified
  45034. */
  45035. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45036. /**
  45037. * Called once for each button that changed state since the last frame
  45038. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  45039. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  45040. * 2) secondary trigger (same)
  45041. * 3) A (right) X (left), touch, pressed = value
  45042. * 4) B / Y
  45043. * 5) thumb rest
  45044. * @param buttonIdx Which button index changed
  45045. * @param state New state of the button
  45046. * @param changes Which properties on the state changed since last frame
  45047. */
  45048. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45049. }
  45050. }
  45051. declare module "babylonjs/Gamepads/Controllers/viveController" {
  45052. import { Scene } from "babylonjs/scene";
  45053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45054. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45055. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45056. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45057. import { Observable } from "babylonjs/Misc/observable";
  45058. /**
  45059. * Vive Controller
  45060. */
  45061. export class ViveController extends WebVRController {
  45062. /**
  45063. * Base Url for the controller model.
  45064. */
  45065. static MODEL_BASE_URL: string;
  45066. /**
  45067. * File name for the controller model.
  45068. */
  45069. static MODEL_FILENAME: string;
  45070. /**
  45071. * Creates a new ViveController from a gamepad
  45072. * @param vrGamepad the gamepad that the controller should be created from
  45073. */
  45074. constructor(vrGamepad: any);
  45075. /**
  45076. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45077. * @param scene scene in which to add meshes
  45078. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45079. */
  45080. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45081. /**
  45082. * Fired when the left button on this controller is modified
  45083. */
  45084. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45085. /**
  45086. * Fired when the right button on this controller is modified
  45087. */
  45088. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45089. /**
  45090. * Fired when the menu button on this controller is modified
  45091. */
  45092. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45093. /**
  45094. * Called once for each button that changed state since the last frame
  45095. * Vive mapping:
  45096. * 0: touchpad
  45097. * 1: trigger
  45098. * 2: left AND right buttons
  45099. * 3: menu button
  45100. * @param buttonIdx Which button index changed
  45101. * @param state New state of the button
  45102. * @param changes Which properties on the state changed since last frame
  45103. */
  45104. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45105. }
  45106. }
  45107. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45108. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45109. import { Observable } from "babylonjs/Misc/observable";
  45110. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45111. /**
  45112. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45113. */
  45114. export class WebXRControllerModelLoader {
  45115. /**
  45116. * an observable that triggers when a new model (the mesh itself) was initialized.
  45117. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45118. */
  45119. onControllerModelLoaded: Observable<WebXRController>;
  45120. /**
  45121. * Creates the WebXRControllerModelLoader
  45122. * @param input xr input that creates the controllers
  45123. */
  45124. constructor(input: WebXRInput);
  45125. }
  45126. }
  45127. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45128. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45129. /**
  45130. * Handles pointer input automatically for the pointer of XR controllers
  45131. */
  45132. export class WebXRControllerPointerSelection {
  45133. private static _idCounter;
  45134. private _tmpRay;
  45135. /**
  45136. * Creates a WebXRControllerPointerSelection
  45137. * @param input input manager to setup pointer selection
  45138. */
  45139. constructor(input: WebXRInput);
  45140. private _convertNormalToDirectionOfRay;
  45141. private _updatePointerDistance;
  45142. }
  45143. }
  45144. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45146. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45147. /**
  45148. * Enables teleportation
  45149. */
  45150. export class WebXRControllerTeleportation {
  45151. private _teleportationFillColor;
  45152. private _teleportationBorderColor;
  45153. private _tmpRay;
  45154. private _tmpVector;
  45155. /**
  45156. * when set to true (default) teleportation will wait for thumbstick changes.
  45157. * When set to false teleportation will be disabled.
  45158. *
  45159. * If set to false while teleporting results can be unexpected.
  45160. */
  45161. enabled: boolean;
  45162. /**
  45163. * Creates a WebXRControllerTeleportation
  45164. * @param input input manager to add teleportation to
  45165. * @param floorMeshes floormeshes which can be teleported to
  45166. */
  45167. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45168. }
  45169. }
  45170. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45171. import { Nullable } from "babylonjs/types";
  45172. import { Observable } from "babylonjs/Misc/observable";
  45173. import { IDisposable, Scene } from "babylonjs/scene";
  45174. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45175. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45176. /**
  45177. * Button which can be used to enter a different mode of XR
  45178. */
  45179. export class WebXREnterExitUIButton {
  45180. /** button element */
  45181. element: HTMLElement;
  45182. /** XR initialization options for the button */
  45183. sessionMode: XRSessionMode;
  45184. /** Reference space type */
  45185. referenceSpaceType: XRReferenceSpaceType;
  45186. /**
  45187. * Creates a WebXREnterExitUIButton
  45188. * @param element button element
  45189. * @param sessionMode XR initialization session mode
  45190. * @param referenceSpaceType the type of reference space to be used
  45191. */
  45192. constructor(
  45193. /** button element */
  45194. element: HTMLElement,
  45195. /** XR initialization options for the button */
  45196. sessionMode: XRSessionMode,
  45197. /** Reference space type */
  45198. referenceSpaceType: XRReferenceSpaceType);
  45199. /**
  45200. * Overwritable function which can be used to update the button's visuals when the state changes
  45201. * @param activeButton the current active button in the UI
  45202. */
  45203. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45204. }
  45205. /**
  45206. * Options to create the webXR UI
  45207. */
  45208. export class WebXREnterExitUIOptions {
  45209. /**
  45210. * Context to enter xr with
  45211. */
  45212. renderTarget?: Nullable<WebXRRenderTarget>;
  45213. /**
  45214. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45215. */
  45216. customButtons?: Array<WebXREnterExitUIButton>;
  45217. /**
  45218. * A session mode to use when creating the default button.
  45219. * Default is immersive-vr
  45220. */
  45221. sessionMode?: XRSessionMode;
  45222. /**
  45223. * A reference space type to use when creating the default button.
  45224. * Default is local-floor
  45225. */
  45226. referenceSpaceType?: XRReferenceSpaceType;
  45227. }
  45228. /**
  45229. * UI to allow the user to enter/exit XR mode
  45230. */
  45231. export class WebXREnterExitUI implements IDisposable {
  45232. private scene;
  45233. /** version of the options passed to this UI */
  45234. options: WebXREnterExitUIOptions;
  45235. private _overlay;
  45236. private _buttons;
  45237. private _activeButton;
  45238. /**
  45239. * Fired every time the active button is changed.
  45240. *
  45241. * When xr is entered via a button that launches xr that button will be the callback parameter
  45242. *
  45243. * When exiting xr the callback parameter will be null)
  45244. */
  45245. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45246. /**
  45247. * Creates UI to allow the user to enter/exit XR mode
  45248. * @param scene the scene to add the ui to
  45249. * @param helper the xr experience helper to enter/exit xr with
  45250. * @param options options to configure the UI
  45251. * @returns the created ui
  45252. */
  45253. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45254. /**
  45255. *
  45256. * @param scene babylon scene object to use
  45257. * @param options (read-only) version of the options passed to this UI
  45258. */
  45259. private constructor();
  45260. private _updateButtons;
  45261. /**
  45262. * Disposes of the object
  45263. */
  45264. dispose(): void;
  45265. }
  45266. }
  45267. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45268. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45269. import { Scene } from "babylonjs/scene";
  45270. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45271. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45272. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45273. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45274. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45275. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45277. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45278. /**
  45279. * Options for the default xr helper
  45280. */
  45281. export class WebXRDefaultExperienceOptions {
  45282. /**
  45283. * Floor meshes that should be used for teleporting
  45284. */
  45285. floorMeshes: Array<AbstractMesh>;
  45286. /**
  45287. * Enable or disable default UI to enter XR
  45288. */
  45289. disableDefaultUI?: boolean;
  45290. /**
  45291. * optional configuration for the output canvas
  45292. */
  45293. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45294. /**
  45295. * optional UI options. This can be used among other to change session mode and reference space type
  45296. */
  45297. uiOptions?: WebXREnterExitUIOptions;
  45298. }
  45299. /**
  45300. * Default experience which provides a similar setup to the previous webVRExperience
  45301. */
  45302. export class WebXRDefaultExperience {
  45303. /**
  45304. * Base experience
  45305. */
  45306. baseExperience: WebXRExperienceHelper;
  45307. /**
  45308. * Input experience extension
  45309. */
  45310. input: WebXRInput;
  45311. /**
  45312. * Loads the controller models
  45313. */
  45314. controllerModelLoader: WebXRControllerModelLoader;
  45315. /**
  45316. * Enables laser pointer and selection
  45317. */
  45318. pointerSelection: WebXRControllerPointerSelection;
  45319. /**
  45320. * Enables teleportation
  45321. */
  45322. teleportation: WebXRControllerTeleportation;
  45323. /**
  45324. * Enables ui for entering/exiting xr
  45325. */
  45326. enterExitUI: WebXREnterExitUI;
  45327. /**
  45328. * Default target xr should render to
  45329. */
  45330. renderTarget: WebXRRenderTarget;
  45331. /**
  45332. * Creates the default xr experience
  45333. * @param scene scene
  45334. * @param options options for basic configuration
  45335. * @returns resulting WebXRDefaultExperience
  45336. */
  45337. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45338. private constructor();
  45339. /**
  45340. * DIsposes of the experience helper
  45341. */
  45342. dispose(): void;
  45343. }
  45344. }
  45345. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45346. import { Observable } from "babylonjs/Misc/observable";
  45347. import { Nullable } from "babylonjs/types";
  45348. import { Camera } from "babylonjs/Cameras/camera";
  45349. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45350. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45351. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45352. import { Scene } from "babylonjs/scene";
  45353. import { Vector3 } from "babylonjs/Maths/math.vector";
  45354. import { Color3 } from "babylonjs/Maths/math.color";
  45355. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45357. import { Mesh } from "babylonjs/Meshes/mesh";
  45358. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45359. import { EasingFunction } from "babylonjs/Animations/easing";
  45360. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45361. import "babylonjs/Meshes/Builders/groundBuilder";
  45362. import "babylonjs/Meshes/Builders/torusBuilder";
  45363. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45364. import "babylonjs/Gamepads/gamepadSceneComponent";
  45365. import "babylonjs/Animations/animatable";
  45366. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45367. /**
  45368. * Options to modify the vr teleportation behavior.
  45369. */
  45370. export interface VRTeleportationOptions {
  45371. /**
  45372. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45373. */
  45374. floorMeshName?: string;
  45375. /**
  45376. * A list of meshes to be used as the teleportation floor. (default: empty)
  45377. */
  45378. floorMeshes?: Mesh[];
  45379. /**
  45380. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45381. */
  45382. teleportationMode?: number;
  45383. /**
  45384. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45385. */
  45386. teleportationTime?: number;
  45387. /**
  45388. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45389. */
  45390. teleportationSpeed?: number;
  45391. /**
  45392. * The easing function used in the animation or null for Linear. (default CircleEase)
  45393. */
  45394. easingFunction?: EasingFunction;
  45395. }
  45396. /**
  45397. * Options to modify the vr experience helper's behavior.
  45398. */
  45399. export interface VRExperienceHelperOptions extends WebVROptions {
  45400. /**
  45401. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45402. */
  45403. createDeviceOrientationCamera?: boolean;
  45404. /**
  45405. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45406. */
  45407. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45408. /**
  45409. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45410. */
  45411. laserToggle?: boolean;
  45412. /**
  45413. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45414. */
  45415. floorMeshes?: Mesh[];
  45416. /**
  45417. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45418. */
  45419. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45420. /**
  45421. * Defines if WebXR should be used instead of WebVR (if available)
  45422. */
  45423. useXR?: boolean;
  45424. }
  45425. /**
  45426. * Event containing information after VR has been entered
  45427. */
  45428. export class OnAfterEnteringVRObservableEvent {
  45429. /**
  45430. * If entering vr was successful
  45431. */
  45432. success: boolean;
  45433. }
  45434. /**
  45435. * Helps to quickly add VR support to an existing scene.
  45436. * See http://doc.babylonjs.com/how_to/webvr_helper
  45437. */
  45438. export class VRExperienceHelper {
  45439. /** Options to modify the vr experience helper's behavior. */
  45440. webVROptions: VRExperienceHelperOptions;
  45441. private _scene;
  45442. private _position;
  45443. private _btnVR;
  45444. private _btnVRDisplayed;
  45445. private _webVRsupported;
  45446. private _webVRready;
  45447. private _webVRrequesting;
  45448. private _webVRpresenting;
  45449. private _hasEnteredVR;
  45450. private _fullscreenVRpresenting;
  45451. private _inputElement;
  45452. private _webVRCamera;
  45453. private _vrDeviceOrientationCamera;
  45454. private _deviceOrientationCamera;
  45455. private _existingCamera;
  45456. private _onKeyDown;
  45457. private _onVrDisplayPresentChange;
  45458. private _onVRDisplayChanged;
  45459. private _onVRRequestPresentStart;
  45460. private _onVRRequestPresentComplete;
  45461. /**
  45462. * 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)
  45463. */
  45464. enableGazeEvenWhenNoPointerLock: boolean;
  45465. /**
  45466. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45467. */
  45468. exitVROnDoubleTap: boolean;
  45469. /**
  45470. * Observable raised right before entering VR.
  45471. */
  45472. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45473. /**
  45474. * Observable raised when entering VR has completed.
  45475. */
  45476. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45477. /**
  45478. * Observable raised when exiting VR.
  45479. */
  45480. onExitingVRObservable: Observable<VRExperienceHelper>;
  45481. /**
  45482. * Observable raised when controller mesh is loaded.
  45483. */
  45484. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45485. /** Return this.onEnteringVRObservable
  45486. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45487. */
  45488. get onEnteringVR(): Observable<VRExperienceHelper>;
  45489. /** Return this.onExitingVRObservable
  45490. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45491. */
  45492. get onExitingVR(): Observable<VRExperienceHelper>;
  45493. /** Return this.onControllerMeshLoadedObservable
  45494. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45495. */
  45496. get onControllerMeshLoaded(): Observable<WebVRController>;
  45497. private _rayLength;
  45498. private _useCustomVRButton;
  45499. private _teleportationRequested;
  45500. private _teleportActive;
  45501. private _floorMeshName;
  45502. private _floorMeshesCollection;
  45503. private _teleportationMode;
  45504. private _teleportationTime;
  45505. private _teleportationSpeed;
  45506. private _teleportationEasing;
  45507. private _rotationAllowed;
  45508. private _teleportBackwardsVector;
  45509. private _teleportationTarget;
  45510. private _isDefaultTeleportationTarget;
  45511. private _postProcessMove;
  45512. private _teleportationFillColor;
  45513. private _teleportationBorderColor;
  45514. private _rotationAngle;
  45515. private _haloCenter;
  45516. private _cameraGazer;
  45517. private _padSensibilityUp;
  45518. private _padSensibilityDown;
  45519. private _leftController;
  45520. private _rightController;
  45521. private _gazeColor;
  45522. private _laserColor;
  45523. private _pickedLaserColor;
  45524. private _pickedGazeColor;
  45525. /**
  45526. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45527. */
  45528. onNewMeshSelected: Observable<AbstractMesh>;
  45529. /**
  45530. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45531. * This observable will provide the mesh and the controller used to select the mesh
  45532. */
  45533. onMeshSelectedWithController: Observable<{
  45534. mesh: AbstractMesh;
  45535. controller: WebVRController;
  45536. }>;
  45537. /**
  45538. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45539. */
  45540. onNewMeshPicked: Observable<PickingInfo>;
  45541. private _circleEase;
  45542. /**
  45543. * Observable raised before camera teleportation
  45544. */
  45545. onBeforeCameraTeleport: Observable<Vector3>;
  45546. /**
  45547. * Observable raised after camera teleportation
  45548. */
  45549. onAfterCameraTeleport: Observable<Vector3>;
  45550. /**
  45551. * Observable raised when current selected mesh gets unselected
  45552. */
  45553. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45554. private _raySelectionPredicate;
  45555. /**
  45556. * To be optionaly changed by user to define custom ray selection
  45557. */
  45558. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45559. /**
  45560. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45561. */
  45562. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45563. /**
  45564. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45565. */
  45566. teleportationEnabled: boolean;
  45567. private _defaultHeight;
  45568. private _teleportationInitialized;
  45569. private _interactionsEnabled;
  45570. private _interactionsRequested;
  45571. private _displayGaze;
  45572. private _displayLaserPointer;
  45573. /**
  45574. * The mesh used to display where the user is going to teleport.
  45575. */
  45576. get teleportationTarget(): Mesh;
  45577. /**
  45578. * Sets the mesh to be used to display where the user is going to teleport.
  45579. */
  45580. set teleportationTarget(value: Mesh);
  45581. /**
  45582. * 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
  45583. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45584. * See http://doc.babylonjs.com/resources/baking_transformations
  45585. */
  45586. get gazeTrackerMesh(): Mesh;
  45587. set gazeTrackerMesh(value: Mesh);
  45588. /**
  45589. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45590. */
  45591. updateGazeTrackerScale: boolean;
  45592. /**
  45593. * If the gaze trackers color should be updated when selecting meshes
  45594. */
  45595. updateGazeTrackerColor: boolean;
  45596. /**
  45597. * If the controller laser color should be updated when selecting meshes
  45598. */
  45599. updateControllerLaserColor: boolean;
  45600. /**
  45601. * The gaze tracking mesh corresponding to the left controller
  45602. */
  45603. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45604. /**
  45605. * The gaze tracking mesh corresponding to the right controller
  45606. */
  45607. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45608. /**
  45609. * If the ray of the gaze should be displayed.
  45610. */
  45611. get displayGaze(): boolean;
  45612. /**
  45613. * Sets if the ray of the gaze should be displayed.
  45614. */
  45615. set displayGaze(value: boolean);
  45616. /**
  45617. * If the ray of the LaserPointer should be displayed.
  45618. */
  45619. get displayLaserPointer(): boolean;
  45620. /**
  45621. * Sets if the ray of the LaserPointer should be displayed.
  45622. */
  45623. set displayLaserPointer(value: boolean);
  45624. /**
  45625. * The deviceOrientationCamera used as the camera when not in VR.
  45626. */
  45627. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45628. /**
  45629. * Based on the current WebVR support, returns the current VR camera used.
  45630. */
  45631. get currentVRCamera(): Nullable<Camera>;
  45632. /**
  45633. * The webVRCamera which is used when in VR.
  45634. */
  45635. get webVRCamera(): WebVRFreeCamera;
  45636. /**
  45637. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45638. */
  45639. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45640. /**
  45641. * The html button that is used to trigger entering into VR.
  45642. */
  45643. get vrButton(): Nullable<HTMLButtonElement>;
  45644. private get _teleportationRequestInitiated();
  45645. /**
  45646. * Defines wether or not Pointer lock should be requested when switching to
  45647. * full screen.
  45648. */
  45649. requestPointerLockOnFullScreen: boolean;
  45650. /**
  45651. * If asking to force XR, this will be populated with the default xr experience
  45652. */
  45653. xr: WebXRDefaultExperience;
  45654. /**
  45655. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45656. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45657. */
  45658. xrTestDone: boolean;
  45659. /**
  45660. * Instantiates a VRExperienceHelper.
  45661. * Helps to quickly add VR support to an existing scene.
  45662. * @param scene The scene the VRExperienceHelper belongs to.
  45663. * @param webVROptions Options to modify the vr experience helper's behavior.
  45664. */
  45665. constructor(scene: Scene,
  45666. /** Options to modify the vr experience helper's behavior. */
  45667. webVROptions?: VRExperienceHelperOptions);
  45668. private completeVRInit;
  45669. private _onDefaultMeshLoaded;
  45670. private _onResize;
  45671. private _onFullscreenChange;
  45672. /**
  45673. * Gets a value indicating if we are currently in VR mode.
  45674. */
  45675. get isInVRMode(): boolean;
  45676. private onVrDisplayPresentChange;
  45677. private onVRDisplayChanged;
  45678. private moveButtonToBottomRight;
  45679. private displayVRButton;
  45680. private updateButtonVisibility;
  45681. private _cachedAngularSensibility;
  45682. /**
  45683. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45684. * Otherwise, will use the fullscreen API.
  45685. */
  45686. enterVR(): void;
  45687. /**
  45688. * Attempt to exit VR, or fullscreen.
  45689. */
  45690. exitVR(): void;
  45691. /**
  45692. * The position of the vr experience helper.
  45693. */
  45694. get position(): Vector3;
  45695. /**
  45696. * Sets the position of the vr experience helper.
  45697. */
  45698. set position(value: Vector3);
  45699. /**
  45700. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45701. */
  45702. enableInteractions(): void;
  45703. private get _noControllerIsActive();
  45704. private beforeRender;
  45705. private _isTeleportationFloor;
  45706. /**
  45707. * Adds a floor mesh to be used for teleportation.
  45708. * @param floorMesh the mesh to be used for teleportation.
  45709. */
  45710. addFloorMesh(floorMesh: Mesh): void;
  45711. /**
  45712. * Removes a floor mesh from being used for teleportation.
  45713. * @param floorMesh the mesh to be removed.
  45714. */
  45715. removeFloorMesh(floorMesh: Mesh): void;
  45716. /**
  45717. * Enables interactions and teleportation using the VR controllers and gaze.
  45718. * @param vrTeleportationOptions options to modify teleportation behavior.
  45719. */
  45720. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45721. private _onNewGamepadConnected;
  45722. private _tryEnableInteractionOnController;
  45723. private _onNewGamepadDisconnected;
  45724. private _enableInteractionOnController;
  45725. private _checkTeleportWithRay;
  45726. private _checkRotate;
  45727. private _checkTeleportBackwards;
  45728. private _enableTeleportationOnController;
  45729. private _createTeleportationCircles;
  45730. private _displayTeleportationTarget;
  45731. private _hideTeleportationTarget;
  45732. private _rotateCamera;
  45733. private _moveTeleportationSelectorTo;
  45734. private _workingVector;
  45735. private _workingQuaternion;
  45736. private _workingMatrix;
  45737. /**
  45738. * Time Constant Teleportation Mode
  45739. */
  45740. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45741. /**
  45742. * Speed Constant Teleportation Mode
  45743. */
  45744. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45745. /**
  45746. * Teleports the users feet to the desired location
  45747. * @param location The location where the user's feet should be placed
  45748. */
  45749. teleportCamera(location: Vector3): void;
  45750. private _convertNormalToDirectionOfRay;
  45751. private _castRayAndSelectObject;
  45752. private _notifySelectedMeshUnselected;
  45753. /**
  45754. * Permanently set new colors for the laser pointer
  45755. * @param color the new laser color
  45756. * @param pickedColor the new laser color when picked mesh detected
  45757. */
  45758. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45759. /**
  45760. * Permanently set new colors for the gaze pointer
  45761. * @param color the new gaze color
  45762. * @param pickedColor the new gaze color when picked mesh detected
  45763. */
  45764. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45765. /**
  45766. * Sets the color of the laser ray from the vr controllers.
  45767. * @param color new color for the ray.
  45768. */
  45769. changeLaserColor(color: Color3): void;
  45770. /**
  45771. * Sets the color of the ray from the vr headsets gaze.
  45772. * @param color new color for the ray.
  45773. */
  45774. changeGazeColor(color: Color3): void;
  45775. /**
  45776. * Exits VR and disposes of the vr experience helper
  45777. */
  45778. dispose(): void;
  45779. /**
  45780. * Gets the name of the VRExperienceHelper class
  45781. * @returns "VRExperienceHelper"
  45782. */
  45783. getClassName(): string;
  45784. }
  45785. }
  45786. declare module "babylonjs/Cameras/VR/index" {
  45787. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45788. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45789. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45790. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45791. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45792. export * from "babylonjs/Cameras/VR/webVRCamera";
  45793. }
  45794. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45795. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45796. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45797. import { Observable } from "babylonjs/Misc/observable";
  45798. import { Matrix } from "babylonjs/Maths/math.vector";
  45799. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45800. /**
  45801. * Options used for hit testing
  45802. */
  45803. export interface IWebXRHitTestOptions {
  45804. /**
  45805. * Only test when user interacted with the scene. Default - hit test every frame
  45806. */
  45807. testOnPointerDownOnly?: boolean;
  45808. /**
  45809. * The node to use to transform the local results to world coordinates
  45810. */
  45811. worldParentNode?: TransformNode;
  45812. }
  45813. /**
  45814. * Interface defining the babylon result of raycasting/hit-test
  45815. */
  45816. export interface IWebXRHitResult {
  45817. /**
  45818. * The native hit test result
  45819. */
  45820. xrHitResult: XRHitResult;
  45821. /**
  45822. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45823. */
  45824. transformationMatrix: Matrix;
  45825. }
  45826. /**
  45827. * The currently-working hit-test module.
  45828. * Hit test (or raycasting) is used to interact with the real world.
  45829. * For further information read here - https://github.com/immersive-web/hit-test
  45830. */
  45831. export class WebXRHitTestLegacy implements IWebXRFeature {
  45832. private _xrSessionManager;
  45833. /**
  45834. * options to use when constructing this feature
  45835. */
  45836. readonly options: IWebXRHitTestOptions;
  45837. /**
  45838. * The module's name
  45839. */
  45840. static readonly Name: string;
  45841. /**
  45842. * The (Babylon) version of this module.
  45843. * This is an integer representing the implementation version.
  45844. * This number does not correspond to the webxr specs version
  45845. */
  45846. static readonly Version: number;
  45847. /**
  45848. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45849. * @param event the (select) event to use to select with
  45850. * @param referenceSpace the reference space to use for this hit test
  45851. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45852. */
  45853. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45854. /**
  45855. * execute a hit test with an XR Ray
  45856. *
  45857. * @param xrSession a native xrSession that will execute this hit test
  45858. * @param xrRay the ray (position and direction) to use for raycasting
  45859. * @param referenceSpace native XR reference space to use for the hit-test
  45860. * @param filter filter function that will filter the results
  45861. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45862. */
  45863. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45864. /**
  45865. * Triggered when new babylon (transformed) hit test results are available
  45866. */
  45867. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45868. /**
  45869. * Creates a new instance of the (legacy version) hit test feature
  45870. * @param _xrSessionManager an instance of WebXRSessionManager
  45871. * @param options options to use when constructing this feature
  45872. */
  45873. constructor(_xrSessionManager: WebXRSessionManager,
  45874. /**
  45875. * options to use when constructing this feature
  45876. */
  45877. options?: IWebXRHitTestOptions);
  45878. private _onSelectEnabled;
  45879. private _xrFrameObserver;
  45880. private _attached;
  45881. /**
  45882. * Populated with the last native XR Hit Results
  45883. */
  45884. lastNativeXRHitResults: XRHitResult[];
  45885. /**
  45886. * attach this feature
  45887. * Will usually be called by the features manager
  45888. *
  45889. * @returns true if successful.
  45890. */
  45891. attach(): boolean;
  45892. /**
  45893. * detach this feature.
  45894. * Will usually be called by the features manager
  45895. *
  45896. * @returns true if successful.
  45897. */
  45898. detach(): boolean;
  45899. private _onHitTestResults;
  45900. private _onSelect;
  45901. /**
  45902. * Dispose this feature and all of the resources attached
  45903. */
  45904. dispose(): void;
  45905. }
  45906. }
  45907. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45908. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45909. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45910. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45911. import { Observable } from "babylonjs/Misc/observable";
  45912. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45913. /**
  45914. * Options used in the plane detector module
  45915. */
  45916. export interface IWebXRPlaneDetectorOptions {
  45917. /**
  45918. * The node to use to transform the local results to world coordinates
  45919. */
  45920. worldParentNode?: TransformNode;
  45921. }
  45922. /**
  45923. * A babylon interface for a webxr plane.
  45924. * A Plane is actually a polygon, built from N points in space
  45925. */
  45926. export interface IWebXRPlane {
  45927. /**
  45928. * a babylon-assigned ID for this polygon
  45929. */
  45930. id: number;
  45931. /**
  45932. * the native xr-plane object
  45933. */
  45934. xrPlane: XRPlane;
  45935. /**
  45936. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45937. */
  45938. polygonDefinition: Array<Vector3>;
  45939. /**
  45940. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45941. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45942. */
  45943. transformationMatrix: Matrix;
  45944. }
  45945. /**
  45946. * The plane detector is used to detect planes in the real world when in AR
  45947. * For more information see https://github.com/immersive-web/real-world-geometry/
  45948. */
  45949. export class WebXRPlaneDetector implements IWebXRFeature {
  45950. private _xrSessionManager;
  45951. private _options;
  45952. /**
  45953. * The module's name
  45954. */
  45955. static readonly Name: string;
  45956. /**
  45957. * The (Babylon) version of this module.
  45958. * This is an integer representing the implementation version.
  45959. * This number does not correspond to the webxr specs version
  45960. */
  45961. static readonly Version: number;
  45962. /**
  45963. * Observers registered here will be executed when a new plane was added to the session
  45964. */
  45965. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45966. /**
  45967. * Observers registered here will be executed when a plane is no longer detected in the session
  45968. */
  45969. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45970. /**
  45971. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45972. * This can execute N times every frame
  45973. */
  45974. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45975. private _enabled;
  45976. private _attached;
  45977. private _detectedPlanes;
  45978. private _lastFrameDetected;
  45979. private _observerTracked;
  45980. /**
  45981. * construct a new Plane Detector
  45982. * @param _xrSessionManager an instance of xr Session manager
  45983. * @param _options configuration to use when constructing this feature
  45984. */
  45985. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45986. /**
  45987. * attach this feature
  45988. * Will usually be called by the features manager
  45989. *
  45990. * @returns true if successful.
  45991. */
  45992. attach(): boolean;
  45993. /**
  45994. * detach this feature.
  45995. * Will usually be called by the features manager
  45996. *
  45997. * @returns true if successful.
  45998. */
  45999. detach(): boolean;
  46000. /**
  46001. * Dispose this feature and all of the resources attached
  46002. */
  46003. dispose(): void;
  46004. private _updatePlaneWithXRPlane;
  46005. /**
  46006. * avoiding using Array.find for global support.
  46007. * @param xrPlane the plane to find in the array
  46008. */
  46009. private findIndexInPlaneArray;
  46010. }
  46011. }
  46012. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46013. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46014. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46015. import { Observable } from "babylonjs/Misc/observable";
  46016. import { Matrix } from "babylonjs/Maths/math.vector";
  46017. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46018. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46019. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46020. /**
  46021. * Configuration options of the anchor system
  46022. */
  46023. export interface IWebXRAnchorSystemOptions {
  46024. /**
  46025. * a node that will be used to convert local to world coordinates
  46026. */
  46027. worldParentNode?: TransformNode;
  46028. /**
  46029. * should the anchor system use plane detection.
  46030. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46031. */
  46032. usePlaneDetection?: boolean;
  46033. /**
  46034. * Should a new anchor be added every time a select event is triggered
  46035. */
  46036. addAnchorOnSelect?: boolean;
  46037. }
  46038. /**
  46039. * A babylon container for an XR Anchor
  46040. */
  46041. export interface IWebXRAnchor {
  46042. /**
  46043. * A babylon-assigned ID for this anchor
  46044. */
  46045. id: number;
  46046. /**
  46047. * The native anchor object
  46048. */
  46049. xrAnchor: XRAnchor;
  46050. /**
  46051. * Transformation matrix to apply to an object attached to this anchor
  46052. */
  46053. transformationMatrix: Matrix;
  46054. }
  46055. /**
  46056. * An implementation of the anchor system of WebXR.
  46057. * Note that the current documented implementation is not available in any browser. Future implementations
  46058. * will use the frame to create an anchor and not the session or a detected plane
  46059. * For further information see https://github.com/immersive-web/anchors/
  46060. */
  46061. export class WebXRAnchorSystem implements IWebXRFeature {
  46062. private _xrSessionManager;
  46063. private _options;
  46064. /**
  46065. * The module's name
  46066. */
  46067. static readonly Name: string;
  46068. /**
  46069. * The (Babylon) version of this module.
  46070. * This is an integer representing the implementation version.
  46071. * This number does not correspond to the webxr specs version
  46072. */
  46073. static readonly Version: number;
  46074. /**
  46075. * Observers registered here will be executed when a new anchor was added to the session
  46076. */
  46077. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46078. /**
  46079. * Observers registered here will be executed when an existing anchor updates
  46080. * This can execute N times every frame
  46081. */
  46082. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46083. /**
  46084. * Observers registered here will be executed when an anchor was removed from the session
  46085. */
  46086. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46087. private _planeDetector;
  46088. private _hitTestModule;
  46089. private _enabled;
  46090. private _attached;
  46091. private _trackedAnchors;
  46092. private _lastFrameDetected;
  46093. private _observerTracked;
  46094. /**
  46095. * constructs a new anchor system
  46096. * @param _xrSessionManager an instance of WebXRSessionManager
  46097. * @param _options configuration object for this feature
  46098. */
  46099. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46100. /**
  46101. * set the plane detector to use in order to create anchors from frames
  46102. * @param planeDetector the plane-detector module to use
  46103. * @param enable enable plane-anchors. default is true
  46104. */
  46105. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46106. /**
  46107. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46108. * @param hitTestModule the hit-test module to use.
  46109. */
  46110. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46111. /**
  46112. * attach this feature
  46113. * Will usually be called by the features manager
  46114. *
  46115. * @returns true if successful.
  46116. */
  46117. attach(): boolean;
  46118. /**
  46119. * detach this feature.
  46120. * Will usually be called by the features manager
  46121. *
  46122. * @returns true if successful.
  46123. */
  46124. detach(): boolean;
  46125. /**
  46126. * Dispose this feature and all of the resources attached
  46127. */
  46128. dispose(): void;
  46129. private _onSelect;
  46130. /**
  46131. * Add anchor at a specific XR point.
  46132. *
  46133. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46134. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46135. * @returns a promise the fulfills when the anchor was created
  46136. */
  46137. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46138. private _updateAnchorWithXRFrame;
  46139. /**
  46140. * avoiding using Array.find for global support.
  46141. * @param xrAnchor the plane to find in the array
  46142. */
  46143. private _findIndexInAnchorArray;
  46144. }
  46145. }
  46146. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46147. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46148. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46150. import { Observable } from "babylonjs/Misc/observable";
  46151. /**
  46152. * Options interface for the background remover plugin
  46153. */
  46154. export interface IWebXRBackgroundRemoverOptions {
  46155. /**
  46156. * don't disable the environment helper
  46157. */
  46158. ignoreEnvironmentHelper?: boolean;
  46159. /**
  46160. * flags to configure the removal of the environment helper.
  46161. * If not set, the entire background will be removed. If set, flags should be set as well.
  46162. */
  46163. environmentHelperRemovalFlags?: {
  46164. /**
  46165. * Should the skybox be removed (default false)
  46166. */
  46167. skyBox?: boolean;
  46168. /**
  46169. * Should the ground be removed (default false)
  46170. */
  46171. ground?: boolean;
  46172. };
  46173. /**
  46174. * Further background meshes to disable when entering AR
  46175. */
  46176. backgroundMeshes?: AbstractMesh[];
  46177. }
  46178. /**
  46179. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46180. */
  46181. export class WebXRBackgroundRemover implements IWebXRFeature {
  46182. private _xrSessionManager;
  46183. /**
  46184. * read-only options to be used in this module
  46185. */
  46186. readonly options: IWebXRBackgroundRemoverOptions;
  46187. /**
  46188. * The module's name
  46189. */
  46190. static readonly Name: string;
  46191. /**
  46192. * The (Babylon) version of this module.
  46193. * This is an integer representing the implementation version.
  46194. * This number does not correspond to the webxr specs version
  46195. */
  46196. static readonly Version: number;
  46197. /**
  46198. * registered observers will be triggered when the background state changes
  46199. */
  46200. onBackgroundStateChangedObservable: Observable<boolean>;
  46201. /**
  46202. * constructs a new background remover module
  46203. * @param _xrSessionManager the session manager for this module
  46204. * @param options read-only options to be used in this module
  46205. */
  46206. constructor(_xrSessionManager: WebXRSessionManager,
  46207. /**
  46208. * read-only options to be used in this module
  46209. */
  46210. options?: IWebXRBackgroundRemoverOptions);
  46211. /**
  46212. * attach this feature
  46213. * Will usually be called by the features manager
  46214. *
  46215. * @returns true if successful.
  46216. */
  46217. attach(): boolean;
  46218. /**
  46219. * detach this feature.
  46220. * Will usually be called by the features manager
  46221. *
  46222. * @returns true if successful.
  46223. */
  46224. detach(): boolean;
  46225. private _setBackgroundState;
  46226. /**
  46227. * Dispose this feature and all of the resources attached
  46228. */
  46229. dispose(): void;
  46230. }
  46231. }
  46232. declare module "babylonjs/Cameras/XR/features/index" {
  46233. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46234. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46235. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46236. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46237. }
  46238. declare module "babylonjs/Cameras/XR/index" {
  46239. export * from "babylonjs/Cameras/XR/webXRCamera";
  46240. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46241. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46242. export * from "babylonjs/Cameras/XR/webXRInput";
  46243. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46244. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46245. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46246. export * from "babylonjs/Cameras/XR/webXRController";
  46247. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46248. export * from "babylonjs/Cameras/XR/webXRTypes";
  46249. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46250. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46251. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46252. export * from "babylonjs/Cameras/XR/features/index";
  46253. }
  46254. declare module "babylonjs/Cameras/RigModes/index" {
  46255. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46256. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46257. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46258. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46259. }
  46260. declare module "babylonjs/Cameras/index" {
  46261. export * from "babylonjs/Cameras/Inputs/index";
  46262. export * from "babylonjs/Cameras/cameraInputsManager";
  46263. export * from "babylonjs/Cameras/camera";
  46264. export * from "babylonjs/Cameras/targetCamera";
  46265. export * from "babylonjs/Cameras/freeCamera";
  46266. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46267. export * from "babylonjs/Cameras/touchCamera";
  46268. export * from "babylonjs/Cameras/arcRotateCamera";
  46269. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46270. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46271. export * from "babylonjs/Cameras/flyCamera";
  46272. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46273. export * from "babylonjs/Cameras/followCamera";
  46274. export * from "babylonjs/Cameras/followCameraInputsManager";
  46275. export * from "babylonjs/Cameras/gamepadCamera";
  46276. export * from "babylonjs/Cameras/Stereoscopic/index";
  46277. export * from "babylonjs/Cameras/universalCamera";
  46278. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46279. export * from "babylonjs/Cameras/VR/index";
  46280. export * from "babylonjs/Cameras/XR/index";
  46281. export * from "babylonjs/Cameras/RigModes/index";
  46282. }
  46283. declare module "babylonjs/Collisions/index" {
  46284. export * from "babylonjs/Collisions/collider";
  46285. export * from "babylonjs/Collisions/collisionCoordinator";
  46286. export * from "babylonjs/Collisions/pickingInfo";
  46287. export * from "babylonjs/Collisions/intersectionInfo";
  46288. export * from "babylonjs/Collisions/meshCollisionData";
  46289. }
  46290. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46291. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46292. import { Vector3 } from "babylonjs/Maths/math.vector";
  46293. import { Ray } from "babylonjs/Culling/ray";
  46294. import { Plane } from "babylonjs/Maths/math.plane";
  46295. /**
  46296. * Contains an array of blocks representing the octree
  46297. */
  46298. export interface IOctreeContainer<T> {
  46299. /**
  46300. * Blocks within the octree
  46301. */
  46302. blocks: Array<OctreeBlock<T>>;
  46303. }
  46304. /**
  46305. * Class used to store a cell in an octree
  46306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46307. */
  46308. export class OctreeBlock<T> {
  46309. /**
  46310. * Gets the content of the current block
  46311. */
  46312. entries: T[];
  46313. /**
  46314. * Gets the list of block children
  46315. */
  46316. blocks: Array<OctreeBlock<T>>;
  46317. private _depth;
  46318. private _maxDepth;
  46319. private _capacity;
  46320. private _minPoint;
  46321. private _maxPoint;
  46322. private _boundingVectors;
  46323. private _creationFunc;
  46324. /**
  46325. * Creates a new block
  46326. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46327. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46328. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46329. * @param depth defines the current depth of this block in the octree
  46330. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46331. * @param creationFunc defines a callback to call when an element is added to the block
  46332. */
  46333. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46334. /**
  46335. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46336. */
  46337. get capacity(): number;
  46338. /**
  46339. * Gets the minimum vector (in world space) of the block's bounding box
  46340. */
  46341. get minPoint(): Vector3;
  46342. /**
  46343. * Gets the maximum vector (in world space) of the block's bounding box
  46344. */
  46345. get maxPoint(): Vector3;
  46346. /**
  46347. * Add a new element to this block
  46348. * @param entry defines the element to add
  46349. */
  46350. addEntry(entry: T): void;
  46351. /**
  46352. * Remove an element from this block
  46353. * @param entry defines the element to remove
  46354. */
  46355. removeEntry(entry: T): void;
  46356. /**
  46357. * Add an array of elements to this block
  46358. * @param entries defines the array of elements to add
  46359. */
  46360. addEntries(entries: T[]): void;
  46361. /**
  46362. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46363. * @param frustumPlanes defines the frustum planes to test
  46364. * @param selection defines the array to store current content if selection is positive
  46365. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46366. */
  46367. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46368. /**
  46369. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46370. * @param sphereCenter defines the bounding sphere center
  46371. * @param sphereRadius defines the bounding sphere radius
  46372. * @param selection defines the array to store current content if selection is positive
  46373. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46374. */
  46375. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46376. /**
  46377. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46378. * @param ray defines the ray to test with
  46379. * @param selection defines the array to store current content if selection is positive
  46380. */
  46381. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46382. /**
  46383. * Subdivide the content into child blocks (this block will then be empty)
  46384. */
  46385. createInnerBlocks(): void;
  46386. /**
  46387. * @hidden
  46388. */
  46389. 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;
  46390. }
  46391. }
  46392. declare module "babylonjs/Culling/Octrees/octree" {
  46393. import { SmartArray } from "babylonjs/Misc/smartArray";
  46394. import { Vector3 } from "babylonjs/Maths/math.vector";
  46395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46397. import { Ray } from "babylonjs/Culling/ray";
  46398. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46399. import { Plane } from "babylonjs/Maths/math.plane";
  46400. /**
  46401. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46402. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46403. */
  46404. export class Octree<T> {
  46405. /** 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.) */
  46406. maxDepth: number;
  46407. /**
  46408. * Blocks within the octree containing objects
  46409. */
  46410. blocks: Array<OctreeBlock<T>>;
  46411. /**
  46412. * Content stored in the octree
  46413. */
  46414. dynamicContent: T[];
  46415. private _maxBlockCapacity;
  46416. private _selectionContent;
  46417. private _creationFunc;
  46418. /**
  46419. * Creates a octree
  46420. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46421. * @param creationFunc function to be used to instatiate the octree
  46422. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46423. * @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.)
  46424. */
  46425. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46426. /** 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.) */
  46427. maxDepth?: number);
  46428. /**
  46429. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46430. * @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);
  46431. * @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);
  46432. * @param entries meshes to be added to the octree blocks
  46433. */
  46434. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46435. /**
  46436. * Adds a mesh to the octree
  46437. * @param entry Mesh to add to the octree
  46438. */
  46439. addMesh(entry: T): void;
  46440. /**
  46441. * Remove an element from the octree
  46442. * @param entry defines the element to remove
  46443. */
  46444. removeMesh(entry: T): void;
  46445. /**
  46446. * Selects an array of meshes within the frustum
  46447. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46448. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46449. * @returns array of meshes within the frustum
  46450. */
  46451. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46452. /**
  46453. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46454. * @param sphereCenter defines the bounding sphere center
  46455. * @param sphereRadius defines the bounding sphere radius
  46456. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46457. * @returns an array of objects that intersect the sphere
  46458. */
  46459. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46460. /**
  46461. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46462. * @param ray defines the ray to test with
  46463. * @returns array of intersected objects
  46464. */
  46465. intersectsRay(ray: Ray): SmartArray<T>;
  46466. /**
  46467. * Adds a mesh into the octree block if it intersects the block
  46468. */
  46469. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46470. /**
  46471. * Adds a submesh into the octree block if it intersects the block
  46472. */
  46473. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46474. }
  46475. }
  46476. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46477. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46478. import { Scene } from "babylonjs/scene";
  46479. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46481. import { Ray } from "babylonjs/Culling/ray";
  46482. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46483. import { Collider } from "babylonjs/Collisions/collider";
  46484. module "babylonjs/scene" {
  46485. interface Scene {
  46486. /**
  46487. * @hidden
  46488. * Backing Filed
  46489. */
  46490. _selectionOctree: Octree<AbstractMesh>;
  46491. /**
  46492. * Gets the octree used to boost mesh selection (picking)
  46493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46494. */
  46495. selectionOctree: Octree<AbstractMesh>;
  46496. /**
  46497. * Creates or updates the octree used to boost selection (picking)
  46498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46499. * @param maxCapacity defines the maximum capacity per leaf
  46500. * @param maxDepth defines the maximum depth of the octree
  46501. * @returns an octree of AbstractMesh
  46502. */
  46503. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46504. }
  46505. }
  46506. module "babylonjs/Meshes/abstractMesh" {
  46507. interface AbstractMesh {
  46508. /**
  46509. * @hidden
  46510. * Backing Field
  46511. */
  46512. _submeshesOctree: Octree<SubMesh>;
  46513. /**
  46514. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46515. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46516. * @param maxCapacity defines the maximum size of each block (64 by default)
  46517. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46518. * @returns the new octree
  46519. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46521. */
  46522. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46523. }
  46524. }
  46525. /**
  46526. * Defines the octree scene component responsible to manage any octrees
  46527. * in a given scene.
  46528. */
  46529. export class OctreeSceneComponent {
  46530. /**
  46531. * The component name help to identify the component in the list of scene components.
  46532. */
  46533. readonly name: string;
  46534. /**
  46535. * The scene the component belongs to.
  46536. */
  46537. scene: Scene;
  46538. /**
  46539. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46540. */
  46541. readonly checksIsEnabled: boolean;
  46542. /**
  46543. * Creates a new instance of the component for the given scene
  46544. * @param scene Defines the scene to register the component in
  46545. */
  46546. constructor(scene: Scene);
  46547. /**
  46548. * Registers the component in a given scene
  46549. */
  46550. register(): void;
  46551. /**
  46552. * Return the list of active meshes
  46553. * @returns the list of active meshes
  46554. */
  46555. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46556. /**
  46557. * Return the list of active sub meshes
  46558. * @param mesh The mesh to get the candidates sub meshes from
  46559. * @returns the list of active sub meshes
  46560. */
  46561. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46562. private _tempRay;
  46563. /**
  46564. * Return the list of sub meshes intersecting with a given local ray
  46565. * @param mesh defines the mesh to find the submesh for
  46566. * @param localRay defines the ray in local space
  46567. * @returns the list of intersecting sub meshes
  46568. */
  46569. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46570. /**
  46571. * Return the list of sub meshes colliding with a collider
  46572. * @param mesh defines the mesh to find the submesh for
  46573. * @param collider defines the collider to evaluate the collision against
  46574. * @returns the list of colliding sub meshes
  46575. */
  46576. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46577. /**
  46578. * Rebuilds the elements related to this component in case of
  46579. * context lost for instance.
  46580. */
  46581. rebuild(): void;
  46582. /**
  46583. * Disposes the component and the associated ressources.
  46584. */
  46585. dispose(): void;
  46586. }
  46587. }
  46588. declare module "babylonjs/Culling/Octrees/index" {
  46589. export * from "babylonjs/Culling/Octrees/octree";
  46590. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46591. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46592. }
  46593. declare module "babylonjs/Culling/index" {
  46594. export * from "babylonjs/Culling/boundingBox";
  46595. export * from "babylonjs/Culling/boundingInfo";
  46596. export * from "babylonjs/Culling/boundingSphere";
  46597. export * from "babylonjs/Culling/Octrees/index";
  46598. export * from "babylonjs/Culling/ray";
  46599. }
  46600. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46601. import { IDisposable, Scene } from "babylonjs/scene";
  46602. import { Nullable } from "babylonjs/types";
  46603. import { Observable } from "babylonjs/Misc/observable";
  46604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46605. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46606. import { Camera } from "babylonjs/Cameras/camera";
  46607. /**
  46608. * Renders a layer on top of an existing scene
  46609. */
  46610. export class UtilityLayerRenderer implements IDisposable {
  46611. /** the original scene that will be rendered on top of */
  46612. originalScene: Scene;
  46613. private _pointerCaptures;
  46614. private _lastPointerEvents;
  46615. private static _DefaultUtilityLayer;
  46616. private static _DefaultKeepDepthUtilityLayer;
  46617. private _sharedGizmoLight;
  46618. private _renderCamera;
  46619. /**
  46620. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46621. * @returns the camera that is used when rendering the utility layer
  46622. */
  46623. getRenderCamera(): Nullable<Camera>;
  46624. /**
  46625. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46626. * @param cam the camera that should be used when rendering the utility layer
  46627. */
  46628. setRenderCamera(cam: Nullable<Camera>): void;
  46629. /**
  46630. * @hidden
  46631. * Light which used by gizmos to get light shading
  46632. */
  46633. _getSharedGizmoLight(): HemisphericLight;
  46634. /**
  46635. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46636. */
  46637. pickUtilitySceneFirst: boolean;
  46638. /**
  46639. * 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)
  46640. */
  46641. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46642. /**
  46643. * 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)
  46644. */
  46645. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46646. /**
  46647. * The scene that is rendered on top of the original scene
  46648. */
  46649. utilityLayerScene: Scene;
  46650. /**
  46651. * If the utility layer should automatically be rendered on top of existing scene
  46652. */
  46653. shouldRender: boolean;
  46654. /**
  46655. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46656. */
  46657. onlyCheckPointerDownEvents: boolean;
  46658. /**
  46659. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46660. */
  46661. processAllEvents: boolean;
  46662. /**
  46663. * Observable raised when the pointer move from the utility layer scene to the main scene
  46664. */
  46665. onPointerOutObservable: Observable<number>;
  46666. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46667. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46668. private _afterRenderObserver;
  46669. private _sceneDisposeObserver;
  46670. private _originalPointerObserver;
  46671. /**
  46672. * Instantiates a UtilityLayerRenderer
  46673. * @param originalScene the original scene that will be rendered on top of
  46674. * @param handleEvents boolean indicating if the utility layer should handle events
  46675. */
  46676. constructor(
  46677. /** the original scene that will be rendered on top of */
  46678. originalScene: Scene, handleEvents?: boolean);
  46679. private _notifyObservers;
  46680. /**
  46681. * Renders the utility layers scene on top of the original scene
  46682. */
  46683. render(): void;
  46684. /**
  46685. * Disposes of the renderer
  46686. */
  46687. dispose(): void;
  46688. private _updateCamera;
  46689. }
  46690. }
  46691. declare module "babylonjs/Gizmos/gizmo" {
  46692. import { Nullable } from "babylonjs/types";
  46693. import { IDisposable } from "babylonjs/scene";
  46694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46695. import { Mesh } from "babylonjs/Meshes/mesh";
  46696. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46697. /**
  46698. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46699. */
  46700. export class Gizmo implements IDisposable {
  46701. /** The utility layer the gizmo will be added to */
  46702. gizmoLayer: UtilityLayerRenderer;
  46703. /**
  46704. * The root mesh of the gizmo
  46705. */
  46706. _rootMesh: Mesh;
  46707. private _attachedMesh;
  46708. /**
  46709. * Ratio for the scale of the gizmo (Default: 1)
  46710. */
  46711. scaleRatio: number;
  46712. /**
  46713. * If a custom mesh has been set (Default: false)
  46714. */
  46715. protected _customMeshSet: boolean;
  46716. /**
  46717. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46718. * * When set, interactions will be enabled
  46719. */
  46720. get attachedMesh(): Nullable<AbstractMesh>;
  46721. set attachedMesh(value: Nullable<AbstractMesh>);
  46722. /**
  46723. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46724. * @param mesh The mesh to replace the default mesh of the gizmo
  46725. */
  46726. setCustomMesh(mesh: Mesh): void;
  46727. /**
  46728. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46729. */
  46730. updateGizmoRotationToMatchAttachedMesh: boolean;
  46731. /**
  46732. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46733. */
  46734. updateGizmoPositionToMatchAttachedMesh: boolean;
  46735. /**
  46736. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46737. */
  46738. updateScale: boolean;
  46739. protected _interactionsEnabled: boolean;
  46740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46741. private _beforeRenderObserver;
  46742. private _tempVector;
  46743. /**
  46744. * Creates a gizmo
  46745. * @param gizmoLayer The utility layer the gizmo will be added to
  46746. */
  46747. constructor(
  46748. /** The utility layer the gizmo will be added to */
  46749. gizmoLayer?: UtilityLayerRenderer);
  46750. /**
  46751. * Updates the gizmo to match the attached mesh's position/rotation
  46752. */
  46753. protected _update(): void;
  46754. /**
  46755. * Disposes of the gizmo
  46756. */
  46757. dispose(): void;
  46758. }
  46759. }
  46760. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46761. import { Observable } from "babylonjs/Misc/observable";
  46762. import { Nullable } from "babylonjs/types";
  46763. import { Vector3 } from "babylonjs/Maths/math.vector";
  46764. import { Color3 } from "babylonjs/Maths/math.color";
  46765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46767. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46768. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46769. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46770. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46771. import { Scene } from "babylonjs/scene";
  46772. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46773. /**
  46774. * Single plane drag gizmo
  46775. */
  46776. export class PlaneDragGizmo extends Gizmo {
  46777. /**
  46778. * Drag behavior responsible for the gizmos dragging interactions
  46779. */
  46780. dragBehavior: PointerDragBehavior;
  46781. private _pointerObserver;
  46782. /**
  46783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46784. */
  46785. snapDistance: number;
  46786. /**
  46787. * Event that fires each time the gizmo snaps to a new location.
  46788. * * snapDistance is the the change in distance
  46789. */
  46790. onSnapObservable: Observable<{
  46791. snapDistance: number;
  46792. }>;
  46793. private _plane;
  46794. private _coloredMaterial;
  46795. private _hoverMaterial;
  46796. private _isEnabled;
  46797. private _parent;
  46798. /** @hidden */
  46799. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46800. /** @hidden */
  46801. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46802. /**
  46803. * Creates a PlaneDragGizmo
  46804. * @param gizmoLayer The utility layer the gizmo will be added to
  46805. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46806. * @param color The color of the gizmo
  46807. */
  46808. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46810. /**
  46811. * If the gizmo is enabled
  46812. */
  46813. set isEnabled(value: boolean);
  46814. get isEnabled(): boolean;
  46815. /**
  46816. * Disposes of the gizmo
  46817. */
  46818. dispose(): void;
  46819. }
  46820. }
  46821. declare module "babylonjs/Gizmos/positionGizmo" {
  46822. import { Observable } from "babylonjs/Misc/observable";
  46823. import { Nullable } from "babylonjs/types";
  46824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46825. import { Mesh } from "babylonjs/Meshes/mesh";
  46826. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46827. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46828. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46829. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46830. /**
  46831. * Gizmo that enables dragging a mesh along 3 axis
  46832. */
  46833. export class PositionGizmo extends Gizmo {
  46834. /**
  46835. * Internal gizmo used for interactions on the x axis
  46836. */
  46837. xGizmo: AxisDragGizmo;
  46838. /**
  46839. * Internal gizmo used for interactions on the y axis
  46840. */
  46841. yGizmo: AxisDragGizmo;
  46842. /**
  46843. * Internal gizmo used for interactions on the z axis
  46844. */
  46845. zGizmo: AxisDragGizmo;
  46846. /**
  46847. * Internal gizmo used for interactions on the yz plane
  46848. */
  46849. xPlaneGizmo: PlaneDragGizmo;
  46850. /**
  46851. * Internal gizmo used for interactions on the xz plane
  46852. */
  46853. yPlaneGizmo: PlaneDragGizmo;
  46854. /**
  46855. * Internal gizmo used for interactions on the xy plane
  46856. */
  46857. zPlaneGizmo: PlaneDragGizmo;
  46858. /**
  46859. * private variables
  46860. */
  46861. private _meshAttached;
  46862. private _updateGizmoRotationToMatchAttachedMesh;
  46863. private _snapDistance;
  46864. private _scaleRatio;
  46865. /** Fires an event when any of it's sub gizmos are dragged */
  46866. onDragStartObservable: Observable<unknown>;
  46867. /** Fires an event when any of it's sub gizmos are released from dragging */
  46868. onDragEndObservable: Observable<unknown>;
  46869. /**
  46870. * If set to true, planar drag is enabled
  46871. */
  46872. private _planarGizmoEnabled;
  46873. get attachedMesh(): Nullable<AbstractMesh>;
  46874. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46875. /**
  46876. * Creates a PositionGizmo
  46877. * @param gizmoLayer The utility layer the gizmo will be added to
  46878. */
  46879. constructor(gizmoLayer?: UtilityLayerRenderer);
  46880. /**
  46881. * If the planar drag gizmo is enabled
  46882. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46883. */
  46884. set planarGizmoEnabled(value: boolean);
  46885. get planarGizmoEnabled(): boolean;
  46886. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46887. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46888. /**
  46889. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46890. */
  46891. set snapDistance(value: number);
  46892. get snapDistance(): number;
  46893. /**
  46894. * Ratio for the scale of the gizmo (Default: 1)
  46895. */
  46896. set scaleRatio(value: number);
  46897. get scaleRatio(): number;
  46898. /**
  46899. * Disposes of the gizmo
  46900. */
  46901. dispose(): void;
  46902. /**
  46903. * CustomMeshes are not supported by this gizmo
  46904. * @param mesh The mesh to replace the default mesh of the gizmo
  46905. */
  46906. setCustomMesh(mesh: Mesh): void;
  46907. }
  46908. }
  46909. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46910. import { Observable } from "babylonjs/Misc/observable";
  46911. import { Nullable } from "babylonjs/types";
  46912. import { Vector3 } from "babylonjs/Maths/math.vector";
  46913. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46915. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46916. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46917. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46918. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46919. import { Scene } from "babylonjs/scene";
  46920. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46921. import { Color3 } from "babylonjs/Maths/math.color";
  46922. /**
  46923. * Single axis drag gizmo
  46924. */
  46925. export class AxisDragGizmo extends Gizmo {
  46926. /**
  46927. * Drag behavior responsible for the gizmos dragging interactions
  46928. */
  46929. dragBehavior: PointerDragBehavior;
  46930. private _pointerObserver;
  46931. /**
  46932. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46933. */
  46934. snapDistance: number;
  46935. /**
  46936. * Event that fires each time the gizmo snaps to a new location.
  46937. * * snapDistance is the the change in distance
  46938. */
  46939. onSnapObservable: Observable<{
  46940. snapDistance: number;
  46941. }>;
  46942. private _isEnabled;
  46943. private _parent;
  46944. private _arrow;
  46945. private _coloredMaterial;
  46946. private _hoverMaterial;
  46947. /** @hidden */
  46948. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46949. /** @hidden */
  46950. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46951. /**
  46952. * Creates an AxisDragGizmo
  46953. * @param gizmoLayer The utility layer the gizmo will be added to
  46954. * @param dragAxis The axis which the gizmo will be able to drag on
  46955. * @param color The color of the gizmo
  46956. */
  46957. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46958. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46959. /**
  46960. * If the gizmo is enabled
  46961. */
  46962. set isEnabled(value: boolean);
  46963. get isEnabled(): boolean;
  46964. /**
  46965. * Disposes of the gizmo
  46966. */
  46967. dispose(): void;
  46968. }
  46969. }
  46970. declare module "babylonjs/Debug/axesViewer" {
  46971. import { Vector3 } from "babylonjs/Maths/math.vector";
  46972. import { Nullable } from "babylonjs/types";
  46973. import { Scene } from "babylonjs/scene";
  46974. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46975. /**
  46976. * The Axes viewer will show 3 axes in a specific point in space
  46977. */
  46978. export class AxesViewer {
  46979. private _xAxis;
  46980. private _yAxis;
  46981. private _zAxis;
  46982. private _scaleLinesFactor;
  46983. private _instanced;
  46984. /**
  46985. * Gets the hosting scene
  46986. */
  46987. scene: Scene;
  46988. /**
  46989. * Gets or sets a number used to scale line length
  46990. */
  46991. scaleLines: number;
  46992. /** Gets the node hierarchy used to render x-axis */
  46993. get xAxis(): TransformNode;
  46994. /** Gets the node hierarchy used to render y-axis */
  46995. get yAxis(): TransformNode;
  46996. /** Gets the node hierarchy used to render z-axis */
  46997. get zAxis(): TransformNode;
  46998. /**
  46999. * Creates a new AxesViewer
  47000. * @param scene defines the hosting scene
  47001. * @param scaleLines defines a number used to scale line length (1 by default)
  47002. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47003. * @param xAxis defines the node hierarchy used to render the x-axis
  47004. * @param yAxis defines the node hierarchy used to render the y-axis
  47005. * @param zAxis defines the node hierarchy used to render the z-axis
  47006. */
  47007. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47008. /**
  47009. * Force the viewer to update
  47010. * @param position defines the position of the viewer
  47011. * @param xaxis defines the x axis of the viewer
  47012. * @param yaxis defines the y axis of the viewer
  47013. * @param zaxis defines the z axis of the viewer
  47014. */
  47015. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47016. /**
  47017. * Creates an instance of this axes viewer.
  47018. * @returns a new axes viewer with instanced meshes
  47019. */
  47020. createInstance(): AxesViewer;
  47021. /** Releases resources */
  47022. dispose(): void;
  47023. private static _SetRenderingGroupId;
  47024. }
  47025. }
  47026. declare module "babylonjs/Debug/boneAxesViewer" {
  47027. import { Nullable } from "babylonjs/types";
  47028. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47029. import { Vector3 } from "babylonjs/Maths/math.vector";
  47030. import { Mesh } from "babylonjs/Meshes/mesh";
  47031. import { Bone } from "babylonjs/Bones/bone";
  47032. import { Scene } from "babylonjs/scene";
  47033. /**
  47034. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47035. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47036. */
  47037. export class BoneAxesViewer extends AxesViewer {
  47038. /**
  47039. * Gets or sets the target mesh where to display the axes viewer
  47040. */
  47041. mesh: Nullable<Mesh>;
  47042. /**
  47043. * Gets or sets the target bone where to display the axes viewer
  47044. */
  47045. bone: Nullable<Bone>;
  47046. /** Gets current position */
  47047. pos: Vector3;
  47048. /** Gets direction of X axis */
  47049. xaxis: Vector3;
  47050. /** Gets direction of Y axis */
  47051. yaxis: Vector3;
  47052. /** Gets direction of Z axis */
  47053. zaxis: Vector3;
  47054. /**
  47055. * Creates a new BoneAxesViewer
  47056. * @param scene defines the hosting scene
  47057. * @param bone defines the target bone
  47058. * @param mesh defines the target mesh
  47059. * @param scaleLines defines a scaling factor for line length (1 by default)
  47060. */
  47061. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47062. /**
  47063. * Force the viewer to update
  47064. */
  47065. update(): void;
  47066. /** Releases resources */
  47067. dispose(): void;
  47068. }
  47069. }
  47070. declare module "babylonjs/Debug/debugLayer" {
  47071. import { Scene } from "babylonjs/scene";
  47072. /**
  47073. * Interface used to define scene explorer extensibility option
  47074. */
  47075. export interface IExplorerExtensibilityOption {
  47076. /**
  47077. * Define the option label
  47078. */
  47079. label: string;
  47080. /**
  47081. * Defines the action to execute on click
  47082. */
  47083. action: (entity: any) => void;
  47084. }
  47085. /**
  47086. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47087. */
  47088. export interface IExplorerExtensibilityGroup {
  47089. /**
  47090. * Defines a predicate to test if a given type mut be extended
  47091. */
  47092. predicate: (entity: any) => boolean;
  47093. /**
  47094. * Gets the list of options added to a type
  47095. */
  47096. entries: IExplorerExtensibilityOption[];
  47097. }
  47098. /**
  47099. * Interface used to define the options to use to create the Inspector
  47100. */
  47101. export interface IInspectorOptions {
  47102. /**
  47103. * Display in overlay mode (default: false)
  47104. */
  47105. overlay?: boolean;
  47106. /**
  47107. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47108. */
  47109. globalRoot?: HTMLElement;
  47110. /**
  47111. * Display the Scene explorer
  47112. */
  47113. showExplorer?: boolean;
  47114. /**
  47115. * Display the property inspector
  47116. */
  47117. showInspector?: boolean;
  47118. /**
  47119. * Display in embed mode (both panes on the right)
  47120. */
  47121. embedMode?: boolean;
  47122. /**
  47123. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47124. */
  47125. handleResize?: boolean;
  47126. /**
  47127. * Allow the panes to popup (default: true)
  47128. */
  47129. enablePopup?: boolean;
  47130. /**
  47131. * Allow the panes to be closed by users (default: true)
  47132. */
  47133. enableClose?: boolean;
  47134. /**
  47135. * Optional list of extensibility entries
  47136. */
  47137. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47138. /**
  47139. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47140. */
  47141. inspectorURL?: string;
  47142. /**
  47143. * Optional initial tab (default to DebugLayerTab.Properties)
  47144. */
  47145. initialTab?: DebugLayerTab;
  47146. }
  47147. module "babylonjs/scene" {
  47148. interface Scene {
  47149. /**
  47150. * @hidden
  47151. * Backing field
  47152. */
  47153. _debugLayer: DebugLayer;
  47154. /**
  47155. * Gets the debug layer (aka Inspector) associated with the scene
  47156. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47157. */
  47158. debugLayer: DebugLayer;
  47159. }
  47160. }
  47161. /**
  47162. * Enum of inspector action tab
  47163. */
  47164. export enum DebugLayerTab {
  47165. /**
  47166. * Properties tag (default)
  47167. */
  47168. Properties = 0,
  47169. /**
  47170. * Debug tab
  47171. */
  47172. Debug = 1,
  47173. /**
  47174. * Statistics tab
  47175. */
  47176. Statistics = 2,
  47177. /**
  47178. * Tools tab
  47179. */
  47180. Tools = 3,
  47181. /**
  47182. * Settings tab
  47183. */
  47184. Settings = 4
  47185. }
  47186. /**
  47187. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47188. * what is happening in your scene
  47189. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47190. */
  47191. export class DebugLayer {
  47192. /**
  47193. * Define the url to get the inspector script from.
  47194. * By default it uses the babylonjs CDN.
  47195. * @ignoreNaming
  47196. */
  47197. static InspectorURL: string;
  47198. private _scene;
  47199. private BJSINSPECTOR;
  47200. private _onPropertyChangedObservable?;
  47201. /**
  47202. * Observable triggered when a property is changed through the inspector.
  47203. */
  47204. get onPropertyChangedObservable(): any;
  47205. /**
  47206. * Instantiates a new debug layer.
  47207. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47208. * what is happening in your scene
  47209. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47210. * @param scene Defines the scene to inspect
  47211. */
  47212. constructor(scene: Scene);
  47213. /** Creates the inspector window. */
  47214. private _createInspector;
  47215. /**
  47216. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47217. * @param entity defines the entity to select
  47218. * @param lineContainerTitle defines the specific block to highlight
  47219. */
  47220. select(entity: any, lineContainerTitle?: string): void;
  47221. /** Get the inspector from bundle or global */
  47222. private _getGlobalInspector;
  47223. /**
  47224. * Get if the inspector is visible or not.
  47225. * @returns true if visible otherwise, false
  47226. */
  47227. isVisible(): boolean;
  47228. /**
  47229. * Hide the inspector and close its window.
  47230. */
  47231. hide(): void;
  47232. /**
  47233. * Launch the debugLayer.
  47234. * @param config Define the configuration of the inspector
  47235. * @return a promise fulfilled when the debug layer is visible
  47236. */
  47237. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47238. }
  47239. }
  47240. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47241. import { Nullable } from "babylonjs/types";
  47242. import { Scene } from "babylonjs/scene";
  47243. import { Vector4 } from "babylonjs/Maths/math.vector";
  47244. import { Color4 } from "babylonjs/Maths/math.color";
  47245. import { Mesh } from "babylonjs/Meshes/mesh";
  47246. /**
  47247. * Class containing static functions to help procedurally build meshes
  47248. */
  47249. export class BoxBuilder {
  47250. /**
  47251. * Creates a box mesh
  47252. * * The parameter `size` sets the size (float) of each box side (default 1)
  47253. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47254. * * 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)
  47255. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47259. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47260. * @param name defines the name of the mesh
  47261. * @param options defines the options used to create the mesh
  47262. * @param scene defines the hosting scene
  47263. * @returns the box mesh
  47264. */
  47265. static CreateBox(name: string, options: {
  47266. size?: number;
  47267. width?: number;
  47268. height?: number;
  47269. depth?: number;
  47270. faceUV?: Vector4[];
  47271. faceColors?: Color4[];
  47272. sideOrientation?: number;
  47273. frontUVs?: Vector4;
  47274. backUVs?: Vector4;
  47275. wrap?: boolean;
  47276. topBaseAt?: number;
  47277. bottomBaseAt?: number;
  47278. updatable?: boolean;
  47279. }, scene?: Nullable<Scene>): Mesh;
  47280. }
  47281. }
  47282. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47283. import { Vector4 } from "babylonjs/Maths/math.vector";
  47284. import { Mesh } from "babylonjs/Meshes/mesh";
  47285. import { Scene } from "babylonjs/scene";
  47286. import { Nullable } from "babylonjs/types";
  47287. /**
  47288. * Class containing static functions to help procedurally build meshes
  47289. */
  47290. export class SphereBuilder {
  47291. /**
  47292. * Creates a sphere mesh
  47293. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47294. * * 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`)
  47295. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47296. * * 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
  47297. * * 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)
  47298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47301. * @param name defines the name of the mesh
  47302. * @param options defines the options used to create the mesh
  47303. * @param scene defines the hosting scene
  47304. * @returns the sphere mesh
  47305. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47306. */
  47307. static CreateSphere(name: string, options: {
  47308. segments?: number;
  47309. diameter?: number;
  47310. diameterX?: number;
  47311. diameterY?: number;
  47312. diameterZ?: number;
  47313. arc?: number;
  47314. slice?: number;
  47315. sideOrientation?: number;
  47316. frontUVs?: Vector4;
  47317. backUVs?: Vector4;
  47318. updatable?: boolean;
  47319. }, scene?: Nullable<Scene>): Mesh;
  47320. }
  47321. }
  47322. declare module "babylonjs/Debug/physicsViewer" {
  47323. import { Nullable } from "babylonjs/types";
  47324. import { Scene } from "babylonjs/scene";
  47325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47326. import { Mesh } from "babylonjs/Meshes/mesh";
  47327. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47328. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47329. /**
  47330. * Used to show the physics impostor around the specific mesh
  47331. */
  47332. export class PhysicsViewer {
  47333. /** @hidden */
  47334. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47335. /** @hidden */
  47336. protected _meshes: Array<Nullable<AbstractMesh>>;
  47337. /** @hidden */
  47338. protected _scene: Nullable<Scene>;
  47339. /** @hidden */
  47340. protected _numMeshes: number;
  47341. /** @hidden */
  47342. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47343. private _renderFunction;
  47344. private _utilityLayer;
  47345. private _debugBoxMesh;
  47346. private _debugSphereMesh;
  47347. private _debugCylinderMesh;
  47348. private _debugMaterial;
  47349. private _debugMeshMeshes;
  47350. /**
  47351. * Creates a new PhysicsViewer
  47352. * @param scene defines the hosting scene
  47353. */
  47354. constructor(scene: Scene);
  47355. /** @hidden */
  47356. protected _updateDebugMeshes(): void;
  47357. /**
  47358. * Renders a specified physic impostor
  47359. * @param impostor defines the impostor to render
  47360. * @param targetMesh defines the mesh represented by the impostor
  47361. * @returns the new debug mesh used to render the impostor
  47362. */
  47363. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47364. /**
  47365. * Hides a specified physic impostor
  47366. * @param impostor defines the impostor to hide
  47367. */
  47368. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47369. private _getDebugMaterial;
  47370. private _getDebugBoxMesh;
  47371. private _getDebugSphereMesh;
  47372. private _getDebugCylinderMesh;
  47373. private _getDebugMeshMesh;
  47374. private _getDebugMesh;
  47375. /** Releases all resources */
  47376. dispose(): void;
  47377. }
  47378. }
  47379. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47380. import { Vector3 } from "babylonjs/Maths/math.vector";
  47381. import { Color4 } from "babylonjs/Maths/math.color";
  47382. import { Nullable } from "babylonjs/types";
  47383. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47384. import { Scene } from "babylonjs/scene";
  47385. /**
  47386. * Class containing static functions to help procedurally build meshes
  47387. */
  47388. export class LinesBuilder {
  47389. /**
  47390. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47391. * * 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
  47392. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47393. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47394. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47395. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47396. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47397. * * 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
  47398. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47401. * @param name defines the name of the new line system
  47402. * @param options defines the options used to create the line system
  47403. * @param scene defines the hosting scene
  47404. * @returns a new line system mesh
  47405. */
  47406. static CreateLineSystem(name: string, options: {
  47407. lines: Vector3[][];
  47408. updatable?: boolean;
  47409. instance?: Nullable<LinesMesh>;
  47410. colors?: Nullable<Color4[][]>;
  47411. useVertexAlpha?: boolean;
  47412. }, scene: Nullable<Scene>): LinesMesh;
  47413. /**
  47414. * Creates a line mesh
  47415. * 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
  47416. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47417. * * The parameter `points` is an array successive Vector3
  47418. * * 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
  47419. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47420. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47421. * * When updating an instance, remember that only point positions can change, not the number of points
  47422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47424. * @param name defines the name of the new line system
  47425. * @param options defines the options used to create the line system
  47426. * @param scene defines the hosting scene
  47427. * @returns a new line mesh
  47428. */
  47429. static CreateLines(name: string, options: {
  47430. points: Vector3[];
  47431. updatable?: boolean;
  47432. instance?: Nullable<LinesMesh>;
  47433. colors?: Color4[];
  47434. useVertexAlpha?: boolean;
  47435. }, scene?: Nullable<Scene>): LinesMesh;
  47436. /**
  47437. * Creates a dashed line mesh
  47438. * * 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
  47439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47440. * * The parameter `points` is an array successive Vector3
  47441. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47442. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47443. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47444. * * 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
  47445. * * When updating an instance, remember that only point positions can change, not the number of points
  47446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47447. * @param name defines the name of the mesh
  47448. * @param options defines the options used to create the mesh
  47449. * @param scene defines the hosting scene
  47450. * @returns the dashed line mesh
  47451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47452. */
  47453. static CreateDashedLines(name: string, options: {
  47454. points: Vector3[];
  47455. dashSize?: number;
  47456. gapSize?: number;
  47457. dashNb?: number;
  47458. updatable?: boolean;
  47459. instance?: LinesMesh;
  47460. }, scene?: Nullable<Scene>): LinesMesh;
  47461. }
  47462. }
  47463. declare module "babylonjs/Debug/rayHelper" {
  47464. import { Nullable } from "babylonjs/types";
  47465. import { Ray } from "babylonjs/Culling/ray";
  47466. import { Vector3 } from "babylonjs/Maths/math.vector";
  47467. import { Color3 } from "babylonjs/Maths/math.color";
  47468. import { Scene } from "babylonjs/scene";
  47469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47470. import "babylonjs/Meshes/Builders/linesBuilder";
  47471. /**
  47472. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47473. * in order to better appreciate the issue one might have.
  47474. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47475. */
  47476. export class RayHelper {
  47477. /**
  47478. * Defines the ray we are currently tryin to visualize.
  47479. */
  47480. ray: Nullable<Ray>;
  47481. private _renderPoints;
  47482. private _renderLine;
  47483. private _renderFunction;
  47484. private _scene;
  47485. private _updateToMeshFunction;
  47486. private _attachedToMesh;
  47487. private _meshSpaceDirection;
  47488. private _meshSpaceOrigin;
  47489. /**
  47490. * Helper function to create a colored helper in a scene in one line.
  47491. * @param ray Defines the ray we are currently tryin to visualize
  47492. * @param scene Defines the scene the ray is used in
  47493. * @param color Defines the color we want to see the ray in
  47494. * @returns The newly created ray helper.
  47495. */
  47496. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47497. /**
  47498. * Instantiate a new ray helper.
  47499. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47500. * in order to better appreciate the issue one might have.
  47501. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47502. * @param ray Defines the ray we are currently tryin to visualize
  47503. */
  47504. constructor(ray: Ray);
  47505. /**
  47506. * Shows the ray we are willing to debug.
  47507. * @param scene Defines the scene the ray needs to be rendered in
  47508. * @param color Defines the color the ray needs to be rendered in
  47509. */
  47510. show(scene: Scene, color?: Color3): void;
  47511. /**
  47512. * Hides the ray we are debugging.
  47513. */
  47514. hide(): void;
  47515. private _render;
  47516. /**
  47517. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47518. * @param mesh Defines the mesh we want the helper attached to
  47519. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47520. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47521. * @param length Defines the length of the ray
  47522. */
  47523. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47524. /**
  47525. * Detach the ray helper from the mesh it has previously been attached to.
  47526. */
  47527. detachFromMesh(): void;
  47528. private _updateToMesh;
  47529. /**
  47530. * Dispose the helper and release its associated resources.
  47531. */
  47532. dispose(): void;
  47533. }
  47534. }
  47535. declare module "babylonjs/Debug/skeletonViewer" {
  47536. import { Color3 } from "babylonjs/Maths/math.color";
  47537. import { Scene } from "babylonjs/scene";
  47538. import { Nullable } from "babylonjs/types";
  47539. import { Skeleton } from "babylonjs/Bones/skeleton";
  47540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47541. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47542. /**
  47543. * Class used to render a debug view of a given skeleton
  47544. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47545. */
  47546. export class SkeletonViewer {
  47547. /** defines the skeleton to render */
  47548. skeleton: Skeleton;
  47549. /** defines the mesh attached to the skeleton */
  47550. mesh: AbstractMesh;
  47551. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47552. autoUpdateBonesMatrices: boolean;
  47553. /** defines the rendering group id to use with the viewer */
  47554. renderingGroupId: number;
  47555. /** Gets or sets the color used to render the skeleton */
  47556. color: Color3;
  47557. private _scene;
  47558. private _debugLines;
  47559. private _debugMesh;
  47560. private _isEnabled;
  47561. private _renderFunction;
  47562. private _utilityLayer;
  47563. /**
  47564. * Returns the mesh used to render the bones
  47565. */
  47566. get debugMesh(): Nullable<LinesMesh>;
  47567. /**
  47568. * Creates a new SkeletonViewer
  47569. * @param skeleton defines the skeleton to render
  47570. * @param mesh defines the mesh attached to the skeleton
  47571. * @param scene defines the hosting scene
  47572. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47573. * @param renderingGroupId defines the rendering group id to use with the viewer
  47574. */
  47575. constructor(
  47576. /** defines the skeleton to render */
  47577. skeleton: Skeleton,
  47578. /** defines the mesh attached to the skeleton */
  47579. mesh: AbstractMesh, scene: Scene,
  47580. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47581. autoUpdateBonesMatrices?: boolean,
  47582. /** defines the rendering group id to use with the viewer */
  47583. renderingGroupId?: number);
  47584. /** Gets or sets a boolean indicating if the viewer is enabled */
  47585. set isEnabled(value: boolean);
  47586. get isEnabled(): boolean;
  47587. private _getBonePosition;
  47588. private _getLinesForBonesWithLength;
  47589. private _getLinesForBonesNoLength;
  47590. /** Update the viewer to sync with current skeleton state */
  47591. update(): void;
  47592. /** Release associated resources */
  47593. dispose(): void;
  47594. }
  47595. }
  47596. declare module "babylonjs/Debug/index" {
  47597. export * from "babylonjs/Debug/axesViewer";
  47598. export * from "babylonjs/Debug/boneAxesViewer";
  47599. export * from "babylonjs/Debug/debugLayer";
  47600. export * from "babylonjs/Debug/physicsViewer";
  47601. export * from "babylonjs/Debug/rayHelper";
  47602. export * from "babylonjs/Debug/skeletonViewer";
  47603. }
  47604. declare module "babylonjs/Engines/nullEngine" {
  47605. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47606. import { Scene } from "babylonjs/scene";
  47607. import { Engine } from "babylonjs/Engines/engine";
  47608. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47609. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47610. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47611. import { Effect } from "babylonjs/Materials/effect";
  47612. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47613. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47614. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47615. /**
  47616. * Options to create the null engine
  47617. */
  47618. export class NullEngineOptions {
  47619. /**
  47620. * Render width (Default: 512)
  47621. */
  47622. renderWidth: number;
  47623. /**
  47624. * Render height (Default: 256)
  47625. */
  47626. renderHeight: number;
  47627. /**
  47628. * Texture size (Default: 512)
  47629. */
  47630. textureSize: number;
  47631. /**
  47632. * If delta time between frames should be constant
  47633. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47634. */
  47635. deterministicLockstep: boolean;
  47636. /**
  47637. * Maximum about of steps between frames (Default: 4)
  47638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47639. */
  47640. lockstepMaxSteps: number;
  47641. }
  47642. /**
  47643. * The null engine class provides support for headless version of babylon.js.
  47644. * This can be used in server side scenario or for testing purposes
  47645. */
  47646. export class NullEngine extends Engine {
  47647. private _options;
  47648. /**
  47649. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47650. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47651. * @returns true if engine is in deterministic lock step mode
  47652. */
  47653. isDeterministicLockStep(): boolean;
  47654. /**
  47655. * Gets the max steps when engine is running in deterministic lock step
  47656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47657. * @returns the max steps
  47658. */
  47659. getLockstepMaxSteps(): number;
  47660. /**
  47661. * Gets the current hardware scaling level.
  47662. * By default the hardware scaling level is computed from the window device ratio.
  47663. * 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.
  47664. * @returns a number indicating the current hardware scaling level
  47665. */
  47666. getHardwareScalingLevel(): number;
  47667. constructor(options?: NullEngineOptions);
  47668. /**
  47669. * Creates a vertex buffer
  47670. * @param vertices the data for the vertex buffer
  47671. * @returns the new WebGL static buffer
  47672. */
  47673. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47674. /**
  47675. * Creates a new index buffer
  47676. * @param indices defines the content of the index buffer
  47677. * @param updatable defines if the index buffer must be updatable
  47678. * @returns a new webGL buffer
  47679. */
  47680. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47681. /**
  47682. * Clear the current render buffer or the current render target (if any is set up)
  47683. * @param color defines the color to use
  47684. * @param backBuffer defines if the back buffer must be cleared
  47685. * @param depth defines if the depth buffer must be cleared
  47686. * @param stencil defines if the stencil buffer must be cleared
  47687. */
  47688. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47689. /**
  47690. * Gets the current render width
  47691. * @param useScreen defines if screen size must be used (or the current render target if any)
  47692. * @returns a number defining the current render width
  47693. */
  47694. getRenderWidth(useScreen?: boolean): number;
  47695. /**
  47696. * Gets the current render height
  47697. * @param useScreen defines if screen size must be used (or the current render target if any)
  47698. * @returns a number defining the current render height
  47699. */
  47700. getRenderHeight(useScreen?: boolean): number;
  47701. /**
  47702. * Set the WebGL's viewport
  47703. * @param viewport defines the viewport element to be used
  47704. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47705. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47706. */
  47707. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47708. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47709. /**
  47710. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47711. * @param pipelineContext defines the pipeline context to use
  47712. * @param uniformsNames defines the list of uniform names
  47713. * @returns an array of webGL uniform locations
  47714. */
  47715. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47716. /**
  47717. * Gets the lsit of active attributes for a given webGL program
  47718. * @param pipelineContext defines the pipeline context to use
  47719. * @param attributesNames defines the list of attribute names to get
  47720. * @returns an array of indices indicating the offset of each attribute
  47721. */
  47722. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47723. /**
  47724. * Binds an effect to the webGL context
  47725. * @param effect defines the effect to bind
  47726. */
  47727. bindSamplers(effect: Effect): void;
  47728. /**
  47729. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47730. * @param effect defines the effect to activate
  47731. */
  47732. enableEffect(effect: Effect): void;
  47733. /**
  47734. * Set various states to the webGL context
  47735. * @param culling defines backface culling state
  47736. * @param zOffset defines the value to apply to zOffset (0 by default)
  47737. * @param force defines if states must be applied even if cache is up to date
  47738. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47739. */
  47740. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47741. /**
  47742. * Set the value of an uniform to an array of int32
  47743. * @param uniform defines the webGL uniform location where to store the value
  47744. * @param array defines the array of int32 to store
  47745. */
  47746. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47747. /**
  47748. * Set the value of an uniform to an array of int32 (stored as vec2)
  47749. * @param uniform defines the webGL uniform location where to store the value
  47750. * @param array defines the array of int32 to store
  47751. */
  47752. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47753. /**
  47754. * Set the value of an uniform to an array of int32 (stored as vec3)
  47755. * @param uniform defines the webGL uniform location where to store the value
  47756. * @param array defines the array of int32 to store
  47757. */
  47758. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47759. /**
  47760. * Set the value of an uniform to an array of int32 (stored as vec4)
  47761. * @param uniform defines the webGL uniform location where to store the value
  47762. * @param array defines the array of int32 to store
  47763. */
  47764. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47765. /**
  47766. * Set the value of an uniform to an array of float32
  47767. * @param uniform defines the webGL uniform location where to store the value
  47768. * @param array defines the array of float32 to store
  47769. */
  47770. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47771. /**
  47772. * Set the value of an uniform to an array of float32 (stored as vec2)
  47773. * @param uniform defines the webGL uniform location where to store the value
  47774. * @param array defines the array of float32 to store
  47775. */
  47776. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47777. /**
  47778. * Set the value of an uniform to an array of float32 (stored as vec3)
  47779. * @param uniform defines the webGL uniform location where to store the value
  47780. * @param array defines the array of float32 to store
  47781. */
  47782. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47783. /**
  47784. * Set the value of an uniform to an array of float32 (stored as vec4)
  47785. * @param uniform defines the webGL uniform location where to store the value
  47786. * @param array defines the array of float32 to store
  47787. */
  47788. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47789. /**
  47790. * Set the value of an uniform to an array of number
  47791. * @param uniform defines the webGL uniform location where to store the value
  47792. * @param array defines the array of number to store
  47793. */
  47794. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47795. /**
  47796. * Set the value of an uniform to an array of number (stored as vec2)
  47797. * @param uniform defines the webGL uniform location where to store the value
  47798. * @param array defines the array of number to store
  47799. */
  47800. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47801. /**
  47802. * Set the value of an uniform to an array of number (stored as vec3)
  47803. * @param uniform defines the webGL uniform location where to store the value
  47804. * @param array defines the array of number to store
  47805. */
  47806. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47807. /**
  47808. * Set the value of an uniform to an array of number (stored as vec4)
  47809. * @param uniform defines the webGL uniform location where to store the value
  47810. * @param array defines the array of number to store
  47811. */
  47812. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47813. /**
  47814. * Set the value of an uniform to an array of float32 (stored as matrices)
  47815. * @param uniform defines the webGL uniform location where to store the value
  47816. * @param matrices defines the array of float32 to store
  47817. */
  47818. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47819. /**
  47820. * Set the value of an uniform to a matrix (3x3)
  47821. * @param uniform defines the webGL uniform location where to store the value
  47822. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47823. */
  47824. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47825. /**
  47826. * Set the value of an uniform to a matrix (2x2)
  47827. * @param uniform defines the webGL uniform location where to store the value
  47828. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47829. */
  47830. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47831. /**
  47832. * Set the value of an uniform to a number (float)
  47833. * @param uniform defines the webGL uniform location where to store the value
  47834. * @param value defines the float number to store
  47835. */
  47836. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47837. /**
  47838. * Set the value of an uniform to a vec2
  47839. * @param uniform defines the webGL uniform location where to store the value
  47840. * @param x defines the 1st component of the value
  47841. * @param y defines the 2nd component of the value
  47842. */
  47843. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47844. /**
  47845. * Set the value of an uniform to a vec3
  47846. * @param uniform defines the webGL uniform location where to store the value
  47847. * @param x defines the 1st component of the value
  47848. * @param y defines the 2nd component of the value
  47849. * @param z defines the 3rd component of the value
  47850. */
  47851. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47852. /**
  47853. * Set the value of an uniform to a boolean
  47854. * @param uniform defines the webGL uniform location where to store the value
  47855. * @param bool defines the boolean to store
  47856. */
  47857. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47858. /**
  47859. * Set the value of an uniform to a vec4
  47860. * @param uniform defines the webGL uniform location where to store the value
  47861. * @param x defines the 1st component of the value
  47862. * @param y defines the 2nd component of the value
  47863. * @param z defines the 3rd component of the value
  47864. * @param w defines the 4th component of the value
  47865. */
  47866. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47867. /**
  47868. * Sets the current alpha mode
  47869. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47870. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47872. */
  47873. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47874. /**
  47875. * Bind webGl buffers directly to the webGL context
  47876. * @param vertexBuffers defines the vertex buffer to bind
  47877. * @param indexBuffer defines the index buffer to bind
  47878. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47879. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47880. * @param effect defines the effect associated with the vertex buffer
  47881. */
  47882. bindBuffers(vertexBuffers: {
  47883. [key: string]: VertexBuffer;
  47884. }, indexBuffer: DataBuffer, effect: Effect): void;
  47885. /**
  47886. * Force the entire cache to be cleared
  47887. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47888. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47889. */
  47890. wipeCaches(bruteForce?: boolean): void;
  47891. /**
  47892. * Send a draw order
  47893. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47894. * @param indexStart defines the starting index
  47895. * @param indexCount defines the number of index to draw
  47896. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47897. */
  47898. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47899. /**
  47900. * Draw a list of indexed primitives
  47901. * @param fillMode defines the primitive to use
  47902. * @param indexStart defines the starting index
  47903. * @param indexCount defines the number of index to draw
  47904. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47905. */
  47906. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47907. /**
  47908. * Draw a list of unindexed primitives
  47909. * @param fillMode defines the primitive to use
  47910. * @param verticesStart defines the index of first vertex to draw
  47911. * @param verticesCount defines the count of vertices to draw
  47912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47913. */
  47914. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47915. /** @hidden */
  47916. _createTexture(): WebGLTexture;
  47917. /** @hidden */
  47918. _releaseTexture(texture: InternalTexture): void;
  47919. /**
  47920. * Usually called from Texture.ts.
  47921. * Passed information to create a WebGLTexture
  47922. * @param urlArg defines a value which contains one of the following:
  47923. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47924. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47925. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47926. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47927. * @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)
  47928. * @param scene needed for loading to the correct scene
  47929. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47930. * @param onLoad optional callback to be called upon successful completion
  47931. * @param onError optional callback to be called upon failure
  47932. * @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
  47933. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47934. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47935. * @param forcedExtension defines the extension to use to pick the right loader
  47936. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47937. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47938. */
  47939. 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;
  47940. /**
  47941. * Creates a new render target texture
  47942. * @param size defines the size of the texture
  47943. * @param options defines the options used to create the texture
  47944. * @returns a new render target texture stored in an InternalTexture
  47945. */
  47946. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47947. /**
  47948. * Update the sampling mode of a given texture
  47949. * @param samplingMode defines the required sampling mode
  47950. * @param texture defines the texture to update
  47951. */
  47952. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47953. /**
  47954. * Binds the frame buffer to the specified texture.
  47955. * @param texture The texture to render to or null for the default canvas
  47956. * @param faceIndex The face of the texture to render to in case of cube texture
  47957. * @param requiredWidth The width of the target to render to
  47958. * @param requiredHeight The height of the target to render to
  47959. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47960. * @param depthStencilTexture The depth stencil texture to use to render
  47961. * @param lodLevel defines le lod level to bind to the frame buffer
  47962. */
  47963. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47964. /**
  47965. * Unbind the current render target texture from the webGL context
  47966. * @param texture defines the render target texture to unbind
  47967. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47968. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47969. */
  47970. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47971. /**
  47972. * Creates a dynamic vertex buffer
  47973. * @param vertices the data for the dynamic vertex buffer
  47974. * @returns the new WebGL dynamic buffer
  47975. */
  47976. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47977. /**
  47978. * Update the content of a dynamic texture
  47979. * @param texture defines the texture to update
  47980. * @param canvas defines the canvas containing the source
  47981. * @param invertY defines if data must be stored with Y axis inverted
  47982. * @param premulAlpha defines if alpha is stored as premultiplied
  47983. * @param format defines the format of the data
  47984. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47985. */
  47986. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47987. /**
  47988. * Gets a boolean indicating if all created effects are ready
  47989. * @returns true if all effects are ready
  47990. */
  47991. areAllEffectsReady(): boolean;
  47992. /**
  47993. * @hidden
  47994. * Get the current error code of the webGL context
  47995. * @returns the error code
  47996. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47997. */
  47998. getError(): number;
  47999. /** @hidden */
  48000. _getUnpackAlignement(): number;
  48001. /** @hidden */
  48002. _unpackFlipY(value: boolean): void;
  48003. /**
  48004. * Update a dynamic index buffer
  48005. * @param indexBuffer defines the target index buffer
  48006. * @param indices defines the data to update
  48007. * @param offset defines the offset in the target index buffer where update should start
  48008. */
  48009. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48010. /**
  48011. * Updates a dynamic vertex buffer.
  48012. * @param vertexBuffer the vertex buffer to update
  48013. * @param vertices the data used to update the vertex buffer
  48014. * @param byteOffset the byte offset of the data (optional)
  48015. * @param byteLength the byte length of the data (optional)
  48016. */
  48017. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48018. /** @hidden */
  48019. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48020. /** @hidden */
  48021. _bindTexture(channel: number, texture: InternalTexture): void;
  48022. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48023. /**
  48024. * 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
  48025. */
  48026. releaseEffects(): void;
  48027. displayLoadingUI(): void;
  48028. hideLoadingUI(): void;
  48029. /** @hidden */
  48030. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48031. /** @hidden */
  48032. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48033. /** @hidden */
  48034. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48035. /** @hidden */
  48036. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48037. }
  48038. }
  48039. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48040. import { Nullable, int } from "babylonjs/types";
  48041. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48042. /** @hidden */
  48043. export class _OcclusionDataStorage {
  48044. /** @hidden */
  48045. occlusionInternalRetryCounter: number;
  48046. /** @hidden */
  48047. isOcclusionQueryInProgress: boolean;
  48048. /** @hidden */
  48049. isOccluded: boolean;
  48050. /** @hidden */
  48051. occlusionRetryCount: number;
  48052. /** @hidden */
  48053. occlusionType: number;
  48054. /** @hidden */
  48055. occlusionQueryAlgorithmType: number;
  48056. }
  48057. module "babylonjs/Engines/engine" {
  48058. interface Engine {
  48059. /**
  48060. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48061. * @return the new query
  48062. */
  48063. createQuery(): WebGLQuery;
  48064. /**
  48065. * Delete and release a webGL query
  48066. * @param query defines the query to delete
  48067. * @return the current engine
  48068. */
  48069. deleteQuery(query: WebGLQuery): Engine;
  48070. /**
  48071. * Check if a given query has resolved and got its value
  48072. * @param query defines the query to check
  48073. * @returns true if the query got its value
  48074. */
  48075. isQueryResultAvailable(query: WebGLQuery): boolean;
  48076. /**
  48077. * Gets the value of a given query
  48078. * @param query defines the query to check
  48079. * @returns the value of the query
  48080. */
  48081. getQueryResult(query: WebGLQuery): number;
  48082. /**
  48083. * Initiates an occlusion query
  48084. * @param algorithmType defines the algorithm to use
  48085. * @param query defines the query to use
  48086. * @returns the current engine
  48087. * @see http://doc.babylonjs.com/features/occlusionquery
  48088. */
  48089. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48090. /**
  48091. * Ends an occlusion query
  48092. * @see http://doc.babylonjs.com/features/occlusionquery
  48093. * @param algorithmType defines the algorithm to use
  48094. * @returns the current engine
  48095. */
  48096. endOcclusionQuery(algorithmType: number): Engine;
  48097. /**
  48098. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48099. * Please note that only one query can be issued at a time
  48100. * @returns a time token used to track the time span
  48101. */
  48102. startTimeQuery(): Nullable<_TimeToken>;
  48103. /**
  48104. * Ends a time query
  48105. * @param token defines the token used to measure the time span
  48106. * @returns the time spent (in ns)
  48107. */
  48108. endTimeQuery(token: _TimeToken): int;
  48109. /** @hidden */
  48110. _currentNonTimestampToken: Nullable<_TimeToken>;
  48111. /** @hidden */
  48112. _createTimeQuery(): WebGLQuery;
  48113. /** @hidden */
  48114. _deleteTimeQuery(query: WebGLQuery): void;
  48115. /** @hidden */
  48116. _getGlAlgorithmType(algorithmType: number): number;
  48117. /** @hidden */
  48118. _getTimeQueryResult(query: WebGLQuery): any;
  48119. /** @hidden */
  48120. _getTimeQueryAvailability(query: WebGLQuery): any;
  48121. }
  48122. }
  48123. module "babylonjs/Meshes/abstractMesh" {
  48124. interface AbstractMesh {
  48125. /**
  48126. * Backing filed
  48127. * @hidden
  48128. */
  48129. __occlusionDataStorage: _OcclusionDataStorage;
  48130. /**
  48131. * Access property
  48132. * @hidden
  48133. */
  48134. _occlusionDataStorage: _OcclusionDataStorage;
  48135. /**
  48136. * 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.
  48137. * The default value is -1 which means don't break the query and wait till the result
  48138. * @see http://doc.babylonjs.com/features/occlusionquery
  48139. */
  48140. occlusionRetryCount: number;
  48141. /**
  48142. * 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:
  48143. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48144. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48145. * * 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.
  48146. * @see http://doc.babylonjs.com/features/occlusionquery
  48147. */
  48148. occlusionType: number;
  48149. /**
  48150. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48151. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48152. * * 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.
  48153. * @see http://doc.babylonjs.com/features/occlusionquery
  48154. */
  48155. occlusionQueryAlgorithmType: number;
  48156. /**
  48157. * 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
  48158. * @see http://doc.babylonjs.com/features/occlusionquery
  48159. */
  48160. isOccluded: boolean;
  48161. /**
  48162. * Flag to check the progress status of the query
  48163. * @see http://doc.babylonjs.com/features/occlusionquery
  48164. */
  48165. isOcclusionQueryInProgress: boolean;
  48166. }
  48167. }
  48168. }
  48169. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48170. import { Nullable } from "babylonjs/types";
  48171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48172. /** @hidden */
  48173. export var _forceTransformFeedbackToBundle: boolean;
  48174. module "babylonjs/Engines/engine" {
  48175. interface Engine {
  48176. /**
  48177. * Creates a webGL transform feedback object
  48178. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48179. * @returns the webGL transform feedback object
  48180. */
  48181. createTransformFeedback(): WebGLTransformFeedback;
  48182. /**
  48183. * Delete a webGL transform feedback object
  48184. * @param value defines the webGL transform feedback object to delete
  48185. */
  48186. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48187. /**
  48188. * Bind a webGL transform feedback object to the webgl context
  48189. * @param value defines the webGL transform feedback object to bind
  48190. */
  48191. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48192. /**
  48193. * Begins a transform feedback operation
  48194. * @param usePoints defines if points or triangles must be used
  48195. */
  48196. beginTransformFeedback(usePoints: boolean): void;
  48197. /**
  48198. * Ends a transform feedback operation
  48199. */
  48200. endTransformFeedback(): void;
  48201. /**
  48202. * Specify the varyings to use with transform feedback
  48203. * @param program defines the associated webGL program
  48204. * @param value defines the list of strings representing the varying names
  48205. */
  48206. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48207. /**
  48208. * Bind a webGL buffer for a transform feedback operation
  48209. * @param value defines the webGL buffer to bind
  48210. */
  48211. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48212. }
  48213. }
  48214. }
  48215. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48216. import { Scene } from "babylonjs/scene";
  48217. import { Engine } from "babylonjs/Engines/engine";
  48218. import { Texture } from "babylonjs/Materials/Textures/texture";
  48219. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48220. import "babylonjs/Engines/Extensions/engine.multiRender";
  48221. /**
  48222. * Creation options of the multi render target texture.
  48223. */
  48224. export interface IMultiRenderTargetOptions {
  48225. /**
  48226. * Define if the texture needs to create mip maps after render.
  48227. */
  48228. generateMipMaps?: boolean;
  48229. /**
  48230. * Define the types of all the draw buffers we want to create
  48231. */
  48232. types?: number[];
  48233. /**
  48234. * Define the sampling modes of all the draw buffers we want to create
  48235. */
  48236. samplingModes?: number[];
  48237. /**
  48238. * Define if a depth buffer is required
  48239. */
  48240. generateDepthBuffer?: boolean;
  48241. /**
  48242. * Define if a stencil buffer is required
  48243. */
  48244. generateStencilBuffer?: boolean;
  48245. /**
  48246. * Define if a depth texture is required instead of a depth buffer
  48247. */
  48248. generateDepthTexture?: boolean;
  48249. /**
  48250. * Define the number of desired draw buffers
  48251. */
  48252. textureCount?: number;
  48253. /**
  48254. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48255. */
  48256. doNotChangeAspectRatio?: boolean;
  48257. /**
  48258. * Define the default type of the buffers we are creating
  48259. */
  48260. defaultType?: number;
  48261. }
  48262. /**
  48263. * A multi render target, like a render target provides the ability to render to a texture.
  48264. * Unlike the render target, it can render to several draw buffers in one draw.
  48265. * This is specially interesting in deferred rendering or for any effects requiring more than
  48266. * just one color from a single pass.
  48267. */
  48268. export class MultiRenderTarget extends RenderTargetTexture {
  48269. private _internalTextures;
  48270. private _textures;
  48271. private _multiRenderTargetOptions;
  48272. /**
  48273. * Get if draw buffers are currently supported by the used hardware and browser.
  48274. */
  48275. get isSupported(): boolean;
  48276. /**
  48277. * Get the list of textures generated by the multi render target.
  48278. */
  48279. get textures(): Texture[];
  48280. /**
  48281. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48282. */
  48283. get depthTexture(): Texture;
  48284. /**
  48285. * Set the wrapping mode on U 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 wrapU(wrap: number);
  48289. /**
  48290. * Set the wrapping mode on V of all the textures we are rendering to.
  48291. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48292. */
  48293. set wrapV(wrap: number);
  48294. /**
  48295. * Instantiate a new multi render target texture.
  48296. * A multi render target, like a render target provides the ability to render to a texture.
  48297. * Unlike the render target, it can render to several draw buffers in one draw.
  48298. * This is specially interesting in deferred rendering or for any effects requiring more than
  48299. * just one color from a single pass.
  48300. * @param name Define the name of the texture
  48301. * @param size Define the size of the buffers to render to
  48302. * @param count Define the number of target we are rendering into
  48303. * @param scene Define the scene the texture belongs to
  48304. * @param options Define the options used to create the multi render target
  48305. */
  48306. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48307. /** @hidden */
  48308. _rebuild(): void;
  48309. private _createInternalTextures;
  48310. private _createTextures;
  48311. /**
  48312. * Define the number of samples used if MSAA is enabled.
  48313. */
  48314. get samples(): number;
  48315. set samples(value: number);
  48316. /**
  48317. * Resize all the textures in the multi render target.
  48318. * Be carrefull as it will recreate all the data in the new texture.
  48319. * @param size Define the new size
  48320. */
  48321. resize(size: any): void;
  48322. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48323. /**
  48324. * Dispose the render targets and their associated resources
  48325. */
  48326. dispose(): void;
  48327. /**
  48328. * Release all the underlying texture used as draw buffers.
  48329. */
  48330. releaseInternalTextures(): void;
  48331. }
  48332. }
  48333. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48335. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48336. import { Nullable } from "babylonjs/types";
  48337. module "babylonjs/Engines/thinEngine" {
  48338. interface ThinEngine {
  48339. /**
  48340. * Unbind a list of render target textures from the webGL context
  48341. * This is used only when drawBuffer extension or webGL2 are active
  48342. * @param textures defines the render target textures to unbind
  48343. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48344. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48345. */
  48346. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48347. /**
  48348. * Create a multi render target texture
  48349. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48350. * @param size defines the size of the texture
  48351. * @param options defines the creation options
  48352. * @returns the cube texture as an InternalTexture
  48353. */
  48354. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48355. /**
  48356. * Update the sample count for a given multiple render target texture
  48357. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48358. * @param textures defines the textures to update
  48359. * @param samples defines the sample count to set
  48360. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48361. */
  48362. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48363. }
  48364. }
  48365. }
  48366. declare module "babylonjs/Engines/Extensions/engine.views" {
  48367. import { Camera } from "babylonjs/Cameras/camera";
  48368. import { Nullable } from "babylonjs/types";
  48369. /**
  48370. * Class used to define an additional view for the engine
  48371. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48372. */
  48373. export class EngineView {
  48374. /** Defines the canvas where to render the view */
  48375. target: HTMLCanvasElement;
  48376. /** Defines an optional camera used to render the view (will use active camera else) */
  48377. camera?: Camera;
  48378. }
  48379. module "babylonjs/Engines/engine" {
  48380. interface Engine {
  48381. /**
  48382. * Gets or sets the HTML element to use for attaching events
  48383. */
  48384. inputElement: Nullable<HTMLElement>;
  48385. /**
  48386. * Gets the current engine view
  48387. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48388. */
  48389. activeView: Nullable<EngineView>;
  48390. /** Gets or sets the list of views */
  48391. views: EngineView[];
  48392. /**
  48393. * Register a new child canvas
  48394. * @param canvas defines the canvas to register
  48395. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48396. * @returns the associated view
  48397. */
  48398. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48399. /**
  48400. * Remove a registered child canvas
  48401. * @param canvas defines the canvas to remove
  48402. * @returns the current engine
  48403. */
  48404. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48405. }
  48406. }
  48407. }
  48408. declare module "babylonjs/Engines/Extensions/index" {
  48409. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48410. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48411. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48412. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48413. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48414. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48415. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48416. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48417. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48418. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48419. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48420. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48421. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48422. export * from "babylonjs/Engines/Extensions/engine.views";
  48423. }
  48424. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48425. import { Nullable } from "babylonjs/types";
  48426. /**
  48427. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48428. */
  48429. export interface CubeMapInfo {
  48430. /**
  48431. * The pixel array for the front face.
  48432. * This is stored in format, left to right, up to down format.
  48433. */
  48434. front: Nullable<ArrayBufferView>;
  48435. /**
  48436. * The pixel array for the back face.
  48437. * This is stored in format, left to right, up to down format.
  48438. */
  48439. back: Nullable<ArrayBufferView>;
  48440. /**
  48441. * The pixel array for the left face.
  48442. * This is stored in format, left to right, up to down format.
  48443. */
  48444. left: Nullable<ArrayBufferView>;
  48445. /**
  48446. * The pixel array for the right face.
  48447. * This is stored in format, left to right, up to down format.
  48448. */
  48449. right: Nullable<ArrayBufferView>;
  48450. /**
  48451. * The pixel array for the up face.
  48452. * This is stored in format, left to right, up to down format.
  48453. */
  48454. up: Nullable<ArrayBufferView>;
  48455. /**
  48456. * The pixel array for the down face.
  48457. * This is stored in format, left to right, up to down format.
  48458. */
  48459. down: Nullable<ArrayBufferView>;
  48460. /**
  48461. * The size of the cubemap stored.
  48462. *
  48463. * Each faces will be size * size pixels.
  48464. */
  48465. size: number;
  48466. /**
  48467. * The format of the texture.
  48468. *
  48469. * RGBA, RGB.
  48470. */
  48471. format: number;
  48472. /**
  48473. * The type of the texture data.
  48474. *
  48475. * UNSIGNED_INT, FLOAT.
  48476. */
  48477. type: number;
  48478. /**
  48479. * Specifies whether the texture is in gamma space.
  48480. */
  48481. gammaSpace: boolean;
  48482. }
  48483. /**
  48484. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48485. */
  48486. export class PanoramaToCubeMapTools {
  48487. private static FACE_FRONT;
  48488. private static FACE_BACK;
  48489. private static FACE_RIGHT;
  48490. private static FACE_LEFT;
  48491. private static FACE_DOWN;
  48492. private static FACE_UP;
  48493. /**
  48494. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48495. *
  48496. * @param float32Array The source data.
  48497. * @param inputWidth The width of the input panorama.
  48498. * @param inputHeight The height of the input panorama.
  48499. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48500. * @return The cubemap data
  48501. */
  48502. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48503. private static CreateCubemapTexture;
  48504. private static CalcProjectionSpherical;
  48505. }
  48506. }
  48507. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48508. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48510. import { Nullable } from "babylonjs/types";
  48511. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48512. /**
  48513. * Helper class dealing with the extraction of spherical polynomial dataArray
  48514. * from a cube map.
  48515. */
  48516. export class CubeMapToSphericalPolynomialTools {
  48517. private static FileFaces;
  48518. /**
  48519. * Converts a texture to the according Spherical Polynomial data.
  48520. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48521. *
  48522. * @param texture The texture to extract the information from.
  48523. * @return The Spherical Polynomial data.
  48524. */
  48525. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48526. /**
  48527. * Converts a cubemap to the according Spherical Polynomial data.
  48528. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48529. *
  48530. * @param cubeInfo The Cube map to extract the information from.
  48531. * @return The Spherical Polynomial data.
  48532. */
  48533. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48534. }
  48535. }
  48536. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48537. import { Nullable } from "babylonjs/types";
  48538. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48539. module "babylonjs/Materials/Textures/baseTexture" {
  48540. interface BaseTexture {
  48541. /**
  48542. * Get the polynomial representation of the texture data.
  48543. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48544. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48545. */
  48546. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48547. }
  48548. }
  48549. }
  48550. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48552. /** @hidden */
  48553. export var rgbdEncodePixelShader: {
  48554. name: string;
  48555. shader: string;
  48556. };
  48557. }
  48558. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48560. /** @hidden */
  48561. export var rgbdDecodePixelShader: {
  48562. name: string;
  48563. shader: string;
  48564. };
  48565. }
  48566. declare module "babylonjs/Misc/environmentTextureTools" {
  48567. import { Nullable } from "babylonjs/types";
  48568. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48570. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48571. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48572. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48573. import "babylonjs/Shaders/rgbdEncode.fragment";
  48574. import "babylonjs/Shaders/rgbdDecode.fragment";
  48575. /**
  48576. * Raw texture data and descriptor sufficient for WebGL texture upload
  48577. */
  48578. export interface EnvironmentTextureInfo {
  48579. /**
  48580. * Version of the environment map
  48581. */
  48582. version: number;
  48583. /**
  48584. * Width of image
  48585. */
  48586. width: number;
  48587. /**
  48588. * Irradiance information stored in the file.
  48589. */
  48590. irradiance: any;
  48591. /**
  48592. * Specular information stored in the file.
  48593. */
  48594. specular: any;
  48595. }
  48596. /**
  48597. * Defines One Image in the file. It requires only the position in the file
  48598. * as well as the length.
  48599. */
  48600. interface BufferImageData {
  48601. /**
  48602. * Length of the image data.
  48603. */
  48604. length: number;
  48605. /**
  48606. * Position of the data from the null terminator delimiting the end of the JSON.
  48607. */
  48608. position: number;
  48609. }
  48610. /**
  48611. * Defines the specular data enclosed in the file.
  48612. * This corresponds to the version 1 of the data.
  48613. */
  48614. export interface EnvironmentTextureSpecularInfoV1 {
  48615. /**
  48616. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48617. */
  48618. specularDataPosition?: number;
  48619. /**
  48620. * This contains all the images data needed to reconstruct the cubemap.
  48621. */
  48622. mipmaps: Array<BufferImageData>;
  48623. /**
  48624. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48625. */
  48626. lodGenerationScale: number;
  48627. }
  48628. /**
  48629. * Sets of helpers addressing the serialization and deserialization of environment texture
  48630. * stored in a BabylonJS env file.
  48631. * Those files are usually stored as .env files.
  48632. */
  48633. export class EnvironmentTextureTools {
  48634. /**
  48635. * Magic number identifying the env file.
  48636. */
  48637. private static _MagicBytes;
  48638. /**
  48639. * Gets the environment info from an env file.
  48640. * @param data The array buffer containing the .env bytes.
  48641. * @returns the environment file info (the json header) if successfully parsed.
  48642. */
  48643. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48644. /**
  48645. * Creates an environment texture from a loaded cube texture.
  48646. * @param texture defines the cube texture to convert in env file
  48647. * @return a promise containing the environment data if succesfull.
  48648. */
  48649. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48650. /**
  48651. * Creates a JSON representation of the spherical data.
  48652. * @param texture defines the texture containing the polynomials
  48653. * @return the JSON representation of the spherical info
  48654. */
  48655. private static _CreateEnvTextureIrradiance;
  48656. /**
  48657. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48658. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48659. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48660. * @return the views described by info providing access to the underlying buffer
  48661. */
  48662. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48663. /**
  48664. * Uploads the texture info contained in the env file to the GPU.
  48665. * @param texture defines the internal texture to upload to
  48666. * @param arrayBuffer defines the buffer cotaining the data to load
  48667. * @param info defines the texture info retrieved through the GetEnvInfo method
  48668. * @returns a promise
  48669. */
  48670. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48671. private static _OnImageReadyAsync;
  48672. /**
  48673. * Uploads the levels of image data to the GPU.
  48674. * @param texture defines the internal texture to upload to
  48675. * @param imageData defines the array buffer views of image data [mipmap][face]
  48676. * @returns a promise
  48677. */
  48678. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48679. /**
  48680. * Uploads spherical polynomials information to the texture.
  48681. * @param texture defines the texture we are trying to upload the information to
  48682. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48683. */
  48684. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48685. /** @hidden */
  48686. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48687. }
  48688. }
  48689. declare module "babylonjs/Maths/math.vertexFormat" {
  48690. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48691. /**
  48692. * Contains position and normal vectors for a vertex
  48693. */
  48694. export class PositionNormalVertex {
  48695. /** the position of the vertex (defaut: 0,0,0) */
  48696. position: Vector3;
  48697. /** the normal of the vertex (defaut: 0,1,0) */
  48698. normal: Vector3;
  48699. /**
  48700. * Creates a PositionNormalVertex
  48701. * @param position the position of the vertex (defaut: 0,0,0)
  48702. * @param normal the normal of the vertex (defaut: 0,1,0)
  48703. */
  48704. constructor(
  48705. /** the position of the vertex (defaut: 0,0,0) */
  48706. position?: Vector3,
  48707. /** the normal of the vertex (defaut: 0,1,0) */
  48708. normal?: Vector3);
  48709. /**
  48710. * Clones the PositionNormalVertex
  48711. * @returns the cloned PositionNormalVertex
  48712. */
  48713. clone(): PositionNormalVertex;
  48714. }
  48715. /**
  48716. * Contains position, normal and uv vectors for a vertex
  48717. */
  48718. export class PositionNormalTextureVertex {
  48719. /** the position of the vertex (defaut: 0,0,0) */
  48720. position: Vector3;
  48721. /** the normal of the vertex (defaut: 0,1,0) */
  48722. normal: Vector3;
  48723. /** the uv of the vertex (default: 0,0) */
  48724. uv: Vector2;
  48725. /**
  48726. * Creates a PositionNormalTextureVertex
  48727. * @param position the position of the vertex (defaut: 0,0,0)
  48728. * @param normal the normal of the vertex (defaut: 0,1,0)
  48729. * @param uv the uv of the vertex (default: 0,0)
  48730. */
  48731. constructor(
  48732. /** the position of the vertex (defaut: 0,0,0) */
  48733. position?: Vector3,
  48734. /** the normal of the vertex (defaut: 0,1,0) */
  48735. normal?: Vector3,
  48736. /** the uv of the vertex (default: 0,0) */
  48737. uv?: Vector2);
  48738. /**
  48739. * Clones the PositionNormalTextureVertex
  48740. * @returns the cloned PositionNormalTextureVertex
  48741. */
  48742. clone(): PositionNormalTextureVertex;
  48743. }
  48744. }
  48745. declare module "babylonjs/Maths/math" {
  48746. export * from "babylonjs/Maths/math.axis";
  48747. export * from "babylonjs/Maths/math.color";
  48748. export * from "babylonjs/Maths/math.constants";
  48749. export * from "babylonjs/Maths/math.frustum";
  48750. export * from "babylonjs/Maths/math.path";
  48751. export * from "babylonjs/Maths/math.plane";
  48752. export * from "babylonjs/Maths/math.size";
  48753. export * from "babylonjs/Maths/math.vector";
  48754. export * from "babylonjs/Maths/math.vertexFormat";
  48755. export * from "babylonjs/Maths/math.viewport";
  48756. }
  48757. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48758. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48759. /** @hidden */
  48760. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48761. private _genericAttributeLocation;
  48762. private _varyingLocationCount;
  48763. private _varyingLocationMap;
  48764. private _replacements;
  48765. private _textureCount;
  48766. private _uniforms;
  48767. lineProcessor(line: string): string;
  48768. attributeProcessor(attribute: string): string;
  48769. varyingProcessor(varying: string, isFragment: boolean): string;
  48770. uniformProcessor(uniform: string): string;
  48771. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48772. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48773. }
  48774. }
  48775. declare module "babylonjs/Engines/nativeEngine" {
  48776. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48777. import { Engine } from "babylonjs/Engines/engine";
  48778. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48781. import { Effect } from "babylonjs/Materials/effect";
  48782. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48783. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48784. import { IColor4Like } from "babylonjs/Maths/math.like";
  48785. import { Scene } from "babylonjs/scene";
  48786. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48787. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48788. /**
  48789. * Container for accessors for natively-stored mesh data buffers.
  48790. */
  48791. class NativeDataBuffer extends DataBuffer {
  48792. /**
  48793. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48794. */
  48795. nativeIndexBuffer?: any;
  48796. /**
  48797. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48798. */
  48799. nativeVertexBuffer?: any;
  48800. }
  48801. /** @hidden */
  48802. class NativeTexture extends InternalTexture {
  48803. getInternalTexture(): InternalTexture;
  48804. getViewCount(): number;
  48805. }
  48806. /** @hidden */
  48807. export class NativeEngine extends Engine {
  48808. private readonly _native;
  48809. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48810. private readonly INVALID_HANDLE;
  48811. getHardwareScalingLevel(): number;
  48812. constructor();
  48813. /**
  48814. * Can be used to override the current requestAnimationFrame requester.
  48815. * @hidden
  48816. */
  48817. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48818. /**
  48819. * Override default engine behavior.
  48820. * @param color
  48821. * @param backBuffer
  48822. * @param depth
  48823. * @param stencil
  48824. */
  48825. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48826. /**
  48827. * Gets host document
  48828. * @returns the host document object
  48829. */
  48830. getHostDocument(): Nullable<Document>;
  48831. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48832. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48833. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48834. recordVertexArrayObject(vertexBuffers: {
  48835. [key: string]: VertexBuffer;
  48836. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48837. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48838. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48839. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48840. /**
  48841. * Draw a list of indexed primitives
  48842. * @param fillMode defines the primitive to use
  48843. * @param indexStart defines the starting index
  48844. * @param indexCount defines the number of index to draw
  48845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48846. */
  48847. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48848. /**
  48849. * Draw a list of unindexed primitives
  48850. * @param fillMode defines the primitive to use
  48851. * @param verticesStart defines the index of first vertex to draw
  48852. * @param verticesCount defines the count of vertices to draw
  48853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48854. */
  48855. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48856. createPipelineContext(): IPipelineContext;
  48857. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48858. /** @hidden */
  48859. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48860. /** @hidden */
  48861. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48862. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48863. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48864. protected _setProgram(program: WebGLProgram): void;
  48865. _releaseEffect(effect: Effect): void;
  48866. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48867. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48868. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48869. bindSamplers(effect: Effect): void;
  48870. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48871. getRenderWidth(useScreen?: boolean): number;
  48872. getRenderHeight(useScreen?: boolean): number;
  48873. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48874. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48875. /**
  48876. * Set the z offset to apply to current rendering
  48877. * @param value defines the offset to apply
  48878. */
  48879. setZOffset(value: number): void;
  48880. /**
  48881. * Gets the current value of the zOffset
  48882. * @returns the current zOffset state
  48883. */
  48884. getZOffset(): number;
  48885. /**
  48886. * Enable or disable depth buffering
  48887. * @param enable defines the state to set
  48888. */
  48889. setDepthBuffer(enable: boolean): void;
  48890. /**
  48891. * Gets a boolean indicating if depth writing is enabled
  48892. * @returns the current depth writing state
  48893. */
  48894. getDepthWrite(): boolean;
  48895. /**
  48896. * Enable or disable depth writing
  48897. * @param enable defines the state to set
  48898. */
  48899. setDepthWrite(enable: boolean): void;
  48900. /**
  48901. * Enable or disable color writing
  48902. * @param enable defines the state to set
  48903. */
  48904. setColorWrite(enable: boolean): void;
  48905. /**
  48906. * Gets a boolean indicating if color writing is enabled
  48907. * @returns the current color writing state
  48908. */
  48909. getColorWrite(): boolean;
  48910. /**
  48911. * Sets alpha constants used by some alpha blending modes
  48912. * @param r defines the red component
  48913. * @param g defines the green component
  48914. * @param b defines the blue component
  48915. * @param a defines the alpha component
  48916. */
  48917. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48918. /**
  48919. * Sets the current alpha mode
  48920. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48921. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48923. */
  48924. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48925. /**
  48926. * Gets the current alpha mode
  48927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48928. * @returns the current alpha mode
  48929. */
  48930. getAlphaMode(): number;
  48931. setInt(uniform: WebGLUniformLocation, int: number): void;
  48932. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48933. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48934. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48935. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48936. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48937. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48938. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48939. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48940. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48941. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48942. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48943. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48944. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48945. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48946. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48947. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48948. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48949. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48950. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48951. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48952. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48953. wipeCaches(bruteForce?: boolean): void;
  48954. _createTexture(): WebGLTexture;
  48955. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48956. /**
  48957. * Usually called from BABYLON.Texture.ts.
  48958. * Passed information to create a WebGLTexture
  48959. * @param urlArg defines a value which contains one of the following:
  48960. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48961. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48962. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48963. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48964. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48965. * @param scene needed for loading to the correct scene
  48966. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48967. * @param onLoad optional callback to be called upon successful completion
  48968. * @param onError optional callback to be called upon failure
  48969. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48970. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48971. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48972. * @param forcedExtension defines the extension to use to pick the right loader
  48973. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48974. */
  48975. 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;
  48976. /**
  48977. * Creates a cube texture
  48978. * @param rootUrl defines the url where the files to load is located
  48979. * @param scene defines the current scene
  48980. * @param files defines the list of files to load (1 per face)
  48981. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48982. * @param onLoad defines an optional callback raised when the texture is loaded
  48983. * @param onError defines an optional callback raised if there is an issue to load the texture
  48984. * @param format defines the format of the data
  48985. * @param forcedExtension defines the extension to use to pick the right loader
  48986. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48987. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48988. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48989. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48990. * @returns the cube texture as an InternalTexture
  48991. */
  48992. 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;
  48993. private _getSamplingFilter;
  48994. private static _GetNativeTextureFormat;
  48995. createRenderTargetTexture(size: number | {
  48996. width: number;
  48997. height: number;
  48998. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48999. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49000. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49001. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49002. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49003. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49004. /**
  49005. * Updates a dynamic vertex buffer.
  49006. * @param vertexBuffer the vertex buffer to update
  49007. * @param data the data used to update the vertex buffer
  49008. * @param byteOffset the byte offset of the data (optional)
  49009. * @param byteLength the byte length of the data (optional)
  49010. */
  49011. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49012. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49013. private _updateAnisotropicLevel;
  49014. private _getAddressMode;
  49015. /** @hidden */
  49016. _bindTexture(channel: number, texture: InternalTexture): void;
  49017. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49018. releaseEffects(): void;
  49019. /** @hidden */
  49020. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49021. /** @hidden */
  49022. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49023. /** @hidden */
  49024. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49025. /** @hidden */
  49026. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49027. }
  49028. }
  49029. declare module "babylonjs/Engines/index" {
  49030. export * from "babylonjs/Engines/constants";
  49031. export * from "babylonjs/Engines/engineCapabilities";
  49032. export * from "babylonjs/Engines/instancingAttributeInfo";
  49033. export * from "babylonjs/Engines/thinEngine";
  49034. export * from "babylonjs/Engines/engine";
  49035. export * from "babylonjs/Engines/engineStore";
  49036. export * from "babylonjs/Engines/nullEngine";
  49037. export * from "babylonjs/Engines/Extensions/index";
  49038. export * from "babylonjs/Engines/IPipelineContext";
  49039. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49040. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49041. export * from "babylonjs/Engines/nativeEngine";
  49042. }
  49043. declare module "babylonjs/Events/clipboardEvents" {
  49044. /**
  49045. * Gather the list of clipboard event types as constants.
  49046. */
  49047. export class ClipboardEventTypes {
  49048. /**
  49049. * The clipboard event is fired when a copy command is active (pressed).
  49050. */
  49051. static readonly COPY: number;
  49052. /**
  49053. * The clipboard event is fired when a cut command is active (pressed).
  49054. */
  49055. static readonly CUT: number;
  49056. /**
  49057. * The clipboard event is fired when a paste command is active (pressed).
  49058. */
  49059. static readonly PASTE: number;
  49060. }
  49061. /**
  49062. * This class is used to store clipboard related info for the onClipboardObservable event.
  49063. */
  49064. export class ClipboardInfo {
  49065. /**
  49066. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49067. */
  49068. type: number;
  49069. /**
  49070. * Defines the related dom event
  49071. */
  49072. event: ClipboardEvent;
  49073. /**
  49074. *Creates an instance of ClipboardInfo.
  49075. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49076. * @param event Defines the related dom event
  49077. */
  49078. constructor(
  49079. /**
  49080. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49081. */
  49082. type: number,
  49083. /**
  49084. * Defines the related dom event
  49085. */
  49086. event: ClipboardEvent);
  49087. /**
  49088. * Get the clipboard event's type from the keycode.
  49089. * @param keyCode Defines the keyCode for the current keyboard event.
  49090. * @return {number}
  49091. */
  49092. static GetTypeFromCharacter(keyCode: number): number;
  49093. }
  49094. }
  49095. declare module "babylonjs/Events/index" {
  49096. export * from "babylonjs/Events/keyboardEvents";
  49097. export * from "babylonjs/Events/pointerEvents";
  49098. export * from "babylonjs/Events/clipboardEvents";
  49099. }
  49100. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49101. import { Scene } from "babylonjs/scene";
  49102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49103. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49104. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49105. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49106. /**
  49107. * Google Daydream controller
  49108. */
  49109. export class DaydreamController extends WebVRController {
  49110. /**
  49111. * Base Url for the controller model.
  49112. */
  49113. static MODEL_BASE_URL: string;
  49114. /**
  49115. * File name for the controller model.
  49116. */
  49117. static MODEL_FILENAME: string;
  49118. /**
  49119. * Gamepad Id prefix used to identify Daydream Controller.
  49120. */
  49121. static readonly GAMEPAD_ID_PREFIX: string;
  49122. /**
  49123. * Creates a new DaydreamController from a gamepad
  49124. * @param vrGamepad the gamepad that the controller should be created from
  49125. */
  49126. constructor(vrGamepad: any);
  49127. /**
  49128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49129. * @param scene scene in which to add meshes
  49130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49131. */
  49132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49133. /**
  49134. * Called once for each button that changed state since the last frame
  49135. * @param buttonIdx Which button index changed
  49136. * @param state New state of the button
  49137. * @param changes Which properties on the state changed since last frame
  49138. */
  49139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49140. }
  49141. }
  49142. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49143. import { Scene } from "babylonjs/scene";
  49144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49145. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49146. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49147. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49148. /**
  49149. * Gear VR Controller
  49150. */
  49151. export class GearVRController extends WebVRController {
  49152. /**
  49153. * Base Url for the controller model.
  49154. */
  49155. static MODEL_BASE_URL: string;
  49156. /**
  49157. * File name for the controller model.
  49158. */
  49159. static MODEL_FILENAME: string;
  49160. /**
  49161. * Gamepad Id prefix used to identify this controller.
  49162. */
  49163. static readonly GAMEPAD_ID_PREFIX: string;
  49164. private readonly _buttonIndexToObservableNameMap;
  49165. /**
  49166. * Creates a new GearVRController from a gamepad
  49167. * @param vrGamepad the gamepad that the controller should be created from
  49168. */
  49169. constructor(vrGamepad: any);
  49170. /**
  49171. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49172. * @param scene scene in which to add meshes
  49173. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49174. */
  49175. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49176. /**
  49177. * Called once for each button that changed state since the last frame
  49178. * @param buttonIdx Which button index changed
  49179. * @param state New state of the button
  49180. * @param changes Which properties on the state changed since last frame
  49181. */
  49182. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49183. }
  49184. }
  49185. declare module "babylonjs/Gamepads/Controllers/index" {
  49186. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49187. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49188. export * from "babylonjs/Gamepads/Controllers/genericController";
  49189. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49190. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49191. export * from "babylonjs/Gamepads/Controllers/viveController";
  49192. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49193. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49194. }
  49195. declare module "babylonjs/Gamepads/index" {
  49196. export * from "babylonjs/Gamepads/Controllers/index";
  49197. export * from "babylonjs/Gamepads/gamepad";
  49198. export * from "babylonjs/Gamepads/gamepadManager";
  49199. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49200. export * from "babylonjs/Gamepads/xboxGamepad";
  49201. export * from "babylonjs/Gamepads/dualShockGamepad";
  49202. }
  49203. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49204. import { Scene } from "babylonjs/scene";
  49205. import { Vector4 } from "babylonjs/Maths/math.vector";
  49206. import { Color4 } from "babylonjs/Maths/math.color";
  49207. import { Mesh } from "babylonjs/Meshes/mesh";
  49208. import { Nullable } from "babylonjs/types";
  49209. /**
  49210. * Class containing static functions to help procedurally build meshes
  49211. */
  49212. export class PolyhedronBuilder {
  49213. /**
  49214. * Creates a polyhedron mesh
  49215. * * 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
  49216. * * The parameter `size` (positive float, default 1) sets the polygon size
  49217. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49218. * * 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`
  49219. * * 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
  49220. * * 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)`)
  49221. * * 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
  49222. * * 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
  49223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49226. * @param name defines the name of the mesh
  49227. * @param options defines the options used to create the mesh
  49228. * @param scene defines the hosting scene
  49229. * @returns the polyhedron mesh
  49230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49231. */
  49232. static CreatePolyhedron(name: string, options: {
  49233. type?: number;
  49234. size?: number;
  49235. sizeX?: number;
  49236. sizeY?: number;
  49237. sizeZ?: number;
  49238. custom?: any;
  49239. faceUV?: Vector4[];
  49240. faceColors?: Color4[];
  49241. flat?: boolean;
  49242. updatable?: boolean;
  49243. sideOrientation?: number;
  49244. frontUVs?: Vector4;
  49245. backUVs?: Vector4;
  49246. }, scene?: Nullable<Scene>): Mesh;
  49247. }
  49248. }
  49249. declare module "babylonjs/Gizmos/scaleGizmo" {
  49250. import { Observable } from "babylonjs/Misc/observable";
  49251. import { Nullable } from "babylonjs/types";
  49252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49253. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49254. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49255. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49256. /**
  49257. * Gizmo that enables scaling a mesh along 3 axis
  49258. */
  49259. export class ScaleGizmo extends Gizmo {
  49260. /**
  49261. * Internal gizmo used for interactions on the x axis
  49262. */
  49263. xGizmo: AxisScaleGizmo;
  49264. /**
  49265. * Internal gizmo used for interactions on the y axis
  49266. */
  49267. yGizmo: AxisScaleGizmo;
  49268. /**
  49269. * Internal gizmo used for interactions on the z axis
  49270. */
  49271. zGizmo: AxisScaleGizmo;
  49272. /**
  49273. * Internal gizmo used to scale all axis equally
  49274. */
  49275. uniformScaleGizmo: AxisScaleGizmo;
  49276. private _meshAttached;
  49277. private _updateGizmoRotationToMatchAttachedMesh;
  49278. private _snapDistance;
  49279. private _scaleRatio;
  49280. private _uniformScalingMesh;
  49281. private _octahedron;
  49282. private _sensitivity;
  49283. /** Fires an event when any of it's sub gizmos are dragged */
  49284. onDragStartObservable: Observable<unknown>;
  49285. /** Fires an event when any of it's sub gizmos are released from dragging */
  49286. onDragEndObservable: Observable<unknown>;
  49287. get attachedMesh(): Nullable<AbstractMesh>;
  49288. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49289. /**
  49290. * Creates a ScaleGizmo
  49291. * @param gizmoLayer The utility layer the gizmo will be added to
  49292. */
  49293. constructor(gizmoLayer?: UtilityLayerRenderer);
  49294. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49295. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49296. /**
  49297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49298. */
  49299. set snapDistance(value: number);
  49300. get snapDistance(): number;
  49301. /**
  49302. * Ratio for the scale of the gizmo (Default: 1)
  49303. */
  49304. set scaleRatio(value: number);
  49305. get scaleRatio(): number;
  49306. /**
  49307. * Sensitivity factor for dragging (Default: 1)
  49308. */
  49309. set sensitivity(value: number);
  49310. get sensitivity(): number;
  49311. /**
  49312. * Disposes of the gizmo
  49313. */
  49314. dispose(): void;
  49315. }
  49316. }
  49317. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49318. import { Observable } from "babylonjs/Misc/observable";
  49319. import { Nullable } from "babylonjs/types";
  49320. import { Vector3 } from "babylonjs/Maths/math.vector";
  49321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49322. import { Mesh } from "babylonjs/Meshes/mesh";
  49323. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49324. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49325. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49326. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49327. import { Color3 } from "babylonjs/Maths/math.color";
  49328. /**
  49329. * Single axis scale gizmo
  49330. */
  49331. export class AxisScaleGizmo extends Gizmo {
  49332. /**
  49333. * Drag behavior responsible for the gizmos dragging interactions
  49334. */
  49335. dragBehavior: PointerDragBehavior;
  49336. private _pointerObserver;
  49337. /**
  49338. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49339. */
  49340. snapDistance: number;
  49341. /**
  49342. * Event that fires each time the gizmo snaps to a new location.
  49343. * * snapDistance is the the change in distance
  49344. */
  49345. onSnapObservable: Observable<{
  49346. snapDistance: number;
  49347. }>;
  49348. /**
  49349. * If the scaling operation should be done on all axis (default: false)
  49350. */
  49351. uniformScaling: boolean;
  49352. /**
  49353. * Custom sensitivity value for the drag strength
  49354. */
  49355. sensitivity: number;
  49356. private _isEnabled;
  49357. private _parent;
  49358. private _arrow;
  49359. private _coloredMaterial;
  49360. private _hoverMaterial;
  49361. /**
  49362. * Creates an AxisScaleGizmo
  49363. * @param gizmoLayer The utility layer the gizmo will be added to
  49364. * @param dragAxis The axis which the gizmo will be able to scale on
  49365. * @param color The color of the gizmo
  49366. */
  49367. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49368. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49369. /**
  49370. * If the gizmo is enabled
  49371. */
  49372. set isEnabled(value: boolean);
  49373. get isEnabled(): boolean;
  49374. /**
  49375. * Disposes of the gizmo
  49376. */
  49377. dispose(): void;
  49378. /**
  49379. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49380. * @param mesh The mesh to replace the default mesh of the gizmo
  49381. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49382. */
  49383. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49384. }
  49385. }
  49386. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49387. import { Observable } from "babylonjs/Misc/observable";
  49388. import { Nullable } from "babylonjs/types";
  49389. import { Vector3 } from "babylonjs/Maths/math.vector";
  49390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49391. import { Mesh } from "babylonjs/Meshes/mesh";
  49392. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49393. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49394. import { Color3 } from "babylonjs/Maths/math.color";
  49395. import "babylonjs/Meshes/Builders/boxBuilder";
  49396. /**
  49397. * Bounding box gizmo
  49398. */
  49399. export class BoundingBoxGizmo extends Gizmo {
  49400. private _lineBoundingBox;
  49401. private _rotateSpheresParent;
  49402. private _scaleBoxesParent;
  49403. private _boundingDimensions;
  49404. private _renderObserver;
  49405. private _pointerObserver;
  49406. private _scaleDragSpeed;
  49407. private _tmpQuaternion;
  49408. private _tmpVector;
  49409. private _tmpRotationMatrix;
  49410. /**
  49411. * 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)
  49412. */
  49413. ignoreChildren: boolean;
  49414. /**
  49415. * 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)
  49416. */
  49417. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49418. /**
  49419. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49420. */
  49421. rotationSphereSize: number;
  49422. /**
  49423. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49424. */
  49425. scaleBoxSize: number;
  49426. /**
  49427. * 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)
  49428. */
  49429. fixedDragMeshScreenSize: boolean;
  49430. /**
  49431. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49432. */
  49433. fixedDragMeshScreenSizeDistanceFactor: number;
  49434. /**
  49435. * Fired when a rotation sphere or scale box is dragged
  49436. */
  49437. onDragStartObservable: Observable<{}>;
  49438. /**
  49439. * Fired when a scale box is dragged
  49440. */
  49441. onScaleBoxDragObservable: Observable<{}>;
  49442. /**
  49443. * Fired when a scale box drag is ended
  49444. */
  49445. onScaleBoxDragEndObservable: Observable<{}>;
  49446. /**
  49447. * Fired when a rotation sphere is dragged
  49448. */
  49449. onRotationSphereDragObservable: Observable<{}>;
  49450. /**
  49451. * Fired when a rotation sphere drag is ended
  49452. */
  49453. onRotationSphereDragEndObservable: Observable<{}>;
  49454. /**
  49455. * 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)
  49456. */
  49457. scalePivot: Nullable<Vector3>;
  49458. /**
  49459. * Mesh used as a pivot to rotate the attached mesh
  49460. */
  49461. private _anchorMesh;
  49462. private _existingMeshScale;
  49463. private _dragMesh;
  49464. private pointerDragBehavior;
  49465. private coloredMaterial;
  49466. private hoverColoredMaterial;
  49467. /**
  49468. * Sets the color of the bounding box gizmo
  49469. * @param color the color to set
  49470. */
  49471. setColor(color: Color3): void;
  49472. /**
  49473. * Creates an BoundingBoxGizmo
  49474. * @param gizmoLayer The utility layer the gizmo will be added to
  49475. * @param color The color of the gizmo
  49476. */
  49477. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49478. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49479. private _selectNode;
  49480. /**
  49481. * Updates the bounding box information for the Gizmo
  49482. */
  49483. updateBoundingBox(): void;
  49484. private _updateRotationSpheres;
  49485. private _updateScaleBoxes;
  49486. /**
  49487. * Enables rotation on the specified axis and disables rotation on the others
  49488. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49489. */
  49490. setEnabledRotationAxis(axis: string): void;
  49491. /**
  49492. * Enables/disables scaling
  49493. * @param enable if scaling should be enabled
  49494. */
  49495. setEnabledScaling(enable: boolean): void;
  49496. private _updateDummy;
  49497. /**
  49498. * Enables a pointer drag behavior on the bounding box of the gizmo
  49499. */
  49500. enableDragBehavior(): void;
  49501. /**
  49502. * Disposes of the gizmo
  49503. */
  49504. dispose(): void;
  49505. /**
  49506. * 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)
  49507. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49508. * @returns the bounding box mesh with the passed in mesh as a child
  49509. */
  49510. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49511. /**
  49512. * CustomMeshes are not supported by this gizmo
  49513. * @param mesh The mesh to replace the default mesh of the gizmo
  49514. */
  49515. setCustomMesh(mesh: Mesh): void;
  49516. }
  49517. }
  49518. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49519. import { Observable } from "babylonjs/Misc/observable";
  49520. import { Nullable } from "babylonjs/types";
  49521. import { Vector3 } from "babylonjs/Maths/math.vector";
  49522. import { Color3 } from "babylonjs/Maths/math.color";
  49523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49524. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49525. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49526. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49527. import "babylonjs/Meshes/Builders/linesBuilder";
  49528. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49529. /**
  49530. * Single plane rotation gizmo
  49531. */
  49532. export class PlaneRotationGizmo extends Gizmo {
  49533. /**
  49534. * Drag behavior responsible for the gizmos dragging interactions
  49535. */
  49536. dragBehavior: PointerDragBehavior;
  49537. private _pointerObserver;
  49538. /**
  49539. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49540. */
  49541. snapDistance: number;
  49542. /**
  49543. * Event that fires each time the gizmo snaps to a new location.
  49544. * * snapDistance is the the change in distance
  49545. */
  49546. onSnapObservable: Observable<{
  49547. snapDistance: number;
  49548. }>;
  49549. private _isEnabled;
  49550. private _parent;
  49551. /**
  49552. * Creates a PlaneRotationGizmo
  49553. * @param gizmoLayer The utility layer the gizmo will be added to
  49554. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49555. * @param color The color of the gizmo
  49556. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49557. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49558. */
  49559. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49560. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49561. /**
  49562. * If the gizmo is enabled
  49563. */
  49564. set isEnabled(value: boolean);
  49565. get isEnabled(): boolean;
  49566. /**
  49567. * Disposes of the gizmo
  49568. */
  49569. dispose(): void;
  49570. }
  49571. }
  49572. declare module "babylonjs/Gizmos/rotationGizmo" {
  49573. import { Observable } from "babylonjs/Misc/observable";
  49574. import { Nullable } from "babylonjs/types";
  49575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49576. import { Mesh } from "babylonjs/Meshes/mesh";
  49577. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49578. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49579. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49580. /**
  49581. * Gizmo that enables rotating a mesh along 3 axis
  49582. */
  49583. export class RotationGizmo extends Gizmo {
  49584. /**
  49585. * Internal gizmo used for interactions on the x axis
  49586. */
  49587. xGizmo: PlaneRotationGizmo;
  49588. /**
  49589. * Internal gizmo used for interactions on the y axis
  49590. */
  49591. yGizmo: PlaneRotationGizmo;
  49592. /**
  49593. * Internal gizmo used for interactions on the z axis
  49594. */
  49595. zGizmo: PlaneRotationGizmo;
  49596. /** Fires an event when any of it's sub gizmos are dragged */
  49597. onDragStartObservable: Observable<unknown>;
  49598. /** Fires an event when any of it's sub gizmos are released from dragging */
  49599. onDragEndObservable: Observable<unknown>;
  49600. private _meshAttached;
  49601. get attachedMesh(): Nullable<AbstractMesh>;
  49602. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49603. /**
  49604. * Creates a RotationGizmo
  49605. * @param gizmoLayer The utility layer the gizmo will be added to
  49606. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49607. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49608. */
  49609. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49610. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49611. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49612. /**
  49613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49614. */
  49615. set snapDistance(value: number);
  49616. get snapDistance(): number;
  49617. /**
  49618. * Ratio for the scale of the gizmo (Default: 1)
  49619. */
  49620. set scaleRatio(value: number);
  49621. get scaleRatio(): number;
  49622. /**
  49623. * Disposes of the gizmo
  49624. */
  49625. dispose(): void;
  49626. /**
  49627. * CustomMeshes are not supported by this gizmo
  49628. * @param mesh The mesh to replace the default mesh of the gizmo
  49629. */
  49630. setCustomMesh(mesh: Mesh): void;
  49631. }
  49632. }
  49633. declare module "babylonjs/Gizmos/gizmoManager" {
  49634. import { Observable } from "babylonjs/Misc/observable";
  49635. import { Nullable } from "babylonjs/types";
  49636. import { Scene, IDisposable } from "babylonjs/scene";
  49637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49638. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49639. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49640. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49641. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49642. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49643. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49644. /**
  49645. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49646. */
  49647. export class GizmoManager implements IDisposable {
  49648. private scene;
  49649. /**
  49650. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49651. */
  49652. gizmos: {
  49653. positionGizmo: Nullable<PositionGizmo>;
  49654. rotationGizmo: Nullable<RotationGizmo>;
  49655. scaleGizmo: Nullable<ScaleGizmo>;
  49656. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49657. };
  49658. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49659. clearGizmoOnEmptyPointerEvent: boolean;
  49660. /** Fires an event when the manager is attached to a mesh */
  49661. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49662. private _gizmosEnabled;
  49663. private _pointerObserver;
  49664. private _attachedMesh;
  49665. private _boundingBoxColor;
  49666. private _defaultUtilityLayer;
  49667. private _defaultKeepDepthUtilityLayer;
  49668. /**
  49669. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49670. */
  49671. boundingBoxDragBehavior: SixDofDragBehavior;
  49672. /**
  49673. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49674. */
  49675. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49676. /**
  49677. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49678. */
  49679. usePointerToAttachGizmos: boolean;
  49680. /**
  49681. * Utility layer that the bounding box gizmo belongs to
  49682. */
  49683. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49684. /**
  49685. * Utility layer that all gizmos besides bounding box belong to
  49686. */
  49687. get utilityLayer(): UtilityLayerRenderer;
  49688. /**
  49689. * Instatiates a gizmo manager
  49690. * @param scene the scene to overlay the gizmos on top of
  49691. */
  49692. constructor(scene: Scene);
  49693. /**
  49694. * Attaches a set of gizmos to the specified mesh
  49695. * @param mesh The mesh the gizmo's should be attached to
  49696. */
  49697. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49698. /**
  49699. * If the position gizmo is enabled
  49700. */
  49701. set positionGizmoEnabled(value: boolean);
  49702. get positionGizmoEnabled(): boolean;
  49703. /**
  49704. * If the rotation gizmo is enabled
  49705. */
  49706. set rotationGizmoEnabled(value: boolean);
  49707. get rotationGizmoEnabled(): boolean;
  49708. /**
  49709. * If the scale gizmo is enabled
  49710. */
  49711. set scaleGizmoEnabled(value: boolean);
  49712. get scaleGizmoEnabled(): boolean;
  49713. /**
  49714. * If the boundingBox gizmo is enabled
  49715. */
  49716. set boundingBoxGizmoEnabled(value: boolean);
  49717. get boundingBoxGizmoEnabled(): boolean;
  49718. /**
  49719. * Disposes of the gizmo manager
  49720. */
  49721. dispose(): void;
  49722. }
  49723. }
  49724. declare module "babylonjs/Lights/directionalLight" {
  49725. import { Camera } from "babylonjs/Cameras/camera";
  49726. import { Scene } from "babylonjs/scene";
  49727. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49729. import { Light } from "babylonjs/Lights/light";
  49730. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49731. import { Effect } from "babylonjs/Materials/effect";
  49732. /**
  49733. * A directional light is defined by a direction (what a surprise!).
  49734. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49735. * 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.
  49736. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49737. */
  49738. export class DirectionalLight extends ShadowLight {
  49739. private _shadowFrustumSize;
  49740. /**
  49741. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49742. */
  49743. get shadowFrustumSize(): number;
  49744. /**
  49745. * Specifies a fix frustum size for the shadow generation.
  49746. */
  49747. set shadowFrustumSize(value: number);
  49748. private _shadowOrthoScale;
  49749. /**
  49750. * Gets the shadow projection scale against the optimal computed one.
  49751. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49752. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49753. */
  49754. get shadowOrthoScale(): number;
  49755. /**
  49756. * Sets the shadow projection scale against the optimal computed one.
  49757. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49758. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49759. */
  49760. set shadowOrthoScale(value: number);
  49761. /**
  49762. * Automatically compute the projection matrix to best fit (including all the casters)
  49763. * on each frame.
  49764. */
  49765. autoUpdateExtends: boolean;
  49766. /**
  49767. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49768. * on each frame. autoUpdateExtends must be set to true for this to work
  49769. */
  49770. autoCalcShadowZBounds: boolean;
  49771. private _orthoLeft;
  49772. private _orthoRight;
  49773. private _orthoTop;
  49774. private _orthoBottom;
  49775. /**
  49776. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49777. * The directional light is emitted from everywhere in the given direction.
  49778. * It can cast shadows.
  49779. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49780. * @param name The friendly name of the light
  49781. * @param direction The direction of the light
  49782. * @param scene The scene the light belongs to
  49783. */
  49784. constructor(name: string, direction: Vector3, scene: Scene);
  49785. /**
  49786. * Returns the string "DirectionalLight".
  49787. * @return The class name
  49788. */
  49789. getClassName(): string;
  49790. /**
  49791. * Returns the integer 1.
  49792. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49793. */
  49794. getTypeID(): number;
  49795. /**
  49796. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49800. /**
  49801. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49805. /**
  49806. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49807. * Returns the DirectionalLight Shadow projection matrix.
  49808. */
  49809. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49810. protected _buildUniformLayout(): void;
  49811. /**
  49812. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49813. * @param effect The effect to update
  49814. * @param lightIndex The index of the light in the effect to update
  49815. * @returns The directional light
  49816. */
  49817. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49818. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49819. /**
  49820. * Gets the minZ used for shadow according to both the scene and the light.
  49821. *
  49822. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49823. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49824. * @param activeCamera The camera we are returning the min for
  49825. * @returns the depth min z
  49826. */
  49827. getDepthMinZ(activeCamera: Camera): number;
  49828. /**
  49829. * Gets the maxZ used for shadow according to both the scene and the light.
  49830. *
  49831. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49832. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49833. * @param activeCamera The camera we are returning the max for
  49834. * @returns the depth max z
  49835. */
  49836. getDepthMaxZ(activeCamera: Camera): number;
  49837. /**
  49838. * Prepares the list of defines specific to the light type.
  49839. * @param defines the list of defines
  49840. * @param lightIndex defines the index of the light for the effect
  49841. */
  49842. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49843. }
  49844. }
  49845. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49846. import { Mesh } from "babylonjs/Meshes/mesh";
  49847. /**
  49848. * Class containing static functions to help procedurally build meshes
  49849. */
  49850. export class HemisphereBuilder {
  49851. /**
  49852. * Creates a hemisphere mesh
  49853. * @param name defines the name of the mesh
  49854. * @param options defines the options used to create the mesh
  49855. * @param scene defines the hosting scene
  49856. * @returns the hemisphere mesh
  49857. */
  49858. static CreateHemisphere(name: string, options: {
  49859. segments?: number;
  49860. diameter?: number;
  49861. sideOrientation?: number;
  49862. }, scene: any): Mesh;
  49863. }
  49864. }
  49865. declare module "babylonjs/Lights/spotLight" {
  49866. import { Nullable } from "babylonjs/types";
  49867. import { Scene } from "babylonjs/scene";
  49868. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49870. import { Effect } from "babylonjs/Materials/effect";
  49871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49872. import { Light } from "babylonjs/Lights/light";
  49873. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49874. /**
  49875. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49876. * These values define a cone of light starting from the position, emitting toward the direction.
  49877. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49878. * and the exponent defines the speed of the decay of the light with distance (reach).
  49879. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49880. */
  49881. export class SpotLight extends ShadowLight {
  49882. private _angle;
  49883. private _innerAngle;
  49884. private _cosHalfAngle;
  49885. private _lightAngleScale;
  49886. private _lightAngleOffset;
  49887. /**
  49888. * Gets the cone angle of the spot light in Radians.
  49889. */
  49890. get angle(): number;
  49891. /**
  49892. * Sets the cone angle of the spot light in Radians.
  49893. */
  49894. set angle(value: number);
  49895. /**
  49896. * Only used in gltf falloff mode, this defines the angle where
  49897. * the directional falloff will start before cutting at angle which could be seen
  49898. * as outer angle.
  49899. */
  49900. get innerAngle(): number;
  49901. /**
  49902. * Only used in gltf falloff mode, this defines the angle where
  49903. * the directional falloff will start before cutting at angle which could be seen
  49904. * as outer angle.
  49905. */
  49906. set innerAngle(value: number);
  49907. private _shadowAngleScale;
  49908. /**
  49909. * Allows scaling the angle of the light for shadow generation only.
  49910. */
  49911. get shadowAngleScale(): number;
  49912. /**
  49913. * Allows scaling the angle of the light for shadow generation only.
  49914. */
  49915. set shadowAngleScale(value: number);
  49916. /**
  49917. * The light decay speed with the distance from the emission spot.
  49918. */
  49919. exponent: number;
  49920. private _projectionTextureMatrix;
  49921. /**
  49922. * Allows reading the projecton texture
  49923. */
  49924. get projectionTextureMatrix(): Matrix;
  49925. protected _projectionTextureLightNear: number;
  49926. /**
  49927. * Gets the near clip of the Spotlight for texture projection.
  49928. */
  49929. get projectionTextureLightNear(): number;
  49930. /**
  49931. * Sets the near clip of the Spotlight for texture projection.
  49932. */
  49933. set projectionTextureLightNear(value: number);
  49934. protected _projectionTextureLightFar: number;
  49935. /**
  49936. * Gets the far clip of the Spotlight for texture projection.
  49937. */
  49938. get projectionTextureLightFar(): number;
  49939. /**
  49940. * Sets the far clip of the Spotlight for texture projection.
  49941. */
  49942. set projectionTextureLightFar(value: number);
  49943. protected _projectionTextureUpDirection: Vector3;
  49944. /**
  49945. * Gets the Up vector of the Spotlight for texture projection.
  49946. */
  49947. get projectionTextureUpDirection(): Vector3;
  49948. /**
  49949. * Sets the Up vector of the Spotlight for texture projection.
  49950. */
  49951. set projectionTextureUpDirection(value: Vector3);
  49952. private _projectionTexture;
  49953. /**
  49954. * Gets the projection texture of the light.
  49955. */
  49956. get projectionTexture(): Nullable<BaseTexture>;
  49957. /**
  49958. * Sets the projection texture of the light.
  49959. */
  49960. set projectionTexture(value: Nullable<BaseTexture>);
  49961. private _projectionTextureViewLightDirty;
  49962. private _projectionTextureProjectionLightDirty;
  49963. private _projectionTextureDirty;
  49964. private _projectionTextureViewTargetVector;
  49965. private _projectionTextureViewLightMatrix;
  49966. private _projectionTextureProjectionLightMatrix;
  49967. private _projectionTextureScalingMatrix;
  49968. /**
  49969. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49970. * It can cast shadows.
  49971. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49972. * @param name The light friendly name
  49973. * @param position The position of the spot light in the scene
  49974. * @param direction The direction of the light in the scene
  49975. * @param angle The cone angle of the light in Radians
  49976. * @param exponent The light decay speed with the distance from the emission spot
  49977. * @param scene The scene the lights belongs to
  49978. */
  49979. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49980. /**
  49981. * Returns the string "SpotLight".
  49982. * @returns the class name
  49983. */
  49984. getClassName(): string;
  49985. /**
  49986. * Returns the integer 2.
  49987. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49988. */
  49989. getTypeID(): number;
  49990. /**
  49991. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49992. */
  49993. protected _setDirection(value: Vector3): void;
  49994. /**
  49995. * Overrides the position setter to recompute the projection texture view light Matrix.
  49996. */
  49997. protected _setPosition(value: Vector3): void;
  49998. /**
  49999. * 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.
  50000. * Returns the SpotLight.
  50001. */
  50002. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50003. protected _computeProjectionTextureViewLightMatrix(): void;
  50004. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50005. /**
  50006. * Main function for light texture projection matrix computing.
  50007. */
  50008. protected _computeProjectionTextureMatrix(): void;
  50009. protected _buildUniformLayout(): void;
  50010. private _computeAngleValues;
  50011. /**
  50012. * Sets the passed Effect "effect" with the Light textures.
  50013. * @param effect The effect to update
  50014. * @param lightIndex The index of the light in the effect to update
  50015. * @returns The light
  50016. */
  50017. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50018. /**
  50019. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50020. * @param effect The effect to update
  50021. * @param lightIndex The index of the light in the effect to update
  50022. * @returns The spot light
  50023. */
  50024. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50025. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50026. /**
  50027. * Disposes the light and the associated resources.
  50028. */
  50029. dispose(): void;
  50030. /**
  50031. * Prepares the list of defines specific to the light type.
  50032. * @param defines the list of defines
  50033. * @param lightIndex defines the index of the light for the effect
  50034. */
  50035. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50036. }
  50037. }
  50038. declare module "babylonjs/Gizmos/lightGizmo" {
  50039. import { Nullable } from "babylonjs/types";
  50040. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50041. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50042. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50043. import { Light } from "babylonjs/Lights/light";
  50044. /**
  50045. * Gizmo that enables viewing a light
  50046. */
  50047. export class LightGizmo extends Gizmo {
  50048. private _lightMesh;
  50049. private _material;
  50050. private _cachedPosition;
  50051. private _cachedForward;
  50052. private _attachedMeshParent;
  50053. /**
  50054. * Creates a LightGizmo
  50055. * @param gizmoLayer The utility layer the gizmo will be added to
  50056. */
  50057. constructor(gizmoLayer?: UtilityLayerRenderer);
  50058. private _light;
  50059. /**
  50060. * The light that the gizmo is attached to
  50061. */
  50062. set light(light: Nullable<Light>);
  50063. get light(): Nullable<Light>;
  50064. /**
  50065. * Gets the material used to render the light gizmo
  50066. */
  50067. get material(): StandardMaterial;
  50068. /**
  50069. * @hidden
  50070. * Updates the gizmo to match the attached mesh's position/rotation
  50071. */
  50072. protected _update(): void;
  50073. private static _Scale;
  50074. /**
  50075. * Creates the lines for a light mesh
  50076. */
  50077. private static _CreateLightLines;
  50078. /**
  50079. * Disposes of the light gizmo
  50080. */
  50081. dispose(): void;
  50082. private static _CreateHemisphericLightMesh;
  50083. private static _CreatePointLightMesh;
  50084. private static _CreateSpotLightMesh;
  50085. private static _CreateDirectionalLightMesh;
  50086. }
  50087. }
  50088. declare module "babylonjs/Gizmos/index" {
  50089. export * from "babylonjs/Gizmos/axisDragGizmo";
  50090. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50091. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50092. export * from "babylonjs/Gizmos/gizmo";
  50093. export * from "babylonjs/Gizmos/gizmoManager";
  50094. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50095. export * from "babylonjs/Gizmos/positionGizmo";
  50096. export * from "babylonjs/Gizmos/rotationGizmo";
  50097. export * from "babylonjs/Gizmos/scaleGizmo";
  50098. export * from "babylonjs/Gizmos/lightGizmo";
  50099. export * from "babylonjs/Gizmos/planeDragGizmo";
  50100. }
  50101. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50102. /** @hidden */
  50103. export var backgroundFragmentDeclaration: {
  50104. name: string;
  50105. shader: string;
  50106. };
  50107. }
  50108. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50109. /** @hidden */
  50110. export var backgroundUboDeclaration: {
  50111. name: string;
  50112. shader: string;
  50113. };
  50114. }
  50115. declare module "babylonjs/Shaders/background.fragment" {
  50116. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50117. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50118. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50119. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50120. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50121. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50123. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50124. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50125. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50126. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50128. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50129. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50130. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50131. /** @hidden */
  50132. export var backgroundPixelShader: {
  50133. name: string;
  50134. shader: string;
  50135. };
  50136. }
  50137. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50138. /** @hidden */
  50139. export var backgroundVertexDeclaration: {
  50140. name: string;
  50141. shader: string;
  50142. };
  50143. }
  50144. declare module "babylonjs/Shaders/background.vertex" {
  50145. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50146. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50147. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50148. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50149. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50150. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50151. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50152. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50153. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50154. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50155. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50156. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50157. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50158. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50159. /** @hidden */
  50160. export var backgroundVertexShader: {
  50161. name: string;
  50162. shader: string;
  50163. };
  50164. }
  50165. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50166. import { Nullable, int, float } from "babylonjs/types";
  50167. import { Scene } from "babylonjs/scene";
  50168. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50169. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50171. import { Mesh } from "babylonjs/Meshes/mesh";
  50172. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50173. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50174. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50176. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50177. import { Color3 } from "babylonjs/Maths/math.color";
  50178. import "babylonjs/Shaders/background.fragment";
  50179. import "babylonjs/Shaders/background.vertex";
  50180. /**
  50181. * Background material used to create an efficient environement around your scene.
  50182. */
  50183. export class BackgroundMaterial extends PushMaterial {
  50184. /**
  50185. * Standard reflectance value at parallel view angle.
  50186. */
  50187. static StandardReflectance0: number;
  50188. /**
  50189. * Standard reflectance value at grazing angle.
  50190. */
  50191. static StandardReflectance90: number;
  50192. protected _primaryColor: Color3;
  50193. /**
  50194. * Key light Color (multiply against the environement texture)
  50195. */
  50196. primaryColor: Color3;
  50197. protected __perceptualColor: Nullable<Color3>;
  50198. /**
  50199. * Experimental Internal Use Only.
  50200. *
  50201. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50202. * This acts as a helper to set the primary color to a more "human friendly" value.
  50203. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50204. * output color as close as possible from the chosen value.
  50205. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50206. * part of lighting setup.)
  50207. */
  50208. get _perceptualColor(): Nullable<Color3>;
  50209. set _perceptualColor(value: Nullable<Color3>);
  50210. protected _primaryColorShadowLevel: float;
  50211. /**
  50212. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50213. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50214. */
  50215. get primaryColorShadowLevel(): float;
  50216. set primaryColorShadowLevel(value: float);
  50217. protected _primaryColorHighlightLevel: float;
  50218. /**
  50219. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50220. * The primary color is used at the level chosen to define what the white area would look.
  50221. */
  50222. get primaryColorHighlightLevel(): float;
  50223. set primaryColorHighlightLevel(value: float);
  50224. protected _reflectionTexture: Nullable<BaseTexture>;
  50225. /**
  50226. * Reflection Texture used in the material.
  50227. * Should be author in a specific way for the best result (refer to the documentation).
  50228. */
  50229. reflectionTexture: Nullable<BaseTexture>;
  50230. protected _reflectionBlur: float;
  50231. /**
  50232. * Reflection Texture level of blur.
  50233. *
  50234. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50235. * texture twice.
  50236. */
  50237. reflectionBlur: float;
  50238. protected _diffuseTexture: Nullable<BaseTexture>;
  50239. /**
  50240. * Diffuse Texture used in the material.
  50241. * Should be author in a specific way for the best result (refer to the documentation).
  50242. */
  50243. diffuseTexture: Nullable<BaseTexture>;
  50244. protected _shadowLights: Nullable<IShadowLight[]>;
  50245. /**
  50246. * Specify the list of lights casting shadow on the material.
  50247. * All scene shadow lights will be included if null.
  50248. */
  50249. shadowLights: Nullable<IShadowLight[]>;
  50250. protected _shadowLevel: float;
  50251. /**
  50252. * Helps adjusting the shadow to a softer level if required.
  50253. * 0 means black shadows and 1 means no shadows.
  50254. */
  50255. shadowLevel: float;
  50256. protected _sceneCenter: Vector3;
  50257. /**
  50258. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50259. * It is usually zero but might be interesting to modify according to your setup.
  50260. */
  50261. sceneCenter: Vector3;
  50262. protected _opacityFresnel: boolean;
  50263. /**
  50264. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50265. * This helps ensuring a nice transition when the camera goes under the ground.
  50266. */
  50267. opacityFresnel: boolean;
  50268. protected _reflectionFresnel: boolean;
  50269. /**
  50270. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50271. * This helps adding a mirror texture on the ground.
  50272. */
  50273. reflectionFresnel: boolean;
  50274. protected _reflectionFalloffDistance: number;
  50275. /**
  50276. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50277. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50278. */
  50279. reflectionFalloffDistance: number;
  50280. protected _reflectionAmount: number;
  50281. /**
  50282. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50283. */
  50284. reflectionAmount: number;
  50285. protected _reflectionReflectance0: number;
  50286. /**
  50287. * This specifies the weight of the reflection at grazing angle.
  50288. */
  50289. reflectionReflectance0: number;
  50290. protected _reflectionReflectance90: number;
  50291. /**
  50292. * This specifies the weight of the reflection at a perpendicular point of view.
  50293. */
  50294. reflectionReflectance90: number;
  50295. /**
  50296. * Sets the reflection reflectance fresnel values according to the default standard
  50297. * empirically know to work well :-)
  50298. */
  50299. set reflectionStandardFresnelWeight(value: number);
  50300. protected _useRGBColor: boolean;
  50301. /**
  50302. * Helps to directly use the maps channels instead of their level.
  50303. */
  50304. useRGBColor: boolean;
  50305. protected _enableNoise: boolean;
  50306. /**
  50307. * This helps reducing the banding effect that could occur on the background.
  50308. */
  50309. enableNoise: boolean;
  50310. /**
  50311. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50312. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50313. * Recommended to be keep at 1.0 except for special cases.
  50314. */
  50315. get fovMultiplier(): number;
  50316. set fovMultiplier(value: number);
  50317. private _fovMultiplier;
  50318. /**
  50319. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50320. */
  50321. useEquirectangularFOV: boolean;
  50322. private _maxSimultaneousLights;
  50323. /**
  50324. * Number of Simultaneous lights allowed on the material.
  50325. */
  50326. maxSimultaneousLights: int;
  50327. /**
  50328. * Default configuration related to image processing available in the Background Material.
  50329. */
  50330. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50331. /**
  50332. * Keep track of the image processing observer to allow dispose and replace.
  50333. */
  50334. private _imageProcessingObserver;
  50335. /**
  50336. * Attaches a new image processing configuration to the PBR Material.
  50337. * @param configuration (if null the scene configuration will be use)
  50338. */
  50339. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50340. /**
  50341. * Gets the image processing configuration used either in this material.
  50342. */
  50343. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50344. /**
  50345. * Sets the Default image processing configuration used either in the this material.
  50346. *
  50347. * If sets to null, the scene one is in use.
  50348. */
  50349. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50350. /**
  50351. * Gets wether the color curves effect is enabled.
  50352. */
  50353. get cameraColorCurvesEnabled(): boolean;
  50354. /**
  50355. * Sets wether the color curves effect is enabled.
  50356. */
  50357. set cameraColorCurvesEnabled(value: boolean);
  50358. /**
  50359. * Gets wether the color grading effect is enabled.
  50360. */
  50361. get cameraColorGradingEnabled(): boolean;
  50362. /**
  50363. * Gets wether the color grading effect is enabled.
  50364. */
  50365. set cameraColorGradingEnabled(value: boolean);
  50366. /**
  50367. * Gets wether tonemapping is enabled or not.
  50368. */
  50369. get cameraToneMappingEnabled(): boolean;
  50370. /**
  50371. * Sets wether tonemapping is enabled or not
  50372. */
  50373. set cameraToneMappingEnabled(value: boolean);
  50374. /**
  50375. * The camera exposure used on this material.
  50376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50377. * This corresponds to a photographic exposure.
  50378. */
  50379. get cameraExposure(): float;
  50380. /**
  50381. * The camera exposure used on this material.
  50382. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50383. * This corresponds to a photographic exposure.
  50384. */
  50385. set cameraExposure(value: float);
  50386. /**
  50387. * Gets The camera contrast used on this material.
  50388. */
  50389. get cameraContrast(): float;
  50390. /**
  50391. * Sets The camera contrast used on this material.
  50392. */
  50393. set cameraContrast(value: float);
  50394. /**
  50395. * Gets the Color Grading 2D Lookup Texture.
  50396. */
  50397. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50398. /**
  50399. * Sets the Color Grading 2D Lookup Texture.
  50400. */
  50401. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50402. /**
  50403. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50404. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50405. * 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;
  50406. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50407. */
  50408. get cameraColorCurves(): Nullable<ColorCurves>;
  50409. /**
  50410. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50411. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50412. * 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;
  50413. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50414. */
  50415. set cameraColorCurves(value: Nullable<ColorCurves>);
  50416. /**
  50417. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50418. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50419. */
  50420. switchToBGR: boolean;
  50421. private _renderTargets;
  50422. private _reflectionControls;
  50423. private _white;
  50424. private _primaryShadowColor;
  50425. private _primaryHighlightColor;
  50426. /**
  50427. * Instantiates a Background Material in the given scene
  50428. * @param name The friendly name of the material
  50429. * @param scene The scene to add the material to
  50430. */
  50431. constructor(name: string, scene: Scene);
  50432. /**
  50433. * Gets a boolean indicating that current material needs to register RTT
  50434. */
  50435. get hasRenderTargetTextures(): boolean;
  50436. /**
  50437. * The entire material has been created in order to prevent overdraw.
  50438. * @returns false
  50439. */
  50440. needAlphaTesting(): boolean;
  50441. /**
  50442. * The entire material has been created in order to prevent overdraw.
  50443. * @returns true if blending is enable
  50444. */
  50445. needAlphaBlending(): boolean;
  50446. /**
  50447. * Checks wether the material is ready to be rendered for a given mesh.
  50448. * @param mesh The mesh to render
  50449. * @param subMesh The submesh to check against
  50450. * @param useInstances Specify wether or not the material is used with instances
  50451. * @returns true if all the dependencies are ready (Textures, Effects...)
  50452. */
  50453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50454. /**
  50455. * Compute the primary color according to the chosen perceptual color.
  50456. */
  50457. private _computePrimaryColorFromPerceptualColor;
  50458. /**
  50459. * Compute the highlights and shadow colors according to their chosen levels.
  50460. */
  50461. private _computePrimaryColors;
  50462. /**
  50463. * Build the uniform buffer used in the material.
  50464. */
  50465. buildUniformLayout(): void;
  50466. /**
  50467. * Unbind the material.
  50468. */
  50469. unbind(): void;
  50470. /**
  50471. * Bind only the world matrix to the material.
  50472. * @param world The world matrix to bind.
  50473. */
  50474. bindOnlyWorldMatrix(world: Matrix): void;
  50475. /**
  50476. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50477. * @param world The world matrix to bind.
  50478. * @param subMesh The submesh to bind for.
  50479. */
  50480. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50481. /**
  50482. * Checks to see if a texture is used in the material.
  50483. * @param texture - Base texture to use.
  50484. * @returns - Boolean specifying if a texture is used in the material.
  50485. */
  50486. hasTexture(texture: BaseTexture): boolean;
  50487. /**
  50488. * Dispose the material.
  50489. * @param forceDisposeEffect Force disposal of the associated effect.
  50490. * @param forceDisposeTextures Force disposal of the associated textures.
  50491. */
  50492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50493. /**
  50494. * Clones the material.
  50495. * @param name The cloned name.
  50496. * @returns The cloned material.
  50497. */
  50498. clone(name: string): BackgroundMaterial;
  50499. /**
  50500. * Serializes the current material to its JSON representation.
  50501. * @returns The JSON representation.
  50502. */
  50503. serialize(): any;
  50504. /**
  50505. * Gets the class name of the material
  50506. * @returns "BackgroundMaterial"
  50507. */
  50508. getClassName(): string;
  50509. /**
  50510. * Parse a JSON input to create back a background material.
  50511. * @param source The JSON data to parse
  50512. * @param scene The scene to create the parsed material in
  50513. * @param rootUrl The root url of the assets the material depends upon
  50514. * @returns the instantiated BackgroundMaterial.
  50515. */
  50516. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50517. }
  50518. }
  50519. declare module "babylonjs/Helpers/environmentHelper" {
  50520. import { Observable } from "babylonjs/Misc/observable";
  50521. import { Nullable } from "babylonjs/types";
  50522. import { Scene } from "babylonjs/scene";
  50523. import { Vector3 } from "babylonjs/Maths/math.vector";
  50524. import { Color3 } from "babylonjs/Maths/math.color";
  50525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50526. import { Mesh } from "babylonjs/Meshes/mesh";
  50527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50528. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50529. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50530. import "babylonjs/Meshes/Builders/planeBuilder";
  50531. import "babylonjs/Meshes/Builders/boxBuilder";
  50532. /**
  50533. * Represents the different options available during the creation of
  50534. * a Environment helper.
  50535. *
  50536. * This can control the default ground, skybox and image processing setup of your scene.
  50537. */
  50538. export interface IEnvironmentHelperOptions {
  50539. /**
  50540. * Specifies wether or not to create a ground.
  50541. * True by default.
  50542. */
  50543. createGround: boolean;
  50544. /**
  50545. * Specifies the ground size.
  50546. * 15 by default.
  50547. */
  50548. groundSize: number;
  50549. /**
  50550. * The texture used on the ground for the main color.
  50551. * Comes from the BabylonJS CDN by default.
  50552. *
  50553. * Remarks: Can be either a texture or a url.
  50554. */
  50555. groundTexture: string | BaseTexture;
  50556. /**
  50557. * The color mixed in the ground texture by default.
  50558. * BabylonJS clearColor by default.
  50559. */
  50560. groundColor: Color3;
  50561. /**
  50562. * Specifies the ground opacity.
  50563. * 1 by default.
  50564. */
  50565. groundOpacity: number;
  50566. /**
  50567. * Enables the ground to receive shadows.
  50568. * True by default.
  50569. */
  50570. enableGroundShadow: boolean;
  50571. /**
  50572. * Helps preventing the shadow to be fully black on the ground.
  50573. * 0.5 by default.
  50574. */
  50575. groundShadowLevel: number;
  50576. /**
  50577. * Creates a mirror texture attach to the ground.
  50578. * false by default.
  50579. */
  50580. enableGroundMirror: boolean;
  50581. /**
  50582. * Specifies the ground mirror size ratio.
  50583. * 0.3 by default as the default kernel is 64.
  50584. */
  50585. groundMirrorSizeRatio: number;
  50586. /**
  50587. * Specifies the ground mirror blur kernel size.
  50588. * 64 by default.
  50589. */
  50590. groundMirrorBlurKernel: number;
  50591. /**
  50592. * Specifies the ground mirror visibility amount.
  50593. * 1 by default
  50594. */
  50595. groundMirrorAmount: number;
  50596. /**
  50597. * Specifies the ground mirror reflectance weight.
  50598. * This uses the standard weight of the background material to setup the fresnel effect
  50599. * of the mirror.
  50600. * 1 by default.
  50601. */
  50602. groundMirrorFresnelWeight: number;
  50603. /**
  50604. * Specifies the ground mirror Falloff distance.
  50605. * This can helps reducing the size of the reflection.
  50606. * 0 by Default.
  50607. */
  50608. groundMirrorFallOffDistance: number;
  50609. /**
  50610. * Specifies the ground mirror texture type.
  50611. * Unsigned Int by Default.
  50612. */
  50613. groundMirrorTextureType: number;
  50614. /**
  50615. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50616. * the shown objects.
  50617. */
  50618. groundYBias: number;
  50619. /**
  50620. * Specifies wether or not to create a skybox.
  50621. * True by default.
  50622. */
  50623. createSkybox: boolean;
  50624. /**
  50625. * Specifies the skybox size.
  50626. * 20 by default.
  50627. */
  50628. skyboxSize: number;
  50629. /**
  50630. * The texture used on the skybox for the main color.
  50631. * Comes from the BabylonJS CDN by default.
  50632. *
  50633. * Remarks: Can be either a texture or a url.
  50634. */
  50635. skyboxTexture: string | BaseTexture;
  50636. /**
  50637. * The color mixed in the skybox texture by default.
  50638. * BabylonJS clearColor by default.
  50639. */
  50640. skyboxColor: Color3;
  50641. /**
  50642. * The background rotation around the Y axis of the scene.
  50643. * This helps aligning the key lights of your scene with the background.
  50644. * 0 by default.
  50645. */
  50646. backgroundYRotation: number;
  50647. /**
  50648. * Compute automatically the size of the elements to best fit with the scene.
  50649. */
  50650. sizeAuto: boolean;
  50651. /**
  50652. * Default position of the rootMesh if autoSize is not true.
  50653. */
  50654. rootPosition: Vector3;
  50655. /**
  50656. * Sets up the image processing in the scene.
  50657. * true by default.
  50658. */
  50659. setupImageProcessing: boolean;
  50660. /**
  50661. * The texture used as your environment texture in the scene.
  50662. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50663. *
  50664. * Remarks: Can be either a texture or a url.
  50665. */
  50666. environmentTexture: string | BaseTexture;
  50667. /**
  50668. * The value of the exposure to apply to the scene.
  50669. * 0.6 by default if setupImageProcessing is true.
  50670. */
  50671. cameraExposure: number;
  50672. /**
  50673. * The value of the contrast to apply to the scene.
  50674. * 1.6 by default if setupImageProcessing is true.
  50675. */
  50676. cameraContrast: number;
  50677. /**
  50678. * Specifies wether or not tonemapping should be enabled in the scene.
  50679. * true by default if setupImageProcessing is true.
  50680. */
  50681. toneMappingEnabled: boolean;
  50682. }
  50683. /**
  50684. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50685. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50686. * It also helps with the default setup of your imageProcessing configuration.
  50687. */
  50688. export class EnvironmentHelper {
  50689. /**
  50690. * Default ground texture URL.
  50691. */
  50692. private static _groundTextureCDNUrl;
  50693. /**
  50694. * Default skybox texture URL.
  50695. */
  50696. private static _skyboxTextureCDNUrl;
  50697. /**
  50698. * Default environment texture URL.
  50699. */
  50700. private static _environmentTextureCDNUrl;
  50701. /**
  50702. * Creates the default options for the helper.
  50703. */
  50704. private static _getDefaultOptions;
  50705. private _rootMesh;
  50706. /**
  50707. * Gets the root mesh created by the helper.
  50708. */
  50709. get rootMesh(): Mesh;
  50710. private _skybox;
  50711. /**
  50712. * Gets the skybox created by the helper.
  50713. */
  50714. get skybox(): Nullable<Mesh>;
  50715. private _skyboxTexture;
  50716. /**
  50717. * Gets the skybox texture created by the helper.
  50718. */
  50719. get skyboxTexture(): Nullable<BaseTexture>;
  50720. private _skyboxMaterial;
  50721. /**
  50722. * Gets the skybox material created by the helper.
  50723. */
  50724. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50725. private _ground;
  50726. /**
  50727. * Gets the ground mesh created by the helper.
  50728. */
  50729. get ground(): Nullable<Mesh>;
  50730. private _groundTexture;
  50731. /**
  50732. * Gets the ground texture created by the helper.
  50733. */
  50734. get groundTexture(): Nullable<BaseTexture>;
  50735. private _groundMirror;
  50736. /**
  50737. * Gets the ground mirror created by the helper.
  50738. */
  50739. get groundMirror(): Nullable<MirrorTexture>;
  50740. /**
  50741. * Gets the ground mirror render list to helps pushing the meshes
  50742. * you wish in the ground reflection.
  50743. */
  50744. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50745. private _groundMaterial;
  50746. /**
  50747. * Gets the ground material created by the helper.
  50748. */
  50749. get groundMaterial(): Nullable<BackgroundMaterial>;
  50750. /**
  50751. * Stores the creation options.
  50752. */
  50753. private readonly _scene;
  50754. private _options;
  50755. /**
  50756. * This observable will be notified with any error during the creation of the environment,
  50757. * mainly texture creation errors.
  50758. */
  50759. onErrorObservable: Observable<{
  50760. message?: string;
  50761. exception?: any;
  50762. }>;
  50763. /**
  50764. * constructor
  50765. * @param options Defines the options we want to customize the helper
  50766. * @param scene The scene to add the material to
  50767. */
  50768. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50769. /**
  50770. * Updates the background according to the new options
  50771. * @param options
  50772. */
  50773. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50774. /**
  50775. * Sets the primary color of all the available elements.
  50776. * @param color the main color to affect to the ground and the background
  50777. */
  50778. setMainColor(color: Color3): void;
  50779. /**
  50780. * Setup the image processing according to the specified options.
  50781. */
  50782. private _setupImageProcessing;
  50783. /**
  50784. * Setup the environment texture according to the specified options.
  50785. */
  50786. private _setupEnvironmentTexture;
  50787. /**
  50788. * Setup the background according to the specified options.
  50789. */
  50790. private _setupBackground;
  50791. /**
  50792. * Get the scene sizes according to the setup.
  50793. */
  50794. private _getSceneSize;
  50795. /**
  50796. * Setup the ground according to the specified options.
  50797. */
  50798. private _setupGround;
  50799. /**
  50800. * Setup the ground material according to the specified options.
  50801. */
  50802. private _setupGroundMaterial;
  50803. /**
  50804. * Setup the ground diffuse texture according to the specified options.
  50805. */
  50806. private _setupGroundDiffuseTexture;
  50807. /**
  50808. * Setup the ground mirror texture according to the specified options.
  50809. */
  50810. private _setupGroundMirrorTexture;
  50811. /**
  50812. * Setup the ground to receive the mirror texture.
  50813. */
  50814. private _setupMirrorInGroundMaterial;
  50815. /**
  50816. * Setup the skybox according to the specified options.
  50817. */
  50818. private _setupSkybox;
  50819. /**
  50820. * Setup the skybox material according to the specified options.
  50821. */
  50822. private _setupSkyboxMaterial;
  50823. /**
  50824. * Setup the skybox reflection texture according to the specified options.
  50825. */
  50826. private _setupSkyboxReflectionTexture;
  50827. private _errorHandler;
  50828. /**
  50829. * Dispose all the elements created by the Helper.
  50830. */
  50831. dispose(): void;
  50832. }
  50833. }
  50834. declare module "babylonjs/Helpers/photoDome" {
  50835. import { Observable } from "babylonjs/Misc/observable";
  50836. import { Nullable } from "babylonjs/types";
  50837. import { Scene } from "babylonjs/scene";
  50838. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50839. import { Mesh } from "babylonjs/Meshes/mesh";
  50840. import { Texture } from "babylonjs/Materials/Textures/texture";
  50841. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50842. import "babylonjs/Meshes/Builders/sphereBuilder";
  50843. /**
  50844. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50845. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50846. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50847. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50848. */
  50849. export class PhotoDome extends TransformNode {
  50850. /**
  50851. * Define the image as a Monoscopic panoramic 360 image.
  50852. */
  50853. static readonly MODE_MONOSCOPIC: number;
  50854. /**
  50855. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50856. */
  50857. static readonly MODE_TOPBOTTOM: number;
  50858. /**
  50859. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50860. */
  50861. static readonly MODE_SIDEBYSIDE: number;
  50862. private _useDirectMapping;
  50863. /**
  50864. * The texture being displayed on the sphere
  50865. */
  50866. protected _photoTexture: Texture;
  50867. /**
  50868. * Gets or sets the texture being displayed on the sphere
  50869. */
  50870. get photoTexture(): Texture;
  50871. set photoTexture(value: Texture);
  50872. /**
  50873. * Observable raised when an error occured while loading the 360 image
  50874. */
  50875. onLoadErrorObservable: Observable<string>;
  50876. /**
  50877. * The skybox material
  50878. */
  50879. protected _material: BackgroundMaterial;
  50880. /**
  50881. * The surface used for the skybox
  50882. */
  50883. protected _mesh: Mesh;
  50884. /**
  50885. * Gets the mesh used for the skybox.
  50886. */
  50887. get mesh(): Mesh;
  50888. /**
  50889. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50890. * Also see the options.resolution property.
  50891. */
  50892. get fovMultiplier(): number;
  50893. set fovMultiplier(value: number);
  50894. private _imageMode;
  50895. /**
  50896. * Gets or set the current video mode for the video. It can be:
  50897. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50898. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50899. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50900. */
  50901. get imageMode(): number;
  50902. set imageMode(value: number);
  50903. /**
  50904. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50905. * @param name Element's name, child elements will append suffixes for their own names.
  50906. * @param urlsOfPhoto defines the url of the photo to display
  50907. * @param options defines an object containing optional or exposed sub element properties
  50908. * @param onError defines a callback called when an error occured while loading the texture
  50909. */
  50910. constructor(name: string, urlOfPhoto: string, options: {
  50911. resolution?: number;
  50912. size?: number;
  50913. useDirectMapping?: boolean;
  50914. faceForward?: boolean;
  50915. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50916. private _onBeforeCameraRenderObserver;
  50917. private _changeImageMode;
  50918. /**
  50919. * Releases resources associated with this node.
  50920. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50921. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50922. */
  50923. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50924. }
  50925. }
  50926. declare module "babylonjs/Misc/rgbdTextureTools" {
  50927. import "babylonjs/Shaders/rgbdDecode.fragment";
  50928. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50929. import { Texture } from "babylonjs/Materials/Textures/texture";
  50930. /**
  50931. * Class used to host RGBD texture specific utilities
  50932. */
  50933. export class RGBDTextureTools {
  50934. /**
  50935. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50936. * @param texture the texture to expand.
  50937. */
  50938. static ExpandRGBDTexture(texture: Texture): void;
  50939. }
  50940. }
  50941. declare module "babylonjs/Misc/brdfTextureTools" {
  50942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50943. import { Scene } from "babylonjs/scene";
  50944. /**
  50945. * Class used to host texture specific utilities
  50946. */
  50947. export class BRDFTextureTools {
  50948. /**
  50949. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50950. * @param scene defines the hosting scene
  50951. * @returns the environment BRDF texture
  50952. */
  50953. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50954. private static _environmentBRDFBase64Texture;
  50955. }
  50956. }
  50957. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50958. import { Nullable } from "babylonjs/types";
  50959. import { Color3 } from "babylonjs/Maths/math.color";
  50960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50961. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50962. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50963. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50964. import { Engine } from "babylonjs/Engines/engine";
  50965. import { Scene } from "babylonjs/scene";
  50966. /**
  50967. * @hidden
  50968. */
  50969. export interface IMaterialClearCoatDefines {
  50970. CLEARCOAT: boolean;
  50971. CLEARCOAT_DEFAULTIOR: boolean;
  50972. CLEARCOAT_TEXTURE: boolean;
  50973. CLEARCOAT_TEXTUREDIRECTUV: number;
  50974. CLEARCOAT_BUMP: boolean;
  50975. CLEARCOAT_BUMPDIRECTUV: number;
  50976. CLEARCOAT_TINT: boolean;
  50977. CLEARCOAT_TINT_TEXTURE: boolean;
  50978. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50979. /** @hidden */
  50980. _areTexturesDirty: boolean;
  50981. }
  50982. /**
  50983. * Define the code related to the clear coat parameters of the pbr material.
  50984. */
  50985. export class PBRClearCoatConfiguration {
  50986. /**
  50987. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50988. * The default fits with a polyurethane material.
  50989. */
  50990. private static readonly _DefaultIndexOfRefraction;
  50991. private _isEnabled;
  50992. /**
  50993. * Defines if the clear coat is enabled in the material.
  50994. */
  50995. isEnabled: boolean;
  50996. /**
  50997. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50998. */
  50999. intensity: number;
  51000. /**
  51001. * Defines the clear coat layer roughness.
  51002. */
  51003. roughness: number;
  51004. private _indexOfRefraction;
  51005. /**
  51006. * Defines the index of refraction of the clear coat.
  51007. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51008. * The default fits with a polyurethane material.
  51009. * Changing the default value is more performance intensive.
  51010. */
  51011. indexOfRefraction: number;
  51012. private _texture;
  51013. /**
  51014. * Stores the clear coat values in a texture.
  51015. */
  51016. texture: Nullable<BaseTexture>;
  51017. private _bumpTexture;
  51018. /**
  51019. * Define the clear coat specific bump texture.
  51020. */
  51021. bumpTexture: Nullable<BaseTexture>;
  51022. private _isTintEnabled;
  51023. /**
  51024. * Defines if the clear coat tint is enabled in the material.
  51025. */
  51026. isTintEnabled: boolean;
  51027. /**
  51028. * Defines the clear coat tint of the material.
  51029. * This is only use if tint is enabled
  51030. */
  51031. tintColor: Color3;
  51032. /**
  51033. * Defines the distance at which the tint color should be found in the
  51034. * clear coat media.
  51035. * This is only use if tint is enabled
  51036. */
  51037. tintColorAtDistance: number;
  51038. /**
  51039. * Defines the clear coat layer thickness.
  51040. * This is only use if tint is enabled
  51041. */
  51042. tintThickness: number;
  51043. private _tintTexture;
  51044. /**
  51045. * Stores the clear tint values in a texture.
  51046. * rgb is tint
  51047. * a is a thickness factor
  51048. */
  51049. tintTexture: Nullable<BaseTexture>;
  51050. /** @hidden */
  51051. private _internalMarkAllSubMeshesAsTexturesDirty;
  51052. /** @hidden */
  51053. _markAllSubMeshesAsTexturesDirty(): void;
  51054. /**
  51055. * Instantiate a new istance of clear coat configuration.
  51056. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51057. */
  51058. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51059. /**
  51060. * Gets wehter the submesh is ready to be used or not.
  51061. * @param defines the list of "defines" to update.
  51062. * @param scene defines the scene the material belongs to.
  51063. * @param engine defines the engine the material belongs to.
  51064. * @param disableBumpMap defines wether the material disables bump or not.
  51065. * @returns - boolean indicating that the submesh is ready or not.
  51066. */
  51067. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51068. /**
  51069. * Checks to see if a texture is used in the material.
  51070. * @param defines the list of "defines" to update.
  51071. * @param scene defines the scene to the material belongs to.
  51072. */
  51073. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51074. /**
  51075. * Binds the material data.
  51076. * @param uniformBuffer defines the Uniform buffer to fill in.
  51077. * @param scene defines the scene the material belongs to.
  51078. * @param engine defines the engine the material belongs to.
  51079. * @param disableBumpMap defines wether the material disables bump or not.
  51080. * @param isFrozen defines wether the material is frozen or not.
  51081. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51082. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51083. */
  51084. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51085. /**
  51086. * Checks to see if a texture is used in the material.
  51087. * @param texture - Base texture to use.
  51088. * @returns - Boolean specifying if a texture is used in the material.
  51089. */
  51090. hasTexture(texture: BaseTexture): boolean;
  51091. /**
  51092. * Returns an array of the actively used textures.
  51093. * @param activeTextures Array of BaseTextures
  51094. */
  51095. getActiveTextures(activeTextures: BaseTexture[]): void;
  51096. /**
  51097. * Returns the animatable textures.
  51098. * @param animatables Array of animatable textures.
  51099. */
  51100. getAnimatables(animatables: IAnimatable[]): void;
  51101. /**
  51102. * Disposes the resources of the material.
  51103. * @param forceDisposeTextures - Forces the disposal of all textures.
  51104. */
  51105. dispose(forceDisposeTextures?: boolean): void;
  51106. /**
  51107. * Get the current class name of the texture useful for serialization or dynamic coding.
  51108. * @returns "PBRClearCoatConfiguration"
  51109. */
  51110. getClassName(): string;
  51111. /**
  51112. * Add fallbacks to the effect fallbacks list.
  51113. * @param defines defines the Base texture to use.
  51114. * @param fallbacks defines the current fallback list.
  51115. * @param currentRank defines the current fallback rank.
  51116. * @returns the new fallback rank.
  51117. */
  51118. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51119. /**
  51120. * Add the required uniforms to the current list.
  51121. * @param uniforms defines the current uniform list.
  51122. */
  51123. static AddUniforms(uniforms: string[]): void;
  51124. /**
  51125. * Add the required samplers to the current list.
  51126. * @param samplers defines the current sampler list.
  51127. */
  51128. static AddSamplers(samplers: string[]): void;
  51129. /**
  51130. * Add the required uniforms to the current buffer.
  51131. * @param uniformBuffer defines the current uniform buffer.
  51132. */
  51133. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51134. /**
  51135. * Makes a duplicate of the current configuration into another one.
  51136. * @param clearCoatConfiguration define the config where to copy the info
  51137. */
  51138. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51139. /**
  51140. * Serializes this clear coat configuration.
  51141. * @returns - An object with the serialized config.
  51142. */
  51143. serialize(): any;
  51144. /**
  51145. * Parses a anisotropy Configuration from a serialized object.
  51146. * @param source - Serialized object.
  51147. * @param scene Defines the scene we are parsing for
  51148. * @param rootUrl Defines the rootUrl to load from
  51149. */
  51150. parse(source: any, scene: Scene, rootUrl: string): void;
  51151. }
  51152. }
  51153. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51156. import { Vector2 } from "babylonjs/Maths/math.vector";
  51157. import { Scene } from "babylonjs/scene";
  51158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51159. import { Nullable } from "babylonjs/types";
  51160. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51161. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51162. /**
  51163. * @hidden
  51164. */
  51165. export interface IMaterialAnisotropicDefines {
  51166. ANISOTROPIC: boolean;
  51167. ANISOTROPIC_TEXTURE: boolean;
  51168. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51169. MAINUV1: boolean;
  51170. _areTexturesDirty: boolean;
  51171. _needUVs: boolean;
  51172. }
  51173. /**
  51174. * Define the code related to the anisotropic parameters of the pbr material.
  51175. */
  51176. export class PBRAnisotropicConfiguration {
  51177. private _isEnabled;
  51178. /**
  51179. * Defines if the anisotropy is enabled in the material.
  51180. */
  51181. isEnabled: boolean;
  51182. /**
  51183. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51184. */
  51185. intensity: number;
  51186. /**
  51187. * Defines if the effect is along the tangents, bitangents or in between.
  51188. * By default, the effect is "strectching" the highlights along the tangents.
  51189. */
  51190. direction: Vector2;
  51191. private _texture;
  51192. /**
  51193. * Stores the anisotropy values in a texture.
  51194. * rg is direction (like normal from -1 to 1)
  51195. * b is a intensity
  51196. */
  51197. texture: Nullable<BaseTexture>;
  51198. /** @hidden */
  51199. private _internalMarkAllSubMeshesAsTexturesDirty;
  51200. /** @hidden */
  51201. _markAllSubMeshesAsTexturesDirty(): void;
  51202. /**
  51203. * Instantiate a new istance of anisotropy configuration.
  51204. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51205. */
  51206. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51207. /**
  51208. * Specifies that the submesh is ready to be used.
  51209. * @param defines the list of "defines" to update.
  51210. * @param scene defines the scene the material belongs to.
  51211. * @returns - boolean indicating that the submesh is ready or not.
  51212. */
  51213. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51214. /**
  51215. * Checks to see if a texture is used in the material.
  51216. * @param defines the list of "defines" to update.
  51217. * @param mesh the mesh we are preparing the defines for.
  51218. * @param scene defines the scene the material belongs to.
  51219. */
  51220. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51221. /**
  51222. * Binds the material data.
  51223. * @param uniformBuffer defines the Uniform buffer to fill in.
  51224. * @param scene defines the scene the material belongs to.
  51225. * @param isFrozen defines wether the material is frozen or not.
  51226. */
  51227. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51228. /**
  51229. * Checks to see if a texture is used in the material.
  51230. * @param texture - Base texture to use.
  51231. * @returns - Boolean specifying if a texture is used in the material.
  51232. */
  51233. hasTexture(texture: BaseTexture): boolean;
  51234. /**
  51235. * Returns an array of the actively used textures.
  51236. * @param activeTextures Array of BaseTextures
  51237. */
  51238. getActiveTextures(activeTextures: BaseTexture[]): void;
  51239. /**
  51240. * Returns the animatable textures.
  51241. * @param animatables Array of animatable textures.
  51242. */
  51243. getAnimatables(animatables: IAnimatable[]): void;
  51244. /**
  51245. * Disposes the resources of the material.
  51246. * @param forceDisposeTextures - Forces the disposal of all textures.
  51247. */
  51248. dispose(forceDisposeTextures?: boolean): void;
  51249. /**
  51250. * Get the current class name of the texture useful for serialization or dynamic coding.
  51251. * @returns "PBRAnisotropicConfiguration"
  51252. */
  51253. getClassName(): string;
  51254. /**
  51255. * Add fallbacks to the effect fallbacks list.
  51256. * @param defines defines the Base texture to use.
  51257. * @param fallbacks defines the current fallback list.
  51258. * @param currentRank defines the current fallback rank.
  51259. * @returns the new fallback rank.
  51260. */
  51261. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51262. /**
  51263. * Add the required uniforms to the current list.
  51264. * @param uniforms defines the current uniform list.
  51265. */
  51266. static AddUniforms(uniforms: string[]): void;
  51267. /**
  51268. * Add the required uniforms to the current buffer.
  51269. * @param uniformBuffer defines the current uniform buffer.
  51270. */
  51271. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51272. /**
  51273. * Add the required samplers to the current list.
  51274. * @param samplers defines the current sampler list.
  51275. */
  51276. static AddSamplers(samplers: string[]): void;
  51277. /**
  51278. * Makes a duplicate of the current configuration into another one.
  51279. * @param anisotropicConfiguration define the config where to copy the info
  51280. */
  51281. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51282. /**
  51283. * Serializes this anisotropy configuration.
  51284. * @returns - An object with the serialized config.
  51285. */
  51286. serialize(): any;
  51287. /**
  51288. * Parses a anisotropy Configuration from a serialized object.
  51289. * @param source - Serialized object.
  51290. * @param scene Defines the scene we are parsing for
  51291. * @param rootUrl Defines the rootUrl to load from
  51292. */
  51293. parse(source: any, scene: Scene, rootUrl: string): void;
  51294. }
  51295. }
  51296. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51297. import { Scene } from "babylonjs/scene";
  51298. /**
  51299. * @hidden
  51300. */
  51301. export interface IMaterialBRDFDefines {
  51302. BRDF_V_HEIGHT_CORRELATED: boolean;
  51303. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51304. SPHERICAL_HARMONICS: boolean;
  51305. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51306. /** @hidden */
  51307. _areMiscDirty: boolean;
  51308. }
  51309. /**
  51310. * Define the code related to the BRDF parameters of the pbr material.
  51311. */
  51312. export class PBRBRDFConfiguration {
  51313. /**
  51314. * Default value used for the energy conservation.
  51315. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51316. */
  51317. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51318. /**
  51319. * Default value used for the Smith Visibility Height Correlated mode.
  51320. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51321. */
  51322. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51323. /**
  51324. * Default value used for the IBL diffuse part.
  51325. * This can help switching back to the polynomials mode globally which is a tiny bit
  51326. * less GPU intensive at the drawback of a lower quality.
  51327. */
  51328. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51329. /**
  51330. * Default value used for activating energy conservation for the specular workflow.
  51331. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51332. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51333. */
  51334. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51335. private _useEnergyConservation;
  51336. /**
  51337. * Defines if the material uses energy conservation.
  51338. */
  51339. useEnergyConservation: boolean;
  51340. private _useSmithVisibilityHeightCorrelated;
  51341. /**
  51342. * LEGACY Mode set to false
  51343. * Defines if the material uses height smith correlated visibility term.
  51344. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51345. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51346. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51347. * Not relying on height correlated will also disable energy conservation.
  51348. */
  51349. useSmithVisibilityHeightCorrelated: boolean;
  51350. private _useSphericalHarmonics;
  51351. /**
  51352. * LEGACY Mode set to false
  51353. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51354. * diffuse part of the IBL.
  51355. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51356. * to the ground truth.
  51357. */
  51358. useSphericalHarmonics: boolean;
  51359. private _useSpecularGlossinessInputEnergyConservation;
  51360. /**
  51361. * Defines if the material uses energy conservation, when the specular workflow is active.
  51362. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51363. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51364. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51365. */
  51366. useSpecularGlossinessInputEnergyConservation: boolean;
  51367. /** @hidden */
  51368. private _internalMarkAllSubMeshesAsMiscDirty;
  51369. /** @hidden */
  51370. _markAllSubMeshesAsMiscDirty(): void;
  51371. /**
  51372. * Instantiate a new istance of clear coat configuration.
  51373. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51374. */
  51375. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51376. /**
  51377. * Checks to see if a texture is used in the material.
  51378. * @param defines the list of "defines" to update.
  51379. */
  51380. prepareDefines(defines: IMaterialBRDFDefines): void;
  51381. /**
  51382. * Get the current class name of the texture useful for serialization or dynamic coding.
  51383. * @returns "PBRClearCoatConfiguration"
  51384. */
  51385. getClassName(): string;
  51386. /**
  51387. * Makes a duplicate of the current configuration into another one.
  51388. * @param brdfConfiguration define the config where to copy the info
  51389. */
  51390. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51391. /**
  51392. * Serializes this BRDF configuration.
  51393. * @returns - An object with the serialized config.
  51394. */
  51395. serialize(): any;
  51396. /**
  51397. * Parses a anisotropy Configuration from a serialized object.
  51398. * @param source - Serialized object.
  51399. * @param scene Defines the scene we are parsing for
  51400. * @param rootUrl Defines the rootUrl to load from
  51401. */
  51402. parse(source: any, scene: Scene, rootUrl: string): void;
  51403. }
  51404. }
  51405. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51406. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51407. import { Color3 } from "babylonjs/Maths/math.color";
  51408. import { Scene } from "babylonjs/scene";
  51409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51410. import { Nullable } from "babylonjs/types";
  51411. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51412. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51413. /**
  51414. * @hidden
  51415. */
  51416. export interface IMaterialSheenDefines {
  51417. SHEEN: boolean;
  51418. SHEEN_TEXTURE: boolean;
  51419. SHEEN_TEXTUREDIRECTUV: number;
  51420. SHEEN_LINKWITHALBEDO: boolean;
  51421. /** @hidden */
  51422. _areTexturesDirty: boolean;
  51423. }
  51424. /**
  51425. * Define the code related to the Sheen parameters of the pbr material.
  51426. */
  51427. export class PBRSheenConfiguration {
  51428. private _isEnabled;
  51429. /**
  51430. * Defines if the material uses sheen.
  51431. */
  51432. isEnabled: boolean;
  51433. private _linkSheenWithAlbedo;
  51434. /**
  51435. * Defines if the sheen is linked to the sheen color.
  51436. */
  51437. linkSheenWithAlbedo: boolean;
  51438. /**
  51439. * Defines the sheen intensity.
  51440. */
  51441. intensity: number;
  51442. /**
  51443. * Defines the sheen color.
  51444. */
  51445. color: Color3;
  51446. private _texture;
  51447. /**
  51448. * Stores the sheen tint values in a texture.
  51449. * rgb is tint
  51450. * a is a intensity
  51451. */
  51452. texture: Nullable<BaseTexture>;
  51453. /** @hidden */
  51454. private _internalMarkAllSubMeshesAsTexturesDirty;
  51455. /** @hidden */
  51456. _markAllSubMeshesAsTexturesDirty(): void;
  51457. /**
  51458. * Instantiate a new istance of clear coat configuration.
  51459. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51460. */
  51461. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51462. /**
  51463. * Specifies that the submesh is ready to be used.
  51464. * @param defines the list of "defines" to update.
  51465. * @param scene defines the scene the material belongs to.
  51466. * @returns - boolean indicating that the submesh is ready or not.
  51467. */
  51468. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51469. /**
  51470. * Checks to see if a texture is used in the material.
  51471. * @param defines the list of "defines" to update.
  51472. * @param scene defines the scene the material belongs to.
  51473. */
  51474. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51475. /**
  51476. * Binds the material data.
  51477. * @param uniformBuffer defines the Uniform buffer to fill in.
  51478. * @param scene defines the scene the material belongs to.
  51479. * @param isFrozen defines wether the material is frozen or not.
  51480. */
  51481. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51482. /**
  51483. * Checks to see if a texture is used in the material.
  51484. * @param texture - Base texture to use.
  51485. * @returns - Boolean specifying if a texture is used in the material.
  51486. */
  51487. hasTexture(texture: BaseTexture): boolean;
  51488. /**
  51489. * Returns an array of the actively used textures.
  51490. * @param activeTextures Array of BaseTextures
  51491. */
  51492. getActiveTextures(activeTextures: BaseTexture[]): void;
  51493. /**
  51494. * Returns the animatable textures.
  51495. * @param animatables Array of animatable textures.
  51496. */
  51497. getAnimatables(animatables: IAnimatable[]): void;
  51498. /**
  51499. * Disposes the resources of the material.
  51500. * @param forceDisposeTextures - Forces the disposal of all textures.
  51501. */
  51502. dispose(forceDisposeTextures?: boolean): void;
  51503. /**
  51504. * Get the current class name of the texture useful for serialization or dynamic coding.
  51505. * @returns "PBRSheenConfiguration"
  51506. */
  51507. getClassName(): string;
  51508. /**
  51509. * Add fallbacks to the effect fallbacks list.
  51510. * @param defines defines the Base texture to use.
  51511. * @param fallbacks defines the current fallback list.
  51512. * @param currentRank defines the current fallback rank.
  51513. * @returns the new fallback rank.
  51514. */
  51515. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51516. /**
  51517. * Add the required uniforms to the current list.
  51518. * @param uniforms defines the current uniform list.
  51519. */
  51520. static AddUniforms(uniforms: string[]): void;
  51521. /**
  51522. * Add the required uniforms to the current buffer.
  51523. * @param uniformBuffer defines the current uniform buffer.
  51524. */
  51525. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51526. /**
  51527. * Add the required samplers to the current list.
  51528. * @param samplers defines the current sampler list.
  51529. */
  51530. static AddSamplers(samplers: string[]): void;
  51531. /**
  51532. * Makes a duplicate of the current configuration into another one.
  51533. * @param sheenConfiguration define the config where to copy the info
  51534. */
  51535. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51536. /**
  51537. * Serializes this BRDF configuration.
  51538. * @returns - An object with the serialized config.
  51539. */
  51540. serialize(): any;
  51541. /**
  51542. * Parses a anisotropy Configuration from a serialized object.
  51543. * @param source - Serialized object.
  51544. * @param scene Defines the scene we are parsing for
  51545. * @param rootUrl Defines the rootUrl to load from
  51546. */
  51547. parse(source: any, scene: Scene, rootUrl: string): void;
  51548. }
  51549. }
  51550. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51551. import { Nullable } from "babylonjs/types";
  51552. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51553. import { Color3 } from "babylonjs/Maths/math.color";
  51554. import { SmartArray } from "babylonjs/Misc/smartArray";
  51555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51556. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51557. import { Effect } from "babylonjs/Materials/effect";
  51558. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51559. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51560. import { Engine } from "babylonjs/Engines/engine";
  51561. import { Scene } from "babylonjs/scene";
  51562. /**
  51563. * @hidden
  51564. */
  51565. export interface IMaterialSubSurfaceDefines {
  51566. SUBSURFACE: boolean;
  51567. SS_REFRACTION: boolean;
  51568. SS_TRANSLUCENCY: boolean;
  51569. SS_SCATERRING: boolean;
  51570. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51571. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51572. SS_REFRACTIONMAP_3D: boolean;
  51573. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51574. SS_LODINREFRACTIONALPHA: boolean;
  51575. SS_GAMMAREFRACTION: boolean;
  51576. SS_RGBDREFRACTION: boolean;
  51577. SS_LINEARSPECULARREFRACTION: boolean;
  51578. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51579. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51580. /** @hidden */
  51581. _areTexturesDirty: boolean;
  51582. }
  51583. /**
  51584. * Define the code related to the sub surface parameters of the pbr material.
  51585. */
  51586. export class PBRSubSurfaceConfiguration {
  51587. private _isRefractionEnabled;
  51588. /**
  51589. * Defines if the refraction is enabled in the material.
  51590. */
  51591. isRefractionEnabled: boolean;
  51592. private _isTranslucencyEnabled;
  51593. /**
  51594. * Defines if the translucency is enabled in the material.
  51595. */
  51596. isTranslucencyEnabled: boolean;
  51597. private _isScatteringEnabled;
  51598. /**
  51599. * Defines the refraction intensity of the material.
  51600. * The refraction when enabled replaces the Diffuse part of the material.
  51601. * The intensity helps transitionning between diffuse and refraction.
  51602. */
  51603. refractionIntensity: number;
  51604. /**
  51605. * Defines the translucency intensity of the material.
  51606. * When translucency has been enabled, this defines how much of the "translucency"
  51607. * is addded to the diffuse part of the material.
  51608. */
  51609. translucencyIntensity: number;
  51610. /**
  51611. * Defines the scattering intensity of the material.
  51612. * When scattering has been enabled, this defines how much of the "scattered light"
  51613. * is addded to the diffuse part of the material.
  51614. */
  51615. scatteringIntensity: number;
  51616. private _thicknessTexture;
  51617. /**
  51618. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51619. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51620. * 0 would mean minimumThickness
  51621. * 1 would mean maximumThickness
  51622. * The other channels might be use as a mask to vary the different effects intensity.
  51623. */
  51624. thicknessTexture: Nullable<BaseTexture>;
  51625. private _refractionTexture;
  51626. /**
  51627. * Defines the texture to use for refraction.
  51628. */
  51629. refractionTexture: Nullable<BaseTexture>;
  51630. private _indexOfRefraction;
  51631. /**
  51632. * Defines the index of refraction used in the material.
  51633. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51634. */
  51635. indexOfRefraction: number;
  51636. private _invertRefractionY;
  51637. /**
  51638. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51639. */
  51640. invertRefractionY: boolean;
  51641. private _linkRefractionWithTransparency;
  51642. /**
  51643. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51644. * Materials half opaque for instance using refraction could benefit from this control.
  51645. */
  51646. linkRefractionWithTransparency: boolean;
  51647. /**
  51648. * Defines the minimum thickness stored in the thickness map.
  51649. * If no thickness map is defined, this value will be used to simulate thickness.
  51650. */
  51651. minimumThickness: number;
  51652. /**
  51653. * Defines the maximum thickness stored in the thickness map.
  51654. */
  51655. maximumThickness: number;
  51656. /**
  51657. * Defines the volume tint of the material.
  51658. * This is used for both translucency and scattering.
  51659. */
  51660. tintColor: Color3;
  51661. /**
  51662. * Defines the distance at which the tint color should be found in the media.
  51663. * This is used for refraction only.
  51664. */
  51665. tintColorAtDistance: number;
  51666. /**
  51667. * Defines how far each channel transmit through the media.
  51668. * It is defined as a color to simplify it selection.
  51669. */
  51670. diffusionDistance: Color3;
  51671. private _useMaskFromThicknessTexture;
  51672. /**
  51673. * Stores the intensity of the different subsurface effects in the thickness texture.
  51674. * * the green channel is the translucency intensity.
  51675. * * the blue channel is the scattering intensity.
  51676. * * the alpha channel is the refraction intensity.
  51677. */
  51678. useMaskFromThicknessTexture: boolean;
  51679. /** @hidden */
  51680. private _internalMarkAllSubMeshesAsTexturesDirty;
  51681. /** @hidden */
  51682. _markAllSubMeshesAsTexturesDirty(): void;
  51683. /**
  51684. * Instantiate a new istance of sub surface configuration.
  51685. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51686. */
  51687. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51688. /**
  51689. * Gets wehter the submesh is ready to be used or not.
  51690. * @param defines the list of "defines" to update.
  51691. * @param scene defines the scene the material belongs to.
  51692. * @returns - boolean indicating that the submesh is ready or not.
  51693. */
  51694. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51695. /**
  51696. * Checks to see if a texture is used in the material.
  51697. * @param defines the list of "defines" to update.
  51698. * @param scene defines the scene to the material belongs to.
  51699. */
  51700. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51701. /**
  51702. * Binds the material data.
  51703. * @param uniformBuffer defines the Uniform buffer to fill in.
  51704. * @param scene defines the scene the material belongs to.
  51705. * @param engine defines the engine the material belongs to.
  51706. * @param isFrozen defines wether the material is frozen or not.
  51707. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51708. */
  51709. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51710. /**
  51711. * Unbinds the material from the mesh.
  51712. * @param activeEffect defines the effect that should be unbound from.
  51713. * @returns true if unbound, otherwise false
  51714. */
  51715. unbind(activeEffect: Effect): boolean;
  51716. /**
  51717. * Returns the texture used for refraction or null if none is used.
  51718. * @param scene defines the scene the material belongs to.
  51719. * @returns - Refraction texture if present. If no refraction texture and refraction
  51720. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51721. */
  51722. private _getRefractionTexture;
  51723. /**
  51724. * Returns true if alpha blending should be disabled.
  51725. */
  51726. get disableAlphaBlending(): boolean;
  51727. /**
  51728. * Fills the list of render target textures.
  51729. * @param renderTargets the list of render targets to update
  51730. */
  51731. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51732. /**
  51733. * Checks to see if a texture is used in the material.
  51734. * @param texture - Base texture to use.
  51735. * @returns - Boolean specifying if a texture is used in the material.
  51736. */
  51737. hasTexture(texture: BaseTexture): boolean;
  51738. /**
  51739. * Gets a boolean indicating that current material needs to register RTT
  51740. * @returns true if this uses a render target otherwise false.
  51741. */
  51742. hasRenderTargetTextures(): boolean;
  51743. /**
  51744. * Returns an array of the actively used textures.
  51745. * @param activeTextures Array of BaseTextures
  51746. */
  51747. getActiveTextures(activeTextures: BaseTexture[]): void;
  51748. /**
  51749. * Returns the animatable textures.
  51750. * @param animatables Array of animatable textures.
  51751. */
  51752. getAnimatables(animatables: IAnimatable[]): void;
  51753. /**
  51754. * Disposes the resources of the material.
  51755. * @param forceDisposeTextures - Forces the disposal of all textures.
  51756. */
  51757. dispose(forceDisposeTextures?: boolean): void;
  51758. /**
  51759. * Get the current class name of the texture useful for serialization or dynamic coding.
  51760. * @returns "PBRSubSurfaceConfiguration"
  51761. */
  51762. getClassName(): string;
  51763. /**
  51764. * Add fallbacks to the effect fallbacks list.
  51765. * @param defines defines the Base texture to use.
  51766. * @param fallbacks defines the current fallback list.
  51767. * @param currentRank defines the current fallback rank.
  51768. * @returns the new fallback rank.
  51769. */
  51770. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51771. /**
  51772. * Add the required uniforms to the current list.
  51773. * @param uniforms defines the current uniform list.
  51774. */
  51775. static AddUniforms(uniforms: string[]): void;
  51776. /**
  51777. * Add the required samplers to the current list.
  51778. * @param samplers defines the current sampler list.
  51779. */
  51780. static AddSamplers(samplers: string[]): void;
  51781. /**
  51782. * Add the required uniforms to the current buffer.
  51783. * @param uniformBuffer defines the current uniform buffer.
  51784. */
  51785. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51786. /**
  51787. * Makes a duplicate of the current configuration into another one.
  51788. * @param configuration define the config where to copy the info
  51789. */
  51790. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51791. /**
  51792. * Serializes this Sub Surface configuration.
  51793. * @returns - An object with the serialized config.
  51794. */
  51795. serialize(): any;
  51796. /**
  51797. * Parses a anisotropy Configuration from a serialized object.
  51798. * @param source - Serialized object.
  51799. * @param scene Defines the scene we are parsing for
  51800. * @param rootUrl Defines the rootUrl to load from
  51801. */
  51802. parse(source: any, scene: Scene, rootUrl: string): void;
  51803. }
  51804. }
  51805. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51806. /** @hidden */
  51807. export var pbrFragmentDeclaration: {
  51808. name: string;
  51809. shader: string;
  51810. };
  51811. }
  51812. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51813. /** @hidden */
  51814. export var pbrUboDeclaration: {
  51815. name: string;
  51816. shader: string;
  51817. };
  51818. }
  51819. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51820. /** @hidden */
  51821. export var pbrFragmentExtraDeclaration: {
  51822. name: string;
  51823. shader: string;
  51824. };
  51825. }
  51826. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51827. /** @hidden */
  51828. export var pbrFragmentSamplersDeclaration: {
  51829. name: string;
  51830. shader: string;
  51831. };
  51832. }
  51833. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51834. /** @hidden */
  51835. export var pbrHelperFunctions: {
  51836. name: string;
  51837. shader: string;
  51838. };
  51839. }
  51840. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51841. /** @hidden */
  51842. export var harmonicsFunctions: {
  51843. name: string;
  51844. shader: string;
  51845. };
  51846. }
  51847. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51848. /** @hidden */
  51849. export var pbrDirectLightingSetupFunctions: {
  51850. name: string;
  51851. shader: string;
  51852. };
  51853. }
  51854. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51855. /** @hidden */
  51856. export var pbrDirectLightingFalloffFunctions: {
  51857. name: string;
  51858. shader: string;
  51859. };
  51860. }
  51861. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51862. /** @hidden */
  51863. export var pbrBRDFFunctions: {
  51864. name: string;
  51865. shader: string;
  51866. };
  51867. }
  51868. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51869. /** @hidden */
  51870. export var pbrDirectLightingFunctions: {
  51871. name: string;
  51872. shader: string;
  51873. };
  51874. }
  51875. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51876. /** @hidden */
  51877. export var pbrIBLFunctions: {
  51878. name: string;
  51879. shader: string;
  51880. };
  51881. }
  51882. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51883. /** @hidden */
  51884. export var pbrDebug: {
  51885. name: string;
  51886. shader: string;
  51887. };
  51888. }
  51889. declare module "babylonjs/Shaders/pbr.fragment" {
  51890. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51891. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51892. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51893. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51894. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51895. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51896. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51898. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51899. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51900. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51901. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51902. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51903. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51904. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51905. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51906. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51907. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51908. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51909. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51910. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51911. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51912. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51913. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51914. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51915. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51916. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51917. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51918. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51919. /** @hidden */
  51920. export var pbrPixelShader: {
  51921. name: string;
  51922. shader: string;
  51923. };
  51924. }
  51925. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51926. /** @hidden */
  51927. export var pbrVertexDeclaration: {
  51928. name: string;
  51929. shader: string;
  51930. };
  51931. }
  51932. declare module "babylonjs/Shaders/pbr.vertex" {
  51933. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51934. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51935. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51937. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51938. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51939. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51940. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51941. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51942. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51943. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51946. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51950. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51952. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51953. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51954. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51955. /** @hidden */
  51956. export var pbrVertexShader: {
  51957. name: string;
  51958. shader: string;
  51959. };
  51960. }
  51961. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51962. import { Nullable } from "babylonjs/types";
  51963. import { Scene } from "babylonjs/scene";
  51964. import { Matrix } from "babylonjs/Maths/math.vector";
  51965. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51967. import { Mesh } from "babylonjs/Meshes/mesh";
  51968. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51969. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51970. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51971. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51972. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51973. import { Color3 } from "babylonjs/Maths/math.color";
  51974. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51975. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51976. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51977. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51979. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51980. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51981. import "babylonjs/Shaders/pbr.fragment";
  51982. import "babylonjs/Shaders/pbr.vertex";
  51983. /**
  51984. * Manages the defines for the PBR Material.
  51985. * @hidden
  51986. */
  51987. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51988. PBR: boolean;
  51989. MAINUV1: boolean;
  51990. MAINUV2: boolean;
  51991. UV1: boolean;
  51992. UV2: boolean;
  51993. ALBEDO: boolean;
  51994. ALBEDODIRECTUV: number;
  51995. VERTEXCOLOR: boolean;
  51996. AMBIENT: boolean;
  51997. AMBIENTDIRECTUV: number;
  51998. AMBIENTINGRAYSCALE: boolean;
  51999. OPACITY: boolean;
  52000. VERTEXALPHA: boolean;
  52001. OPACITYDIRECTUV: number;
  52002. OPACITYRGB: boolean;
  52003. ALPHATEST: boolean;
  52004. DEPTHPREPASS: boolean;
  52005. ALPHABLEND: boolean;
  52006. ALPHAFROMALBEDO: boolean;
  52007. ALPHATESTVALUE: string;
  52008. SPECULAROVERALPHA: boolean;
  52009. RADIANCEOVERALPHA: boolean;
  52010. ALPHAFRESNEL: boolean;
  52011. LINEARALPHAFRESNEL: boolean;
  52012. PREMULTIPLYALPHA: boolean;
  52013. EMISSIVE: boolean;
  52014. EMISSIVEDIRECTUV: number;
  52015. REFLECTIVITY: boolean;
  52016. REFLECTIVITYDIRECTUV: number;
  52017. SPECULARTERM: boolean;
  52018. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52019. MICROSURFACEAUTOMATIC: boolean;
  52020. LODBASEDMICROSFURACE: boolean;
  52021. MICROSURFACEMAP: boolean;
  52022. MICROSURFACEMAPDIRECTUV: number;
  52023. METALLICWORKFLOW: boolean;
  52024. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52025. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52026. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52027. AOSTOREINMETALMAPRED: boolean;
  52028. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52029. ENVIRONMENTBRDF: boolean;
  52030. ENVIRONMENTBRDF_RGBD: boolean;
  52031. NORMAL: boolean;
  52032. TANGENT: boolean;
  52033. BUMP: boolean;
  52034. BUMPDIRECTUV: number;
  52035. OBJECTSPACE_NORMALMAP: boolean;
  52036. PARALLAX: boolean;
  52037. PARALLAXOCCLUSION: boolean;
  52038. NORMALXYSCALE: boolean;
  52039. LIGHTMAP: boolean;
  52040. LIGHTMAPDIRECTUV: number;
  52041. USELIGHTMAPASSHADOWMAP: boolean;
  52042. GAMMALIGHTMAP: boolean;
  52043. RGBDLIGHTMAP: boolean;
  52044. REFLECTION: boolean;
  52045. REFLECTIONMAP_3D: boolean;
  52046. REFLECTIONMAP_SPHERICAL: boolean;
  52047. REFLECTIONMAP_PLANAR: boolean;
  52048. REFLECTIONMAP_CUBIC: boolean;
  52049. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52050. REFLECTIONMAP_PROJECTION: boolean;
  52051. REFLECTIONMAP_SKYBOX: boolean;
  52052. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52053. REFLECTIONMAP_EXPLICIT: boolean;
  52054. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52055. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52056. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52057. INVERTCUBICMAP: boolean;
  52058. USESPHERICALFROMREFLECTIONMAP: boolean;
  52059. USEIRRADIANCEMAP: boolean;
  52060. SPHERICAL_HARMONICS: boolean;
  52061. USESPHERICALINVERTEX: boolean;
  52062. REFLECTIONMAP_OPPOSITEZ: boolean;
  52063. LODINREFLECTIONALPHA: boolean;
  52064. GAMMAREFLECTION: boolean;
  52065. RGBDREFLECTION: boolean;
  52066. LINEARSPECULARREFLECTION: boolean;
  52067. RADIANCEOCCLUSION: boolean;
  52068. HORIZONOCCLUSION: boolean;
  52069. INSTANCES: boolean;
  52070. NUM_BONE_INFLUENCERS: number;
  52071. BonesPerMesh: number;
  52072. BONETEXTURE: boolean;
  52073. NONUNIFORMSCALING: boolean;
  52074. MORPHTARGETS: boolean;
  52075. MORPHTARGETS_NORMAL: boolean;
  52076. MORPHTARGETS_TANGENT: boolean;
  52077. MORPHTARGETS_UV: boolean;
  52078. NUM_MORPH_INFLUENCERS: number;
  52079. IMAGEPROCESSING: boolean;
  52080. VIGNETTE: boolean;
  52081. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52082. VIGNETTEBLENDMODEOPAQUE: boolean;
  52083. TONEMAPPING: boolean;
  52084. TONEMAPPING_ACES: boolean;
  52085. CONTRAST: boolean;
  52086. COLORCURVES: boolean;
  52087. COLORGRADING: boolean;
  52088. COLORGRADING3D: boolean;
  52089. SAMPLER3DGREENDEPTH: boolean;
  52090. SAMPLER3DBGRMAP: boolean;
  52091. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52092. EXPOSURE: boolean;
  52093. MULTIVIEW: boolean;
  52094. USEPHYSICALLIGHTFALLOFF: boolean;
  52095. USEGLTFLIGHTFALLOFF: boolean;
  52096. TWOSIDEDLIGHTING: boolean;
  52097. SHADOWFLOAT: boolean;
  52098. CLIPPLANE: boolean;
  52099. CLIPPLANE2: boolean;
  52100. CLIPPLANE3: boolean;
  52101. CLIPPLANE4: boolean;
  52102. CLIPPLANE5: boolean;
  52103. CLIPPLANE6: boolean;
  52104. POINTSIZE: boolean;
  52105. FOG: boolean;
  52106. LOGARITHMICDEPTH: boolean;
  52107. FORCENORMALFORWARD: boolean;
  52108. SPECULARAA: boolean;
  52109. CLEARCOAT: boolean;
  52110. CLEARCOAT_DEFAULTIOR: boolean;
  52111. CLEARCOAT_TEXTURE: boolean;
  52112. CLEARCOAT_TEXTUREDIRECTUV: number;
  52113. CLEARCOAT_BUMP: boolean;
  52114. CLEARCOAT_BUMPDIRECTUV: number;
  52115. CLEARCOAT_TINT: boolean;
  52116. CLEARCOAT_TINT_TEXTURE: boolean;
  52117. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52118. ANISOTROPIC: boolean;
  52119. ANISOTROPIC_TEXTURE: boolean;
  52120. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52121. BRDF_V_HEIGHT_CORRELATED: boolean;
  52122. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52123. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52124. SHEEN: boolean;
  52125. SHEEN_TEXTURE: boolean;
  52126. SHEEN_TEXTUREDIRECTUV: number;
  52127. SHEEN_LINKWITHALBEDO: boolean;
  52128. SUBSURFACE: boolean;
  52129. SS_REFRACTION: boolean;
  52130. SS_TRANSLUCENCY: boolean;
  52131. SS_SCATERRING: boolean;
  52132. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52133. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52134. SS_REFRACTIONMAP_3D: boolean;
  52135. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52136. SS_LODINREFRACTIONALPHA: boolean;
  52137. SS_GAMMAREFRACTION: boolean;
  52138. SS_RGBDREFRACTION: boolean;
  52139. SS_LINEARSPECULARREFRACTION: boolean;
  52140. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52141. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52142. UNLIT: boolean;
  52143. DEBUGMODE: number;
  52144. /**
  52145. * Initializes the PBR Material defines.
  52146. */
  52147. constructor();
  52148. /**
  52149. * Resets the PBR Material defines.
  52150. */
  52151. reset(): void;
  52152. }
  52153. /**
  52154. * The Physically based material base class of BJS.
  52155. *
  52156. * This offers the main features of a standard PBR material.
  52157. * For more information, please refer to the documentation :
  52158. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52159. */
  52160. export abstract class PBRBaseMaterial extends PushMaterial {
  52161. /**
  52162. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52163. */
  52164. static readonly PBRMATERIAL_OPAQUE: number;
  52165. /**
  52166. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52167. */
  52168. static readonly PBRMATERIAL_ALPHATEST: number;
  52169. /**
  52170. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52171. */
  52172. static readonly PBRMATERIAL_ALPHABLEND: number;
  52173. /**
  52174. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52175. * They are also discarded below the alpha cutoff threshold to improve performances.
  52176. */
  52177. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52178. /**
  52179. * Defines the default value of how much AO map is occluding the analytical lights
  52180. * (point spot...).
  52181. */
  52182. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52183. /**
  52184. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52185. */
  52186. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52187. /**
  52188. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52189. * to enhance interoperability with other engines.
  52190. */
  52191. static readonly LIGHTFALLOFF_GLTF: number;
  52192. /**
  52193. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52194. * to enhance interoperability with other materials.
  52195. */
  52196. static readonly LIGHTFALLOFF_STANDARD: number;
  52197. /**
  52198. * Intensity of the direct lights e.g. the four lights available in your scene.
  52199. * This impacts both the direct diffuse and specular highlights.
  52200. */
  52201. protected _directIntensity: number;
  52202. /**
  52203. * Intensity of the emissive part of the material.
  52204. * This helps controlling the emissive effect without modifying the emissive color.
  52205. */
  52206. protected _emissiveIntensity: number;
  52207. /**
  52208. * Intensity of the environment e.g. how much the environment will light the object
  52209. * either through harmonics for rough material or through the refelction for shiny ones.
  52210. */
  52211. protected _environmentIntensity: number;
  52212. /**
  52213. * This is a special control allowing the reduction of the specular highlights coming from the
  52214. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52215. */
  52216. protected _specularIntensity: number;
  52217. /**
  52218. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52219. */
  52220. private _lightingInfos;
  52221. /**
  52222. * Debug Control allowing disabling the bump map on this material.
  52223. */
  52224. protected _disableBumpMap: boolean;
  52225. /**
  52226. * AKA Diffuse Texture in standard nomenclature.
  52227. */
  52228. protected _albedoTexture: Nullable<BaseTexture>;
  52229. /**
  52230. * AKA Occlusion Texture in other nomenclature.
  52231. */
  52232. protected _ambientTexture: Nullable<BaseTexture>;
  52233. /**
  52234. * AKA Occlusion Texture Intensity in other nomenclature.
  52235. */
  52236. protected _ambientTextureStrength: number;
  52237. /**
  52238. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52239. * 1 means it completely occludes it
  52240. * 0 mean it has no impact
  52241. */
  52242. protected _ambientTextureImpactOnAnalyticalLights: number;
  52243. /**
  52244. * Stores the alpha values in a texture.
  52245. */
  52246. protected _opacityTexture: Nullable<BaseTexture>;
  52247. /**
  52248. * Stores the reflection values in a texture.
  52249. */
  52250. protected _reflectionTexture: Nullable<BaseTexture>;
  52251. /**
  52252. * Stores the emissive values in a texture.
  52253. */
  52254. protected _emissiveTexture: Nullable<BaseTexture>;
  52255. /**
  52256. * AKA Specular texture in other nomenclature.
  52257. */
  52258. protected _reflectivityTexture: Nullable<BaseTexture>;
  52259. /**
  52260. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52261. */
  52262. protected _metallicTexture: Nullable<BaseTexture>;
  52263. /**
  52264. * Specifies the metallic scalar of the metallic/roughness workflow.
  52265. * Can also be used to scale the metalness values of the metallic texture.
  52266. */
  52267. protected _metallic: Nullable<number>;
  52268. /**
  52269. * Specifies the roughness scalar of the metallic/roughness workflow.
  52270. * Can also be used to scale the roughness values of the metallic texture.
  52271. */
  52272. protected _roughness: Nullable<number>;
  52273. /**
  52274. * Specifies the an F0 factor to help configuring the material F0.
  52275. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52276. * to 0.5 the previously hard coded value stays the same.
  52277. * Can also be used to scale the F0 values of the metallic texture.
  52278. */
  52279. protected _metallicF0Factor: number;
  52280. /**
  52281. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52282. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52283. * your expectation as it multiplies with the texture data.
  52284. */
  52285. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52286. /**
  52287. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52288. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52289. */
  52290. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52291. /**
  52292. * Stores surface normal data used to displace a mesh in a texture.
  52293. */
  52294. protected _bumpTexture: Nullable<BaseTexture>;
  52295. /**
  52296. * Stores the pre-calculated light information of a mesh in a texture.
  52297. */
  52298. protected _lightmapTexture: Nullable<BaseTexture>;
  52299. /**
  52300. * The color of a material in ambient lighting.
  52301. */
  52302. protected _ambientColor: Color3;
  52303. /**
  52304. * AKA Diffuse Color in other nomenclature.
  52305. */
  52306. protected _albedoColor: Color3;
  52307. /**
  52308. * AKA Specular Color in other nomenclature.
  52309. */
  52310. protected _reflectivityColor: Color3;
  52311. /**
  52312. * The color applied when light is reflected from a material.
  52313. */
  52314. protected _reflectionColor: Color3;
  52315. /**
  52316. * The color applied when light is emitted from a material.
  52317. */
  52318. protected _emissiveColor: Color3;
  52319. /**
  52320. * AKA Glossiness in other nomenclature.
  52321. */
  52322. protected _microSurface: number;
  52323. /**
  52324. * Specifies that the material will use the light map as a show map.
  52325. */
  52326. protected _useLightmapAsShadowmap: boolean;
  52327. /**
  52328. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52329. * makes the reflect vector face the model (under horizon).
  52330. */
  52331. protected _useHorizonOcclusion: boolean;
  52332. /**
  52333. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52334. * too much the area relying on ambient texture to define their ambient occlusion.
  52335. */
  52336. protected _useRadianceOcclusion: boolean;
  52337. /**
  52338. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52339. */
  52340. protected _useAlphaFromAlbedoTexture: boolean;
  52341. /**
  52342. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52343. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52344. */
  52345. protected _useSpecularOverAlpha: boolean;
  52346. /**
  52347. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52348. */
  52349. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52350. /**
  52351. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52352. */
  52353. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52354. /**
  52355. * Specifies if the metallic texture contains the roughness information in its green channel.
  52356. */
  52357. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52358. /**
  52359. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52360. */
  52361. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52362. /**
  52363. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52364. */
  52365. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52366. /**
  52367. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52368. */
  52369. protected _useAmbientInGrayScale: boolean;
  52370. /**
  52371. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52372. * The material will try to infer what glossiness each pixel should be.
  52373. */
  52374. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52375. /**
  52376. * Defines the falloff type used in this material.
  52377. * It by default is Physical.
  52378. */
  52379. protected _lightFalloff: number;
  52380. /**
  52381. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52382. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52383. */
  52384. protected _useRadianceOverAlpha: boolean;
  52385. /**
  52386. * Allows using an object space normal map (instead of tangent space).
  52387. */
  52388. protected _useObjectSpaceNormalMap: boolean;
  52389. /**
  52390. * Allows using the bump map in parallax mode.
  52391. */
  52392. protected _useParallax: boolean;
  52393. /**
  52394. * Allows using the bump map in parallax occlusion mode.
  52395. */
  52396. protected _useParallaxOcclusion: boolean;
  52397. /**
  52398. * Controls the scale bias of the parallax mode.
  52399. */
  52400. protected _parallaxScaleBias: number;
  52401. /**
  52402. * If sets to true, disables all the lights affecting the material.
  52403. */
  52404. protected _disableLighting: boolean;
  52405. /**
  52406. * Number of Simultaneous lights allowed on the material.
  52407. */
  52408. protected _maxSimultaneousLights: number;
  52409. /**
  52410. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52411. */
  52412. protected _invertNormalMapX: boolean;
  52413. /**
  52414. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52415. */
  52416. protected _invertNormalMapY: boolean;
  52417. /**
  52418. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52419. */
  52420. protected _twoSidedLighting: boolean;
  52421. /**
  52422. * Defines the alpha limits in alpha test mode.
  52423. */
  52424. protected _alphaCutOff: number;
  52425. /**
  52426. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52427. */
  52428. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  52432. */
  52433. protected _useAlphaFresnel: boolean;
  52434. /**
  52435. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52436. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52437. */
  52438. protected _useLinearAlphaFresnel: boolean;
  52439. /**
  52440. * The transparency mode of the material.
  52441. */
  52442. protected _transparencyMode: Nullable<number>;
  52443. /**
  52444. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52445. * from cos thetav and roughness:
  52446. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52447. */
  52448. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52449. /**
  52450. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52451. */
  52452. protected _forceIrradianceInFragment: boolean;
  52453. /**
  52454. * Force normal to face away from face.
  52455. */
  52456. protected _forceNormalForward: boolean;
  52457. /**
  52458. * Enables specular anti aliasing in the PBR shader.
  52459. * It will both interacts on the Geometry for analytical and IBL lighting.
  52460. * It also prefilter the roughness map based on the bump values.
  52461. */
  52462. protected _enableSpecularAntiAliasing: boolean;
  52463. /**
  52464. * Default configuration related to image processing available in the PBR Material.
  52465. */
  52466. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52467. /**
  52468. * Keep track of the image processing observer to allow dispose and replace.
  52469. */
  52470. private _imageProcessingObserver;
  52471. /**
  52472. * Attaches a new image processing configuration to the PBR Material.
  52473. * @param configuration
  52474. */
  52475. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52476. /**
  52477. * Stores the available render targets.
  52478. */
  52479. private _renderTargets;
  52480. /**
  52481. * Sets the global ambient color for the material used in lighting calculations.
  52482. */
  52483. private _globalAmbientColor;
  52484. /**
  52485. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52486. */
  52487. private _useLogarithmicDepth;
  52488. /**
  52489. * If set to true, no lighting calculations will be applied.
  52490. */
  52491. private _unlit;
  52492. private _debugMode;
  52493. /**
  52494. * @hidden
  52495. * This is reserved for the inspector.
  52496. * Defines the material debug mode.
  52497. * It helps seeing only some components of the material while troubleshooting.
  52498. */
  52499. debugMode: number;
  52500. /**
  52501. * @hidden
  52502. * This is reserved for the inspector.
  52503. * Specify from where on screen the debug mode should start.
  52504. * The value goes from -1 (full screen) to 1 (not visible)
  52505. * It helps with side by side comparison against the final render
  52506. * This defaults to -1
  52507. */
  52508. private debugLimit;
  52509. /**
  52510. * @hidden
  52511. * This is reserved for the inspector.
  52512. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52513. * You can use the factor to better multiply the final value.
  52514. */
  52515. private debugFactor;
  52516. /**
  52517. * Defines the clear coat layer parameters for the material.
  52518. */
  52519. readonly clearCoat: PBRClearCoatConfiguration;
  52520. /**
  52521. * Defines the anisotropic parameters for the material.
  52522. */
  52523. readonly anisotropy: PBRAnisotropicConfiguration;
  52524. /**
  52525. * Defines the BRDF parameters for the material.
  52526. */
  52527. readonly brdf: PBRBRDFConfiguration;
  52528. /**
  52529. * Defines the Sheen parameters for the material.
  52530. */
  52531. readonly sheen: PBRSheenConfiguration;
  52532. /**
  52533. * Defines the SubSurface parameters for the material.
  52534. */
  52535. readonly subSurface: PBRSubSurfaceConfiguration;
  52536. /**
  52537. * Custom callback helping to override the default shader used in the material.
  52538. */
  52539. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52540. protected _rebuildInParallel: boolean;
  52541. /**
  52542. * Instantiates a new PBRMaterial instance.
  52543. *
  52544. * @param name The material name
  52545. * @param scene The scene the material will be use in.
  52546. */
  52547. constructor(name: string, scene: Scene);
  52548. /**
  52549. * Gets a boolean indicating that current material needs to register RTT
  52550. */
  52551. get hasRenderTargetTextures(): boolean;
  52552. /**
  52553. * Gets the name of the material class.
  52554. */
  52555. getClassName(): string;
  52556. /**
  52557. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52558. */
  52559. get useLogarithmicDepth(): boolean;
  52560. /**
  52561. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52562. */
  52563. set useLogarithmicDepth(value: boolean);
  52564. /**
  52565. * Gets the current transparency mode.
  52566. */
  52567. get transparencyMode(): Nullable<number>;
  52568. /**
  52569. * Sets the transparency mode of the material.
  52570. *
  52571. * | Value | Type | Description |
  52572. * | ----- | ----------------------------------- | ----------- |
  52573. * | 0 | OPAQUE | |
  52574. * | 1 | ALPHATEST | |
  52575. * | 2 | ALPHABLEND | |
  52576. * | 3 | ALPHATESTANDBLEND | |
  52577. *
  52578. */
  52579. set transparencyMode(value: Nullable<number>);
  52580. /**
  52581. * Returns true if alpha blending should be disabled.
  52582. */
  52583. private get _disableAlphaBlending();
  52584. /**
  52585. * Specifies whether or not this material should be rendered in alpha blend mode.
  52586. */
  52587. needAlphaBlending(): boolean;
  52588. /**
  52589. * Specifies if the mesh will require alpha blending.
  52590. * @param mesh - BJS mesh.
  52591. */
  52592. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52593. /**
  52594. * Specifies whether or not this material should be rendered in alpha test mode.
  52595. */
  52596. needAlphaTesting(): boolean;
  52597. /**
  52598. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52599. */
  52600. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52601. /**
  52602. * Gets the texture used for the alpha test.
  52603. */
  52604. getAlphaTestTexture(): Nullable<BaseTexture>;
  52605. /**
  52606. * Specifies that the submesh is ready to be used.
  52607. * @param mesh - BJS mesh.
  52608. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52609. * @param useInstances - Specifies that instances should be used.
  52610. * @returns - boolean indicating that the submesh is ready or not.
  52611. */
  52612. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52613. /**
  52614. * Specifies if the material uses metallic roughness workflow.
  52615. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52616. */
  52617. isMetallicWorkflow(): boolean;
  52618. private _prepareEffect;
  52619. private _prepareDefines;
  52620. /**
  52621. * Force shader compilation
  52622. */
  52623. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52624. /**
  52625. * Initializes the uniform buffer layout for the shader.
  52626. */
  52627. buildUniformLayout(): void;
  52628. /**
  52629. * Unbinds the material from the mesh
  52630. */
  52631. unbind(): void;
  52632. /**
  52633. * Binds the submesh data.
  52634. * @param world - The world matrix.
  52635. * @param mesh - The BJS mesh.
  52636. * @param subMesh - A submesh of the BJS mesh.
  52637. */
  52638. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52639. /**
  52640. * Returns the animatable textures.
  52641. * @returns - Array of animatable textures.
  52642. */
  52643. getAnimatables(): IAnimatable[];
  52644. /**
  52645. * Returns the texture used for reflections.
  52646. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52647. */
  52648. private _getReflectionTexture;
  52649. /**
  52650. * Returns an array of the actively used textures.
  52651. * @returns - Array of BaseTextures
  52652. */
  52653. getActiveTextures(): BaseTexture[];
  52654. /**
  52655. * Checks to see if a texture is used in the material.
  52656. * @param texture - Base texture to use.
  52657. * @returns - Boolean specifying if a texture is used in the material.
  52658. */
  52659. hasTexture(texture: BaseTexture): boolean;
  52660. /**
  52661. * Disposes the resources of the material.
  52662. * @param forceDisposeEffect - Forces the disposal of effects.
  52663. * @param forceDisposeTextures - Forces the disposal of all textures.
  52664. */
  52665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52666. }
  52667. }
  52668. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52669. import { Nullable } from "babylonjs/types";
  52670. import { Scene } from "babylonjs/scene";
  52671. import { Color3 } from "babylonjs/Maths/math.color";
  52672. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52673. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52675. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52676. /**
  52677. * The Physically based material of BJS.
  52678. *
  52679. * This offers the main features of a standard PBR material.
  52680. * For more information, please refer to the documentation :
  52681. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52682. */
  52683. export class PBRMaterial extends PBRBaseMaterial {
  52684. /**
  52685. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52686. */
  52687. static readonly PBRMATERIAL_OPAQUE: number;
  52688. /**
  52689. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52690. */
  52691. static readonly PBRMATERIAL_ALPHATEST: number;
  52692. /**
  52693. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52694. */
  52695. static readonly PBRMATERIAL_ALPHABLEND: number;
  52696. /**
  52697. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52698. * They are also discarded below the alpha cutoff threshold to improve performances.
  52699. */
  52700. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52701. /**
  52702. * Defines the default value of how much AO map is occluding the analytical lights
  52703. * (point spot...).
  52704. */
  52705. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52706. /**
  52707. * Intensity of the direct lights e.g. the four lights available in your scene.
  52708. * This impacts both the direct diffuse and specular highlights.
  52709. */
  52710. directIntensity: number;
  52711. /**
  52712. * Intensity of the emissive part of the material.
  52713. * This helps controlling the emissive effect without modifying the emissive color.
  52714. */
  52715. emissiveIntensity: number;
  52716. /**
  52717. * Intensity of the environment e.g. how much the environment will light the object
  52718. * either through harmonics for rough material or through the refelction for shiny ones.
  52719. */
  52720. environmentIntensity: number;
  52721. /**
  52722. * This is a special control allowing the reduction of the specular highlights coming from the
  52723. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52724. */
  52725. specularIntensity: number;
  52726. /**
  52727. * Debug Control allowing disabling the bump map on this material.
  52728. */
  52729. disableBumpMap: boolean;
  52730. /**
  52731. * AKA Diffuse Texture in standard nomenclature.
  52732. */
  52733. albedoTexture: BaseTexture;
  52734. /**
  52735. * AKA Occlusion Texture in other nomenclature.
  52736. */
  52737. ambientTexture: BaseTexture;
  52738. /**
  52739. * AKA Occlusion Texture Intensity in other nomenclature.
  52740. */
  52741. ambientTextureStrength: number;
  52742. /**
  52743. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52744. * 1 means it completely occludes it
  52745. * 0 mean it has no impact
  52746. */
  52747. ambientTextureImpactOnAnalyticalLights: number;
  52748. /**
  52749. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52750. */
  52751. opacityTexture: BaseTexture;
  52752. /**
  52753. * Stores the reflection values in a texture.
  52754. */
  52755. reflectionTexture: Nullable<BaseTexture>;
  52756. /**
  52757. * Stores the emissive values in a texture.
  52758. */
  52759. emissiveTexture: BaseTexture;
  52760. /**
  52761. * AKA Specular texture in other nomenclature.
  52762. */
  52763. reflectivityTexture: BaseTexture;
  52764. /**
  52765. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52766. */
  52767. metallicTexture: BaseTexture;
  52768. /**
  52769. * Specifies the metallic scalar of the metallic/roughness workflow.
  52770. * Can also be used to scale the metalness values of the metallic texture.
  52771. */
  52772. metallic: Nullable<number>;
  52773. /**
  52774. * Specifies the roughness scalar of the metallic/roughness workflow.
  52775. * Can also be used to scale the roughness values of the metallic texture.
  52776. */
  52777. roughness: Nullable<number>;
  52778. /**
  52779. * Specifies the an F0 factor to help configuring the material F0.
  52780. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52781. * to 0.5 the previously hard coded value stays the same.
  52782. * Can also be used to scale the F0 values of the metallic texture.
  52783. */
  52784. metallicF0Factor: number;
  52785. /**
  52786. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52787. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52788. * your expectation as it multiplies with the texture data.
  52789. */
  52790. useMetallicF0FactorFromMetallicTexture: boolean;
  52791. /**
  52792. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52793. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52794. */
  52795. microSurfaceTexture: BaseTexture;
  52796. /**
  52797. * Stores surface normal data used to displace a mesh in a texture.
  52798. */
  52799. bumpTexture: BaseTexture;
  52800. /**
  52801. * Stores the pre-calculated light information of a mesh in a texture.
  52802. */
  52803. lightmapTexture: BaseTexture;
  52804. /**
  52805. * Stores the refracted light information in a texture.
  52806. */
  52807. get refractionTexture(): Nullable<BaseTexture>;
  52808. set refractionTexture(value: Nullable<BaseTexture>);
  52809. /**
  52810. * The color of a material in ambient lighting.
  52811. */
  52812. ambientColor: Color3;
  52813. /**
  52814. * AKA Diffuse Color in other nomenclature.
  52815. */
  52816. albedoColor: Color3;
  52817. /**
  52818. * AKA Specular Color in other nomenclature.
  52819. */
  52820. reflectivityColor: Color3;
  52821. /**
  52822. * The color reflected from the material.
  52823. */
  52824. reflectionColor: Color3;
  52825. /**
  52826. * The color emitted from the material.
  52827. */
  52828. emissiveColor: Color3;
  52829. /**
  52830. * AKA Glossiness in other nomenclature.
  52831. */
  52832. microSurface: number;
  52833. /**
  52834. * source material index of refraction (IOR)' / 'destination material IOR.
  52835. */
  52836. get indexOfRefraction(): number;
  52837. set indexOfRefraction(value: number);
  52838. /**
  52839. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52840. */
  52841. get invertRefractionY(): boolean;
  52842. set invertRefractionY(value: boolean);
  52843. /**
  52844. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52845. * Materials half opaque for instance using refraction could benefit from this control.
  52846. */
  52847. get linkRefractionWithTransparency(): boolean;
  52848. set linkRefractionWithTransparency(value: boolean);
  52849. /**
  52850. * If true, the light map contains occlusion information instead of lighting info.
  52851. */
  52852. useLightmapAsShadowmap: boolean;
  52853. /**
  52854. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52855. */
  52856. useAlphaFromAlbedoTexture: boolean;
  52857. /**
  52858. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52859. */
  52860. forceAlphaTest: boolean;
  52861. /**
  52862. * Defines the alpha limits in alpha test mode.
  52863. */
  52864. alphaCutOff: number;
  52865. /**
  52866. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52867. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52868. */
  52869. useSpecularOverAlpha: boolean;
  52870. /**
  52871. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52872. */
  52873. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52874. /**
  52875. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52876. */
  52877. useRoughnessFromMetallicTextureAlpha: boolean;
  52878. /**
  52879. * Specifies if the metallic texture contains the roughness information in its green channel.
  52880. */
  52881. useRoughnessFromMetallicTextureGreen: boolean;
  52882. /**
  52883. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52884. */
  52885. useMetallnessFromMetallicTextureBlue: boolean;
  52886. /**
  52887. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52888. */
  52889. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52890. /**
  52891. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52892. */
  52893. useAmbientInGrayScale: boolean;
  52894. /**
  52895. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52896. * The material will try to infer what glossiness each pixel should be.
  52897. */
  52898. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52899. /**
  52900. * BJS is using an harcoded light falloff based on a manually sets up range.
  52901. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52902. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52903. */
  52904. get usePhysicalLightFalloff(): boolean;
  52905. /**
  52906. * BJS is using an harcoded light falloff based on a manually sets up range.
  52907. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52908. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52909. */
  52910. set usePhysicalLightFalloff(value: 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. get useGLTFLightFalloff(): boolean;
  52916. /**
  52917. * In order to support the falloff compatibility with gltf, a special mode has been added
  52918. * to reproduce the gltf light falloff.
  52919. */
  52920. set useGLTFLightFalloff(value: boolean);
  52921. /**
  52922. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52923. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52924. */
  52925. useRadianceOverAlpha: boolean;
  52926. /**
  52927. * Allows using an object space normal map (instead of tangent space).
  52928. */
  52929. useObjectSpaceNormalMap: boolean;
  52930. /**
  52931. * Allows using the bump map in parallax mode.
  52932. */
  52933. useParallax: boolean;
  52934. /**
  52935. * Allows using the bump map in parallax occlusion mode.
  52936. */
  52937. useParallaxOcclusion: boolean;
  52938. /**
  52939. * Controls the scale bias of the parallax mode.
  52940. */
  52941. parallaxScaleBias: number;
  52942. /**
  52943. * If sets to true, disables all the lights affecting the material.
  52944. */
  52945. disableLighting: boolean;
  52946. /**
  52947. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52948. */
  52949. forceIrradianceInFragment: boolean;
  52950. /**
  52951. * Number of Simultaneous lights allowed on the material.
  52952. */
  52953. maxSimultaneousLights: number;
  52954. /**
  52955. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52956. */
  52957. invertNormalMapX: boolean;
  52958. /**
  52959. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52960. */
  52961. invertNormalMapY: boolean;
  52962. /**
  52963. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52964. */
  52965. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  52969. */
  52970. useAlphaFresnel: boolean;
  52971. /**
  52972. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52973. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52974. */
  52975. useLinearAlphaFresnel: boolean;
  52976. /**
  52977. * Let user defines the brdf lookup texture used for IBL.
  52978. * A default 8bit version is embedded but you could point at :
  52979. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52980. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52981. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52982. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52983. */
  52984. environmentBRDFTexture: Nullable<BaseTexture>;
  52985. /**
  52986. * Force normal to face away from face.
  52987. */
  52988. forceNormalForward: boolean;
  52989. /**
  52990. * Enables specular anti aliasing in the PBR shader.
  52991. * It will both interacts on the Geometry for analytical and IBL lighting.
  52992. * It also prefilter the roughness map based on the bump values.
  52993. */
  52994. enableSpecularAntiAliasing: boolean;
  52995. /**
  52996. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52997. * makes the reflect vector face the model (under horizon).
  52998. */
  52999. useHorizonOcclusion: boolean;
  53000. /**
  53001. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53002. * too much the area relying on ambient texture to define their ambient occlusion.
  53003. */
  53004. useRadianceOcclusion: boolean;
  53005. /**
  53006. * If set to true, no lighting calculations will be applied.
  53007. */
  53008. unlit: boolean;
  53009. /**
  53010. * Gets the image processing configuration used either in this material.
  53011. */
  53012. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53013. /**
  53014. * Sets the Default image processing configuration used either in the this material.
  53015. *
  53016. * If sets to null, the scene one is in use.
  53017. */
  53018. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53019. /**
  53020. * Gets wether the color curves effect is enabled.
  53021. */
  53022. get cameraColorCurvesEnabled(): boolean;
  53023. /**
  53024. * Sets wether the color curves effect is enabled.
  53025. */
  53026. set cameraColorCurvesEnabled(value: boolean);
  53027. /**
  53028. * Gets wether the color grading effect is enabled.
  53029. */
  53030. get cameraColorGradingEnabled(): boolean;
  53031. /**
  53032. * Gets wether the color grading effect is enabled.
  53033. */
  53034. set cameraColorGradingEnabled(value: boolean);
  53035. /**
  53036. * Gets wether tonemapping is enabled or not.
  53037. */
  53038. get cameraToneMappingEnabled(): boolean;
  53039. /**
  53040. * Sets wether tonemapping is enabled or not
  53041. */
  53042. set cameraToneMappingEnabled(value: boolean);
  53043. /**
  53044. * The camera exposure used on this material.
  53045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53046. * This corresponds to a photographic exposure.
  53047. */
  53048. get cameraExposure(): number;
  53049. /**
  53050. * The camera exposure used on this material.
  53051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53052. * This corresponds to a photographic exposure.
  53053. */
  53054. set cameraExposure(value: number);
  53055. /**
  53056. * Gets The camera contrast used on this material.
  53057. */
  53058. get cameraContrast(): number;
  53059. /**
  53060. * Sets The camera contrast used on this material.
  53061. */
  53062. set cameraContrast(value: number);
  53063. /**
  53064. * Gets the Color Grading 2D Lookup Texture.
  53065. */
  53066. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53067. /**
  53068. * Sets the Color Grading 2D Lookup Texture.
  53069. */
  53070. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53071. /**
  53072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53074. * 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;
  53075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53076. */
  53077. get cameraColorCurves(): Nullable<ColorCurves>;
  53078. /**
  53079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53081. * 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;
  53082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53083. */
  53084. set cameraColorCurves(value: Nullable<ColorCurves>);
  53085. /**
  53086. * Instantiates a new PBRMaterial instance.
  53087. *
  53088. * @param name The material name
  53089. * @param scene The scene the material will be use in.
  53090. */
  53091. constructor(name: string, scene: Scene);
  53092. /**
  53093. * Returns the name of this material class.
  53094. */
  53095. getClassName(): string;
  53096. /**
  53097. * Makes a duplicate of the current material.
  53098. * @param name - name to use for the new material.
  53099. */
  53100. clone(name: string): PBRMaterial;
  53101. /**
  53102. * Serializes this PBR Material.
  53103. * @returns - An object with the serialized material.
  53104. */
  53105. serialize(): any;
  53106. /**
  53107. * Parses a PBR Material from a serialized object.
  53108. * @param source - Serialized object.
  53109. * @param scene - BJS scene instance.
  53110. * @param rootUrl - url for the scene object
  53111. * @returns - PBRMaterial
  53112. */
  53113. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53114. }
  53115. }
  53116. declare module "babylonjs/Misc/dds" {
  53117. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53119. import { Nullable } from "babylonjs/types";
  53120. import { Scene } from "babylonjs/scene";
  53121. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53122. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53123. /**
  53124. * Direct draw surface info
  53125. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53126. */
  53127. export interface DDSInfo {
  53128. /**
  53129. * Width of the texture
  53130. */
  53131. width: number;
  53132. /**
  53133. * Width of the texture
  53134. */
  53135. height: number;
  53136. /**
  53137. * Number of Mipmaps for the texture
  53138. * @see https://en.wikipedia.org/wiki/Mipmap
  53139. */
  53140. mipmapCount: number;
  53141. /**
  53142. * If the textures format is a known fourCC format
  53143. * @see https://www.fourcc.org/
  53144. */
  53145. isFourCC: boolean;
  53146. /**
  53147. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53148. */
  53149. isRGB: boolean;
  53150. /**
  53151. * If the texture is a lumincance format
  53152. */
  53153. isLuminance: boolean;
  53154. /**
  53155. * If this is a cube texture
  53156. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53157. */
  53158. isCube: boolean;
  53159. /**
  53160. * If the texture is a compressed format eg. FOURCC_DXT1
  53161. */
  53162. isCompressed: boolean;
  53163. /**
  53164. * The dxgiFormat of the texture
  53165. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53166. */
  53167. dxgiFormat: number;
  53168. /**
  53169. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53170. */
  53171. textureType: number;
  53172. /**
  53173. * Sphericle polynomial created for the dds texture
  53174. */
  53175. sphericalPolynomial?: SphericalPolynomial;
  53176. }
  53177. /**
  53178. * Class used to provide DDS decompression tools
  53179. */
  53180. export class DDSTools {
  53181. /**
  53182. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53183. */
  53184. static StoreLODInAlphaChannel: boolean;
  53185. /**
  53186. * Gets DDS information from an array buffer
  53187. * @param arrayBuffer defines the array buffer to read data from
  53188. * @returns the DDS information
  53189. */
  53190. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53191. private static _FloatView;
  53192. private static _Int32View;
  53193. private static _ToHalfFloat;
  53194. private static _FromHalfFloat;
  53195. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53196. private static _GetHalfFloatRGBAArrayBuffer;
  53197. private static _GetFloatRGBAArrayBuffer;
  53198. private static _GetFloatAsUIntRGBAArrayBuffer;
  53199. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53200. private static _GetRGBAArrayBuffer;
  53201. private static _ExtractLongWordOrder;
  53202. private static _GetRGBArrayBuffer;
  53203. private static _GetLuminanceArrayBuffer;
  53204. /**
  53205. * Uploads DDS Levels to a Babylon Texture
  53206. * @hidden
  53207. */
  53208. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53209. }
  53210. module "babylonjs/Engines/thinEngine" {
  53211. interface ThinEngine {
  53212. /**
  53213. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53214. * @param rootUrl defines the url where the file to load is located
  53215. * @param scene defines the current scene
  53216. * @param lodScale defines scale to apply to the mip map selection
  53217. * @param lodOffset defines offset to apply to the mip map selection
  53218. * @param onLoad defines an optional callback raised when the texture is loaded
  53219. * @param onError defines an optional callback raised if there is an issue to load the texture
  53220. * @param format defines the format of the data
  53221. * @param forcedExtension defines the extension to use to pick the right loader
  53222. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53223. * @returns the cube texture as an InternalTexture
  53224. */
  53225. 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;
  53226. }
  53227. }
  53228. }
  53229. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53230. import { Nullable } from "babylonjs/types";
  53231. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53232. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53233. /**
  53234. * Implementation of the DDS Texture Loader.
  53235. * @hidden
  53236. */
  53237. export class _DDSTextureLoader implements IInternalTextureLoader {
  53238. /**
  53239. * Defines wether the loader supports cascade loading the different faces.
  53240. */
  53241. readonly supportCascades: boolean;
  53242. /**
  53243. * This returns if the loader support the current file information.
  53244. * @param extension defines the file extension of the file being loaded
  53245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53246. * @param fallback defines the fallback internal texture if any
  53247. * @param isBase64 defines whether the texture is encoded as a base64
  53248. * @param isBuffer defines whether the texture data are stored as a buffer
  53249. * @returns true if the loader can load the specified file
  53250. */
  53251. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53252. /**
  53253. * Transform the url before loading if required.
  53254. * @param rootUrl the url of the texture
  53255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53256. * @returns the transformed texture
  53257. */
  53258. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53259. /**
  53260. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53261. * @param rootUrl the url of the texture
  53262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53263. * @returns the fallback texture
  53264. */
  53265. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53266. /**
  53267. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53268. * @param data contains the texture data
  53269. * @param texture defines the BabylonJS internal texture
  53270. * @param createPolynomials will be true if polynomials have been requested
  53271. * @param onLoad defines the callback to trigger once the texture is ready
  53272. * @param onError defines the callback to trigger in case of error
  53273. */
  53274. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53275. /**
  53276. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53277. * @param data contains the texture data
  53278. * @param texture defines the BabylonJS internal texture
  53279. * @param callback defines the method to call once ready to upload
  53280. */
  53281. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53282. }
  53283. }
  53284. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53285. import { Nullable } from "babylonjs/types";
  53286. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53287. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53288. /**
  53289. * Implementation of the ENV Texture Loader.
  53290. * @hidden
  53291. */
  53292. export class _ENVTextureLoader implements IInternalTextureLoader {
  53293. /**
  53294. * Defines wether the loader supports cascade loading the different faces.
  53295. */
  53296. readonly supportCascades: boolean;
  53297. /**
  53298. * This returns if the loader support the current file information.
  53299. * @param extension defines the file extension of the file being loaded
  53300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53301. * @param fallback defines the fallback internal texture if any
  53302. * @param isBase64 defines whether the texture is encoded as a base64
  53303. * @param isBuffer defines whether the texture data are stored as a buffer
  53304. * @returns true if the loader can load the specified file
  53305. */
  53306. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53307. /**
  53308. * Transform the url before loading if required.
  53309. * @param rootUrl the url of the texture
  53310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53311. * @returns the transformed texture
  53312. */
  53313. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53314. /**
  53315. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53316. * @param rootUrl the url of the texture
  53317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53318. * @returns the fallback texture
  53319. */
  53320. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53321. /**
  53322. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53323. * @param data contains the texture data
  53324. * @param texture defines the BabylonJS internal texture
  53325. * @param createPolynomials will be true if polynomials have been requested
  53326. * @param onLoad defines the callback to trigger once the texture is ready
  53327. * @param onError defines the callback to trigger in case of error
  53328. */
  53329. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53330. /**
  53331. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53332. * @param data contains the texture data
  53333. * @param texture defines the BabylonJS internal texture
  53334. * @param callback defines the method to call once ready to upload
  53335. */
  53336. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53337. }
  53338. }
  53339. declare module "babylonjs/Misc/khronosTextureContainer" {
  53340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53341. /**
  53342. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53343. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53344. */
  53345. export class KhronosTextureContainer {
  53346. /** contents of the KTX container file */
  53347. arrayBuffer: any;
  53348. private static HEADER_LEN;
  53349. private static COMPRESSED_2D;
  53350. private static COMPRESSED_3D;
  53351. private static TEX_2D;
  53352. private static TEX_3D;
  53353. /**
  53354. * Gets the openGL type
  53355. */
  53356. glType: number;
  53357. /**
  53358. * Gets the openGL type size
  53359. */
  53360. glTypeSize: number;
  53361. /**
  53362. * Gets the openGL format
  53363. */
  53364. glFormat: number;
  53365. /**
  53366. * Gets the openGL internal format
  53367. */
  53368. glInternalFormat: number;
  53369. /**
  53370. * Gets the base internal format
  53371. */
  53372. glBaseInternalFormat: number;
  53373. /**
  53374. * Gets image width in pixel
  53375. */
  53376. pixelWidth: number;
  53377. /**
  53378. * Gets image height in pixel
  53379. */
  53380. pixelHeight: number;
  53381. /**
  53382. * Gets image depth in pixels
  53383. */
  53384. pixelDepth: number;
  53385. /**
  53386. * Gets the number of array elements
  53387. */
  53388. numberOfArrayElements: number;
  53389. /**
  53390. * Gets the number of faces
  53391. */
  53392. numberOfFaces: number;
  53393. /**
  53394. * Gets the number of mipmap levels
  53395. */
  53396. numberOfMipmapLevels: number;
  53397. /**
  53398. * Gets the bytes of key value data
  53399. */
  53400. bytesOfKeyValueData: number;
  53401. /**
  53402. * Gets the load type
  53403. */
  53404. loadType: number;
  53405. /**
  53406. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53407. */
  53408. isInvalid: boolean;
  53409. /**
  53410. * Creates a new KhronosTextureContainer
  53411. * @param arrayBuffer contents of the KTX container file
  53412. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53413. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53414. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53415. */
  53416. constructor(
  53417. /** contents of the KTX container file */
  53418. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53419. /**
  53420. * Uploads KTX content to a Babylon Texture.
  53421. * It is assumed that the texture has already been created & is currently bound
  53422. * @hidden
  53423. */
  53424. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53425. private _upload2DCompressedLevels;
  53426. }
  53427. }
  53428. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53429. import { Nullable } from "babylonjs/types";
  53430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53431. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53432. /**
  53433. * Implementation of the KTX Texture Loader.
  53434. * @hidden
  53435. */
  53436. export class _KTXTextureLoader implements IInternalTextureLoader {
  53437. /**
  53438. * Defines wether the loader supports cascade loading the different faces.
  53439. */
  53440. readonly supportCascades: boolean;
  53441. /**
  53442. * This returns if the loader support the current file information.
  53443. * @param extension defines the file extension of the file being loaded
  53444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53445. * @param fallback defines the fallback internal texture if any
  53446. * @param isBase64 defines whether the texture is encoded as a base64
  53447. * @param isBuffer defines whether the texture data are stored as a buffer
  53448. * @returns true if the loader can load the specified file
  53449. */
  53450. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53451. /**
  53452. * Transform the url before loading if required.
  53453. * @param rootUrl the url of the texture
  53454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53455. * @returns the transformed texture
  53456. */
  53457. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53458. /**
  53459. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53460. * @param rootUrl the url of the texture
  53461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53462. * @returns the fallback texture
  53463. */
  53464. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53465. /**
  53466. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53467. * @param data contains the texture data
  53468. * @param texture defines the BabylonJS internal texture
  53469. * @param createPolynomials will be true if polynomials have been requested
  53470. * @param onLoad defines the callback to trigger once the texture is ready
  53471. * @param onError defines the callback to trigger in case of error
  53472. */
  53473. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53474. /**
  53475. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53476. * @param data contains the texture data
  53477. * @param texture defines the BabylonJS internal texture
  53478. * @param callback defines the method to call once ready to upload
  53479. */
  53480. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53481. }
  53482. }
  53483. declare module "babylonjs/Helpers/sceneHelpers" {
  53484. import { Nullable } from "babylonjs/types";
  53485. import { Mesh } from "babylonjs/Meshes/mesh";
  53486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53487. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53488. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53489. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53490. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53491. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53492. import "babylonjs/Meshes/Builders/boxBuilder";
  53493. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53494. /** @hidden */
  53495. export var _forceSceneHelpersToBundle: boolean;
  53496. module "babylonjs/scene" {
  53497. interface Scene {
  53498. /**
  53499. * Creates a default light for the scene.
  53500. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53501. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53502. */
  53503. createDefaultLight(replace?: boolean): void;
  53504. /**
  53505. * Creates a default camera for the scene.
  53506. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53507. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53508. * @param replace has default false, when true replaces the active camera in the scene
  53509. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53510. */
  53511. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53512. /**
  53513. * Creates a default camera and a default light.
  53514. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53515. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53516. * @param replace has the default false, when true replaces the active camera/light in the scene
  53517. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53518. */
  53519. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53520. /**
  53521. * Creates a new sky box
  53522. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53523. * @param environmentTexture defines the texture to use as environment texture
  53524. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53525. * @param scale defines the overall scale of the skybox
  53526. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53527. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53528. * @returns a new mesh holding the sky box
  53529. */
  53530. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53531. /**
  53532. * Creates a new environment
  53533. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53534. * @param options defines the options you can use to configure the environment
  53535. * @returns the new EnvironmentHelper
  53536. */
  53537. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53538. /**
  53539. * Creates a new VREXperienceHelper
  53540. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53541. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53542. * @returns a new VREXperienceHelper
  53543. */
  53544. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53545. /**
  53546. * Creates a new WebXRDefaultExperience
  53547. * @see http://doc.babylonjs.com/how_to/webxr
  53548. * @param options experience options
  53549. * @returns a promise for a new WebXRDefaultExperience
  53550. */
  53551. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53552. }
  53553. }
  53554. }
  53555. declare module "babylonjs/Helpers/videoDome" {
  53556. import { Scene } from "babylonjs/scene";
  53557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53558. import { Mesh } from "babylonjs/Meshes/mesh";
  53559. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53560. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53561. import "babylonjs/Meshes/Builders/sphereBuilder";
  53562. /**
  53563. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53564. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53565. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53566. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53567. */
  53568. export class VideoDome extends TransformNode {
  53569. /**
  53570. * Define the video source as a Monoscopic panoramic 360 video.
  53571. */
  53572. static readonly MODE_MONOSCOPIC: number;
  53573. /**
  53574. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53575. */
  53576. static readonly MODE_TOPBOTTOM: number;
  53577. /**
  53578. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53579. */
  53580. static readonly MODE_SIDEBYSIDE: number;
  53581. private _halfDome;
  53582. private _useDirectMapping;
  53583. /**
  53584. * The video texture being displayed on the sphere
  53585. */
  53586. protected _videoTexture: VideoTexture;
  53587. /**
  53588. * Gets the video texture being displayed on the sphere
  53589. */
  53590. get videoTexture(): VideoTexture;
  53591. /**
  53592. * The skybox material
  53593. */
  53594. protected _material: BackgroundMaterial;
  53595. /**
  53596. * The surface used for the skybox
  53597. */
  53598. protected _mesh: Mesh;
  53599. /**
  53600. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53601. */
  53602. private _halfDomeMask;
  53603. /**
  53604. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53605. * Also see the options.resolution property.
  53606. */
  53607. get fovMultiplier(): number;
  53608. set fovMultiplier(value: number);
  53609. private _videoMode;
  53610. /**
  53611. * Gets or set the current video mode for the video. It can be:
  53612. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53613. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53614. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53615. */
  53616. get videoMode(): number;
  53617. set videoMode(value: number);
  53618. /**
  53619. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53620. *
  53621. */
  53622. get halfDome(): boolean;
  53623. /**
  53624. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53625. */
  53626. set halfDome(enabled: boolean);
  53627. /**
  53628. * Oberserver used in Stereoscopic VR Mode.
  53629. */
  53630. private _onBeforeCameraRenderObserver;
  53631. /**
  53632. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53633. * @param name Element's name, child elements will append suffixes for their own names.
  53634. * @param urlsOrVideo defines the url(s) or the video element to use
  53635. * @param options An object containing optional or exposed sub element properties
  53636. */
  53637. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53638. resolution?: number;
  53639. clickToPlay?: boolean;
  53640. autoPlay?: boolean;
  53641. loop?: boolean;
  53642. size?: number;
  53643. poster?: string;
  53644. faceForward?: boolean;
  53645. useDirectMapping?: boolean;
  53646. halfDomeMode?: boolean;
  53647. }, scene: Scene);
  53648. private _changeVideoMode;
  53649. /**
  53650. * Releases resources associated with this node.
  53651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53653. */
  53654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53655. }
  53656. }
  53657. declare module "babylonjs/Helpers/index" {
  53658. export * from "babylonjs/Helpers/environmentHelper";
  53659. export * from "babylonjs/Helpers/photoDome";
  53660. export * from "babylonjs/Helpers/sceneHelpers";
  53661. export * from "babylonjs/Helpers/videoDome";
  53662. }
  53663. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53664. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53665. import { IDisposable } from "babylonjs/scene";
  53666. import { Engine } from "babylonjs/Engines/engine";
  53667. /**
  53668. * This class can be used to get instrumentation data from a Babylon engine
  53669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53670. */
  53671. export class EngineInstrumentation implements IDisposable {
  53672. /**
  53673. * Define the instrumented engine.
  53674. */
  53675. engine: Engine;
  53676. private _captureGPUFrameTime;
  53677. private _gpuFrameTimeToken;
  53678. private _gpuFrameTime;
  53679. private _captureShaderCompilationTime;
  53680. private _shaderCompilationTime;
  53681. private _onBeginFrameObserver;
  53682. private _onEndFrameObserver;
  53683. private _onBeforeShaderCompilationObserver;
  53684. private _onAfterShaderCompilationObserver;
  53685. /**
  53686. * Gets the perf counter used for GPU frame time
  53687. */
  53688. get gpuFrameTimeCounter(): PerfCounter;
  53689. /**
  53690. * Gets the GPU frame time capture status
  53691. */
  53692. get captureGPUFrameTime(): boolean;
  53693. /**
  53694. * Enable or disable the GPU frame time capture
  53695. */
  53696. set captureGPUFrameTime(value: boolean);
  53697. /**
  53698. * Gets the perf counter used for shader compilation time
  53699. */
  53700. get shaderCompilationTimeCounter(): PerfCounter;
  53701. /**
  53702. * Gets the shader compilation time capture status
  53703. */
  53704. get captureShaderCompilationTime(): boolean;
  53705. /**
  53706. * Enable or disable the shader compilation time capture
  53707. */
  53708. set captureShaderCompilationTime(value: boolean);
  53709. /**
  53710. * Instantiates a new engine instrumentation.
  53711. * This class can be used to get instrumentation data from a Babylon engine
  53712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53713. * @param engine Defines the engine to instrument
  53714. */
  53715. constructor(
  53716. /**
  53717. * Define the instrumented engine.
  53718. */
  53719. engine: Engine);
  53720. /**
  53721. * Dispose and release associated resources.
  53722. */
  53723. dispose(): void;
  53724. }
  53725. }
  53726. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53727. import { Scene, IDisposable } from "babylonjs/scene";
  53728. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53729. /**
  53730. * This class can be used to get instrumentation data from a Babylon engine
  53731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53732. */
  53733. export class SceneInstrumentation implements IDisposable {
  53734. /**
  53735. * Defines the scene to instrument
  53736. */
  53737. scene: Scene;
  53738. private _captureActiveMeshesEvaluationTime;
  53739. private _activeMeshesEvaluationTime;
  53740. private _captureRenderTargetsRenderTime;
  53741. private _renderTargetsRenderTime;
  53742. private _captureFrameTime;
  53743. private _frameTime;
  53744. private _captureRenderTime;
  53745. private _renderTime;
  53746. private _captureInterFrameTime;
  53747. private _interFrameTime;
  53748. private _captureParticlesRenderTime;
  53749. private _particlesRenderTime;
  53750. private _captureSpritesRenderTime;
  53751. private _spritesRenderTime;
  53752. private _capturePhysicsTime;
  53753. private _physicsTime;
  53754. private _captureAnimationsTime;
  53755. private _animationsTime;
  53756. private _captureCameraRenderTime;
  53757. private _cameraRenderTime;
  53758. private _onBeforeActiveMeshesEvaluationObserver;
  53759. private _onAfterActiveMeshesEvaluationObserver;
  53760. private _onBeforeRenderTargetsRenderObserver;
  53761. private _onAfterRenderTargetsRenderObserver;
  53762. private _onAfterRenderObserver;
  53763. private _onBeforeDrawPhaseObserver;
  53764. private _onAfterDrawPhaseObserver;
  53765. private _onBeforeAnimationsObserver;
  53766. private _onBeforeParticlesRenderingObserver;
  53767. private _onAfterParticlesRenderingObserver;
  53768. private _onBeforeSpritesRenderingObserver;
  53769. private _onAfterSpritesRenderingObserver;
  53770. private _onBeforePhysicsObserver;
  53771. private _onAfterPhysicsObserver;
  53772. private _onAfterAnimationsObserver;
  53773. private _onBeforeCameraRenderObserver;
  53774. private _onAfterCameraRenderObserver;
  53775. /**
  53776. * Gets the perf counter used for active meshes evaluation time
  53777. */
  53778. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53779. /**
  53780. * Gets the active meshes evaluation time capture status
  53781. */
  53782. get captureActiveMeshesEvaluationTime(): boolean;
  53783. /**
  53784. * Enable or disable the active meshes evaluation time capture
  53785. */
  53786. set captureActiveMeshesEvaluationTime(value: boolean);
  53787. /**
  53788. * Gets the perf counter used for render targets render time
  53789. */
  53790. get renderTargetsRenderTimeCounter(): PerfCounter;
  53791. /**
  53792. * Gets the render targets render time capture status
  53793. */
  53794. get captureRenderTargetsRenderTime(): boolean;
  53795. /**
  53796. * Enable or disable the render targets render time capture
  53797. */
  53798. set captureRenderTargetsRenderTime(value: boolean);
  53799. /**
  53800. * Gets the perf counter used for particles render time
  53801. */
  53802. get particlesRenderTimeCounter(): PerfCounter;
  53803. /**
  53804. * Gets the particles render time capture status
  53805. */
  53806. get captureParticlesRenderTime(): boolean;
  53807. /**
  53808. * Enable or disable the particles render time capture
  53809. */
  53810. set captureParticlesRenderTime(value: boolean);
  53811. /**
  53812. * Gets the perf counter used for sprites render time
  53813. */
  53814. get spritesRenderTimeCounter(): PerfCounter;
  53815. /**
  53816. * Gets the sprites render time capture status
  53817. */
  53818. get captureSpritesRenderTime(): boolean;
  53819. /**
  53820. * Enable or disable the sprites render time capture
  53821. */
  53822. set captureSpritesRenderTime(value: boolean);
  53823. /**
  53824. * Gets the perf counter used for physics time
  53825. */
  53826. get physicsTimeCounter(): PerfCounter;
  53827. /**
  53828. * Gets the physics time capture status
  53829. */
  53830. get capturePhysicsTime(): boolean;
  53831. /**
  53832. * Enable or disable the physics time capture
  53833. */
  53834. set capturePhysicsTime(value: boolean);
  53835. /**
  53836. * Gets the perf counter used for animations time
  53837. */
  53838. get animationsTimeCounter(): PerfCounter;
  53839. /**
  53840. * Gets the animations time capture status
  53841. */
  53842. get captureAnimationsTime(): boolean;
  53843. /**
  53844. * Enable or disable the animations time capture
  53845. */
  53846. set captureAnimationsTime(value: boolean);
  53847. /**
  53848. * Gets the perf counter used for frame time capture
  53849. */
  53850. get frameTimeCounter(): PerfCounter;
  53851. /**
  53852. * Gets the frame time capture status
  53853. */
  53854. get captureFrameTime(): boolean;
  53855. /**
  53856. * Enable or disable the frame time capture
  53857. */
  53858. set captureFrameTime(value: boolean);
  53859. /**
  53860. * Gets the perf counter used for inter-frames time capture
  53861. */
  53862. get interFrameTimeCounter(): PerfCounter;
  53863. /**
  53864. * Gets the inter-frames time capture status
  53865. */
  53866. get captureInterFrameTime(): boolean;
  53867. /**
  53868. * Enable or disable the inter-frames time capture
  53869. */
  53870. set captureInterFrameTime(value: boolean);
  53871. /**
  53872. * Gets the perf counter used for render time capture
  53873. */
  53874. get renderTimeCounter(): PerfCounter;
  53875. /**
  53876. * Gets the render time capture status
  53877. */
  53878. get captureRenderTime(): boolean;
  53879. /**
  53880. * Enable or disable the render time capture
  53881. */
  53882. set captureRenderTime(value: boolean);
  53883. /**
  53884. * Gets the perf counter used for camera render time capture
  53885. */
  53886. get cameraRenderTimeCounter(): PerfCounter;
  53887. /**
  53888. * Gets the camera render time capture status
  53889. */
  53890. get captureCameraRenderTime(): boolean;
  53891. /**
  53892. * Enable or disable the camera render time capture
  53893. */
  53894. set captureCameraRenderTime(value: boolean);
  53895. /**
  53896. * Gets the perf counter used for draw calls
  53897. */
  53898. get drawCallsCounter(): PerfCounter;
  53899. /**
  53900. * Instantiates a new scene instrumentation.
  53901. * This class can be used to get instrumentation data from a Babylon engine
  53902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53903. * @param scene Defines the scene to instrument
  53904. */
  53905. constructor(
  53906. /**
  53907. * Defines the scene to instrument
  53908. */
  53909. scene: Scene);
  53910. /**
  53911. * Dispose and release associated resources.
  53912. */
  53913. dispose(): void;
  53914. }
  53915. }
  53916. declare module "babylonjs/Instrumentation/index" {
  53917. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53918. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53919. export * from "babylonjs/Instrumentation/timeToken";
  53920. }
  53921. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53922. /** @hidden */
  53923. export var glowMapGenerationPixelShader: {
  53924. name: string;
  53925. shader: string;
  53926. };
  53927. }
  53928. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53929. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53931. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53932. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53933. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53934. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53935. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53936. /** @hidden */
  53937. export var glowMapGenerationVertexShader: {
  53938. name: string;
  53939. shader: string;
  53940. };
  53941. }
  53942. declare module "babylonjs/Layers/effectLayer" {
  53943. import { Observable } from "babylonjs/Misc/observable";
  53944. import { Nullable } from "babylonjs/types";
  53945. import { Camera } from "babylonjs/Cameras/camera";
  53946. import { Scene } from "babylonjs/scene";
  53947. import { ISize } from "babylonjs/Maths/math.size";
  53948. import { Color4 } from "babylonjs/Maths/math.color";
  53949. import { Engine } from "babylonjs/Engines/engine";
  53950. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53952. import { Mesh } from "babylonjs/Meshes/mesh";
  53953. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53956. import { Effect } from "babylonjs/Materials/effect";
  53957. import { Material } from "babylonjs/Materials/material";
  53958. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53959. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53960. /**
  53961. * Effect layer options. This helps customizing the behaviour
  53962. * of the effect layer.
  53963. */
  53964. export interface IEffectLayerOptions {
  53965. /**
  53966. * Multiplication factor apply to the canvas size to compute the render target size
  53967. * used to generated the objects (the smaller the faster).
  53968. */
  53969. mainTextureRatio: number;
  53970. /**
  53971. * Enforces a fixed size texture to ensure effect stability across devices.
  53972. */
  53973. mainTextureFixedSize?: number;
  53974. /**
  53975. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53976. */
  53977. alphaBlendingMode: number;
  53978. /**
  53979. * The camera attached to the layer.
  53980. */
  53981. camera: Nullable<Camera>;
  53982. /**
  53983. * The rendering group to draw the layer in.
  53984. */
  53985. renderingGroupId: number;
  53986. }
  53987. /**
  53988. * The effect layer Helps adding post process effect blended with the main pass.
  53989. *
  53990. * This can be for instance use to generate glow or higlight effects on the scene.
  53991. *
  53992. * The effect layer class can not be used directly and is intented to inherited from to be
  53993. * customized per effects.
  53994. */
  53995. export abstract class EffectLayer {
  53996. private _vertexBuffers;
  53997. private _indexBuffer;
  53998. private _cachedDefines;
  53999. private _effectLayerMapGenerationEffect;
  54000. private _effectLayerOptions;
  54001. private _mergeEffect;
  54002. protected _scene: Scene;
  54003. protected _engine: Engine;
  54004. protected _maxSize: number;
  54005. protected _mainTextureDesiredSize: ISize;
  54006. protected _mainTexture: RenderTargetTexture;
  54007. protected _shouldRender: boolean;
  54008. protected _postProcesses: PostProcess[];
  54009. protected _textures: BaseTexture[];
  54010. protected _emissiveTextureAndColor: {
  54011. texture: Nullable<BaseTexture>;
  54012. color: Color4;
  54013. };
  54014. /**
  54015. * The name of the layer
  54016. */
  54017. name: string;
  54018. /**
  54019. * The clear color of the texture used to generate the glow map.
  54020. */
  54021. neutralColor: Color4;
  54022. /**
  54023. * Specifies wether the highlight layer is enabled or not.
  54024. */
  54025. isEnabled: boolean;
  54026. /**
  54027. * Gets the camera attached to the layer.
  54028. */
  54029. get camera(): Nullable<Camera>;
  54030. /**
  54031. * Gets the rendering group id the layer should render in.
  54032. */
  54033. get renderingGroupId(): number;
  54034. set renderingGroupId(renderingGroupId: number);
  54035. /**
  54036. * An event triggered when the effect layer has been disposed.
  54037. */
  54038. onDisposeObservable: Observable<EffectLayer>;
  54039. /**
  54040. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54041. */
  54042. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54043. /**
  54044. * An event triggered when the generated texture is being merged in the scene.
  54045. */
  54046. onBeforeComposeObservable: Observable<EffectLayer>;
  54047. /**
  54048. * An event triggered when the mesh is rendered into the effect render target.
  54049. */
  54050. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54051. /**
  54052. * An event triggered after the mesh has been rendered into the effect render target.
  54053. */
  54054. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54055. /**
  54056. * An event triggered when the generated texture has been merged in the scene.
  54057. */
  54058. onAfterComposeObservable: Observable<EffectLayer>;
  54059. /**
  54060. * An event triggered when the efffect layer changes its size.
  54061. */
  54062. onSizeChangedObservable: Observable<EffectLayer>;
  54063. /** @hidden */
  54064. static _SceneComponentInitialization: (scene: Scene) => void;
  54065. /**
  54066. * Instantiates a new effect Layer and references it in the scene.
  54067. * @param name The name of the layer
  54068. * @param scene The scene to use the layer in
  54069. */
  54070. constructor(
  54071. /** The Friendly of the effect in the scene */
  54072. name: string, scene: Scene);
  54073. /**
  54074. * Get the effect name of the layer.
  54075. * @return The effect name
  54076. */
  54077. abstract getEffectName(): string;
  54078. /**
  54079. * Checks for the readiness of the element composing the layer.
  54080. * @param subMesh the mesh to check for
  54081. * @param useInstances specify wether or not to use instances to render the mesh
  54082. * @return true if ready otherwise, false
  54083. */
  54084. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54085. /**
  54086. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54087. * @returns true if the effect requires stencil during the main canvas render pass.
  54088. */
  54089. abstract needStencil(): boolean;
  54090. /**
  54091. * Create the merge effect. This is the shader use to blit the information back
  54092. * to the main canvas at the end of the scene rendering.
  54093. * @returns The effect containing the shader used to merge the effect on the main canvas
  54094. */
  54095. protected abstract _createMergeEffect(): Effect;
  54096. /**
  54097. * Creates the render target textures and post processes used in the effect layer.
  54098. */
  54099. protected abstract _createTextureAndPostProcesses(): void;
  54100. /**
  54101. * Implementation specific of rendering the generating effect on the main canvas.
  54102. * @param effect The effect used to render through
  54103. */
  54104. protected abstract _internalRender(effect: Effect): void;
  54105. /**
  54106. * Sets the required values for both the emissive texture and and the main color.
  54107. */
  54108. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54109. /**
  54110. * Free any resources and references associated to a mesh.
  54111. * Internal use
  54112. * @param mesh The mesh to free.
  54113. */
  54114. abstract _disposeMesh(mesh: Mesh): void;
  54115. /**
  54116. * Serializes this layer (Glow or Highlight for example)
  54117. * @returns a serialized layer object
  54118. */
  54119. abstract serialize?(): any;
  54120. /**
  54121. * Initializes the effect layer with the required options.
  54122. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54123. */
  54124. protected _init(options: Partial<IEffectLayerOptions>): void;
  54125. /**
  54126. * Generates the index buffer of the full screen quad blending to the main canvas.
  54127. */
  54128. private _generateIndexBuffer;
  54129. /**
  54130. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54131. */
  54132. private _generateVertexBuffer;
  54133. /**
  54134. * Sets the main texture desired size which is the closest power of two
  54135. * of the engine canvas size.
  54136. */
  54137. private _setMainTextureSize;
  54138. /**
  54139. * Creates the main texture for the effect layer.
  54140. */
  54141. protected _createMainTexture(): void;
  54142. /**
  54143. * Adds specific effects defines.
  54144. * @param defines The defines to add specifics to.
  54145. */
  54146. protected _addCustomEffectDefines(defines: string[]): void;
  54147. /**
  54148. * Checks for the readiness of the element composing the layer.
  54149. * @param subMesh the mesh to check for
  54150. * @param useInstances specify wether or not to use instances to render the mesh
  54151. * @param emissiveTexture the associated emissive texture used to generate the glow
  54152. * @return true if ready otherwise, false
  54153. */
  54154. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54155. /**
  54156. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54157. */
  54158. render(): void;
  54159. /**
  54160. * Determine if a given mesh will be used in the current effect.
  54161. * @param mesh mesh to test
  54162. * @returns true if the mesh will be used
  54163. */
  54164. hasMesh(mesh: AbstractMesh): boolean;
  54165. /**
  54166. * Returns true if the layer contains information to display, otherwise false.
  54167. * @returns true if the glow layer should be rendered
  54168. */
  54169. shouldRender(): boolean;
  54170. /**
  54171. * Returns true if the mesh should render, otherwise false.
  54172. * @param mesh The mesh to render
  54173. * @returns true if it should render otherwise false
  54174. */
  54175. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54176. /**
  54177. * Returns true if the mesh can be rendered, otherwise false.
  54178. * @param mesh The mesh to render
  54179. * @param material The material used on the mesh
  54180. * @returns true if it can be rendered otherwise false
  54181. */
  54182. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54183. /**
  54184. * Returns true if the mesh should render, otherwise false.
  54185. * @param mesh The mesh to render
  54186. * @returns true if it should render otherwise false
  54187. */
  54188. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54189. /**
  54190. * Renders the submesh passed in parameter to the generation map.
  54191. */
  54192. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54193. /**
  54194. * Defines wether the current material of the mesh should be use to render the effect.
  54195. * @param mesh defines the current mesh to render
  54196. */
  54197. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54198. /**
  54199. * Rebuild the required buffers.
  54200. * @hidden Internal use only.
  54201. */
  54202. _rebuild(): void;
  54203. /**
  54204. * Dispose only the render target textures and post process.
  54205. */
  54206. private _disposeTextureAndPostProcesses;
  54207. /**
  54208. * Dispose the highlight layer and free resources.
  54209. */
  54210. dispose(): void;
  54211. /**
  54212. * Gets the class name of the effect layer
  54213. * @returns the string with the class name of the effect layer
  54214. */
  54215. getClassName(): string;
  54216. /**
  54217. * Creates an effect layer from parsed effect layer data
  54218. * @param parsedEffectLayer defines effect layer data
  54219. * @param scene defines the current scene
  54220. * @param rootUrl defines the root URL containing the effect layer information
  54221. * @returns a parsed effect Layer
  54222. */
  54223. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54224. }
  54225. }
  54226. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54227. import { Scene } from "babylonjs/scene";
  54228. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54229. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54230. import { AbstractScene } from "babylonjs/abstractScene";
  54231. module "babylonjs/abstractScene" {
  54232. interface AbstractScene {
  54233. /**
  54234. * The list of effect layers (highlights/glow) added to the scene
  54235. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54236. * @see http://doc.babylonjs.com/how_to/glow_layer
  54237. */
  54238. effectLayers: Array<EffectLayer>;
  54239. /**
  54240. * Removes the given effect layer from this scene.
  54241. * @param toRemove defines the effect layer to remove
  54242. * @returns the index of the removed effect layer
  54243. */
  54244. removeEffectLayer(toRemove: EffectLayer): number;
  54245. /**
  54246. * Adds the given effect layer to this scene
  54247. * @param newEffectLayer defines the effect layer to add
  54248. */
  54249. addEffectLayer(newEffectLayer: EffectLayer): void;
  54250. }
  54251. }
  54252. /**
  54253. * Defines the layer scene component responsible to manage any effect layers
  54254. * in a given scene.
  54255. */
  54256. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54257. /**
  54258. * The component name helpfull to identify the component in the list of scene components.
  54259. */
  54260. readonly name: string;
  54261. /**
  54262. * The scene the component belongs to.
  54263. */
  54264. scene: Scene;
  54265. private _engine;
  54266. private _renderEffects;
  54267. private _needStencil;
  54268. private _previousStencilState;
  54269. /**
  54270. * Creates a new instance of the component for the given scene
  54271. * @param scene Defines the scene to register the component in
  54272. */
  54273. constructor(scene: Scene);
  54274. /**
  54275. * Registers the component in a given scene
  54276. */
  54277. register(): void;
  54278. /**
  54279. * Rebuilds the elements related to this component in case of
  54280. * context lost for instance.
  54281. */
  54282. rebuild(): void;
  54283. /**
  54284. * Serializes the component data to the specified json object
  54285. * @param serializationObject The object to serialize to
  54286. */
  54287. serialize(serializationObject: any): void;
  54288. /**
  54289. * Adds all the elements from the container to the scene
  54290. * @param container the container holding the elements
  54291. */
  54292. addFromContainer(container: AbstractScene): void;
  54293. /**
  54294. * Removes all the elements in the container from the scene
  54295. * @param container contains the elements to remove
  54296. * @param dispose if the removed element should be disposed (default: false)
  54297. */
  54298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54299. /**
  54300. * Disposes the component and the associated ressources.
  54301. */
  54302. dispose(): void;
  54303. private _isReadyForMesh;
  54304. private _renderMainTexture;
  54305. private _setStencil;
  54306. private _setStencilBack;
  54307. private _draw;
  54308. private _drawCamera;
  54309. private _drawRenderingGroup;
  54310. }
  54311. }
  54312. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54313. /** @hidden */
  54314. export var glowMapMergePixelShader: {
  54315. name: string;
  54316. shader: string;
  54317. };
  54318. }
  54319. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54320. /** @hidden */
  54321. export var glowMapMergeVertexShader: {
  54322. name: string;
  54323. shader: string;
  54324. };
  54325. }
  54326. declare module "babylonjs/Layers/glowLayer" {
  54327. import { Nullable } from "babylonjs/types";
  54328. import { Camera } from "babylonjs/Cameras/camera";
  54329. import { Scene } from "babylonjs/scene";
  54330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54332. import { Mesh } from "babylonjs/Meshes/mesh";
  54333. import { Texture } from "babylonjs/Materials/Textures/texture";
  54334. import { Effect } from "babylonjs/Materials/effect";
  54335. import { Material } from "babylonjs/Materials/material";
  54336. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54337. import { Color4 } from "babylonjs/Maths/math.color";
  54338. import "babylonjs/Shaders/glowMapMerge.fragment";
  54339. import "babylonjs/Shaders/glowMapMerge.vertex";
  54340. import "babylonjs/Layers/effectLayerSceneComponent";
  54341. module "babylonjs/abstractScene" {
  54342. interface AbstractScene {
  54343. /**
  54344. * Return a the first highlight layer of the scene with a given name.
  54345. * @param name The name of the highlight layer to look for.
  54346. * @return The highlight layer if found otherwise null.
  54347. */
  54348. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54349. }
  54350. }
  54351. /**
  54352. * Glow layer options. This helps customizing the behaviour
  54353. * of the glow layer.
  54354. */
  54355. export interface IGlowLayerOptions {
  54356. /**
  54357. * Multiplication factor apply to the canvas size to compute the render target size
  54358. * used to generated the glowing objects (the smaller the faster).
  54359. */
  54360. mainTextureRatio: number;
  54361. /**
  54362. * Enforces a fixed size texture to ensure resize independant blur.
  54363. */
  54364. mainTextureFixedSize?: number;
  54365. /**
  54366. * How big is the kernel of the blur texture.
  54367. */
  54368. blurKernelSize: number;
  54369. /**
  54370. * The camera attached to the layer.
  54371. */
  54372. camera: Nullable<Camera>;
  54373. /**
  54374. * Enable MSAA by chosing the number of samples.
  54375. */
  54376. mainTextureSamples?: number;
  54377. /**
  54378. * The rendering group to draw the layer in.
  54379. */
  54380. renderingGroupId: number;
  54381. }
  54382. /**
  54383. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54384. *
  54385. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54386. *
  54387. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54388. */
  54389. export class GlowLayer extends EffectLayer {
  54390. /**
  54391. * Effect Name of the layer.
  54392. */
  54393. static readonly EffectName: string;
  54394. /**
  54395. * The default blur kernel size used for the glow.
  54396. */
  54397. static DefaultBlurKernelSize: number;
  54398. /**
  54399. * The default texture size ratio used for the glow.
  54400. */
  54401. static DefaultTextureRatio: number;
  54402. /**
  54403. * Sets the kernel size of the blur.
  54404. */
  54405. set blurKernelSize(value: number);
  54406. /**
  54407. * Gets the kernel size of the blur.
  54408. */
  54409. get blurKernelSize(): number;
  54410. /**
  54411. * Sets the glow intensity.
  54412. */
  54413. set intensity(value: number);
  54414. /**
  54415. * Gets the glow intensity.
  54416. */
  54417. get intensity(): number;
  54418. private _options;
  54419. private _intensity;
  54420. private _horizontalBlurPostprocess1;
  54421. private _verticalBlurPostprocess1;
  54422. private _horizontalBlurPostprocess2;
  54423. private _verticalBlurPostprocess2;
  54424. private _blurTexture1;
  54425. private _blurTexture2;
  54426. private _postProcesses1;
  54427. private _postProcesses2;
  54428. private _includedOnlyMeshes;
  54429. private _excludedMeshes;
  54430. private _meshesUsingTheirOwnMaterials;
  54431. /**
  54432. * Callback used to let the user override the color selection on a per mesh basis
  54433. */
  54434. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54435. /**
  54436. * Callback used to let the user override the texture selection on a per mesh basis
  54437. */
  54438. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54439. /**
  54440. * Instantiates a new glow Layer and references it to the scene.
  54441. * @param name The name of the layer
  54442. * @param scene The scene to use the layer in
  54443. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54444. */
  54445. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54446. /**
  54447. * Get the effect name of the layer.
  54448. * @return The effect name
  54449. */
  54450. getEffectName(): string;
  54451. /**
  54452. * Create the merge effect. This is the shader use to blit the information back
  54453. * to the main canvas at the end of the scene rendering.
  54454. */
  54455. protected _createMergeEffect(): Effect;
  54456. /**
  54457. * Creates the render target textures and post processes used in the glow layer.
  54458. */
  54459. protected _createTextureAndPostProcesses(): void;
  54460. /**
  54461. * Checks for the readiness of the element composing the layer.
  54462. * @param subMesh the mesh to check for
  54463. * @param useInstances specify wether or not to use instances to render the mesh
  54464. * @param emissiveTexture the associated emissive texture used to generate the glow
  54465. * @return true if ready otherwise, false
  54466. */
  54467. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54468. /**
  54469. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54470. */
  54471. needStencil(): boolean;
  54472. /**
  54473. * Returns true if the mesh can be rendered, otherwise false.
  54474. * @param mesh The mesh to render
  54475. * @param material The material used on the mesh
  54476. * @returns true if it can be rendered otherwise false
  54477. */
  54478. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54479. /**
  54480. * Implementation specific of rendering the generating effect on the main canvas.
  54481. * @param effect The effect used to render through
  54482. */
  54483. protected _internalRender(effect: Effect): void;
  54484. /**
  54485. * Sets the required values for both the emissive texture and and the main color.
  54486. */
  54487. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54488. /**
  54489. * Returns true if the mesh should render, otherwise false.
  54490. * @param mesh The mesh to render
  54491. * @returns true if it should render otherwise false
  54492. */
  54493. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54494. /**
  54495. * Adds specific effects defines.
  54496. * @param defines The defines to add specifics to.
  54497. */
  54498. protected _addCustomEffectDefines(defines: string[]): void;
  54499. /**
  54500. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54501. * @param mesh The mesh to exclude from the glow layer
  54502. */
  54503. addExcludedMesh(mesh: Mesh): void;
  54504. /**
  54505. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54506. * @param mesh The mesh to remove
  54507. */
  54508. removeExcludedMesh(mesh: Mesh): void;
  54509. /**
  54510. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54511. * @param mesh The mesh to include in the glow layer
  54512. */
  54513. addIncludedOnlyMesh(mesh: Mesh): void;
  54514. /**
  54515. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54516. * @param mesh The mesh to remove
  54517. */
  54518. removeIncludedOnlyMesh(mesh: Mesh): void;
  54519. /**
  54520. * Determine if a given mesh will be used in the glow layer
  54521. * @param mesh The mesh to test
  54522. * @returns true if the mesh will be highlighted by the current glow layer
  54523. */
  54524. hasMesh(mesh: AbstractMesh): boolean;
  54525. /**
  54526. * Defines wether the current material of the mesh should be use to render the effect.
  54527. * @param mesh defines the current mesh to render
  54528. */
  54529. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54530. /**
  54531. * Add a mesh to be rendered through its own material and not with emissive only.
  54532. * @param mesh The mesh for which we need to use its material
  54533. */
  54534. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54535. /**
  54536. * Remove a mesh from being rendered through its own material and not with emissive only.
  54537. * @param mesh The mesh for which we need to not use its material
  54538. */
  54539. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54540. /**
  54541. * Free any resources and references associated to a mesh.
  54542. * Internal use
  54543. * @param mesh The mesh to free.
  54544. * @hidden
  54545. */
  54546. _disposeMesh(mesh: Mesh): void;
  54547. /**
  54548. * Gets the class name of the effect layer
  54549. * @returns the string with the class name of the effect layer
  54550. */
  54551. getClassName(): string;
  54552. /**
  54553. * Serializes this glow layer
  54554. * @returns a serialized glow layer object
  54555. */
  54556. serialize(): any;
  54557. /**
  54558. * Creates a Glow Layer from parsed glow layer data
  54559. * @param parsedGlowLayer defines glow layer data
  54560. * @param scene defines the current scene
  54561. * @param rootUrl defines the root URL containing the glow layer information
  54562. * @returns a parsed Glow Layer
  54563. */
  54564. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54565. }
  54566. }
  54567. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54568. /** @hidden */
  54569. export var glowBlurPostProcessPixelShader: {
  54570. name: string;
  54571. shader: string;
  54572. };
  54573. }
  54574. declare module "babylonjs/Layers/highlightLayer" {
  54575. import { Observable } from "babylonjs/Misc/observable";
  54576. import { Nullable } from "babylonjs/types";
  54577. import { Camera } from "babylonjs/Cameras/camera";
  54578. import { Scene } from "babylonjs/scene";
  54579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54581. import { Mesh } from "babylonjs/Meshes/mesh";
  54582. import { Effect } from "babylonjs/Materials/effect";
  54583. import { Material } from "babylonjs/Materials/material";
  54584. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54585. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54586. import "babylonjs/Shaders/glowMapMerge.fragment";
  54587. import "babylonjs/Shaders/glowMapMerge.vertex";
  54588. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54589. module "babylonjs/abstractScene" {
  54590. interface AbstractScene {
  54591. /**
  54592. * Return a the first highlight layer of the scene with a given name.
  54593. * @param name The name of the highlight layer to look for.
  54594. * @return The highlight layer if found otherwise null.
  54595. */
  54596. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54597. }
  54598. }
  54599. /**
  54600. * Highlight layer options. This helps customizing the behaviour
  54601. * of the highlight layer.
  54602. */
  54603. export interface IHighlightLayerOptions {
  54604. /**
  54605. * Multiplication factor apply to the canvas size to compute the render target size
  54606. * used to generated the glowing objects (the smaller the faster).
  54607. */
  54608. mainTextureRatio: number;
  54609. /**
  54610. * Enforces a fixed size texture to ensure resize independant blur.
  54611. */
  54612. mainTextureFixedSize?: number;
  54613. /**
  54614. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54615. * of the picture to blur (the smaller the faster).
  54616. */
  54617. blurTextureSizeRatio: number;
  54618. /**
  54619. * How big in texel of the blur texture is the vertical blur.
  54620. */
  54621. blurVerticalSize: number;
  54622. /**
  54623. * How big in texel of the blur texture is the horizontal blur.
  54624. */
  54625. blurHorizontalSize: number;
  54626. /**
  54627. * Alpha blending mode used to apply the blur. Default is combine.
  54628. */
  54629. alphaBlendingMode: number;
  54630. /**
  54631. * The camera attached to the layer.
  54632. */
  54633. camera: Nullable<Camera>;
  54634. /**
  54635. * Should we display highlight as a solid stroke?
  54636. */
  54637. isStroke?: boolean;
  54638. /**
  54639. * The rendering group to draw the layer in.
  54640. */
  54641. renderingGroupId: number;
  54642. }
  54643. /**
  54644. * The highlight layer Helps adding a glow effect around a mesh.
  54645. *
  54646. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54647. * glowy meshes to your scene.
  54648. *
  54649. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54650. */
  54651. export class HighlightLayer extends EffectLayer {
  54652. name: string;
  54653. /**
  54654. * Effect Name of the highlight layer.
  54655. */
  54656. static readonly EffectName: string;
  54657. /**
  54658. * The neutral color used during the preparation of the glow effect.
  54659. * This is black by default as the blend operation is a blend operation.
  54660. */
  54661. static NeutralColor: Color4;
  54662. /**
  54663. * Stencil value used for glowing meshes.
  54664. */
  54665. static GlowingMeshStencilReference: number;
  54666. /**
  54667. * Stencil value used for the other meshes in the scene.
  54668. */
  54669. static NormalMeshStencilReference: number;
  54670. /**
  54671. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54672. */
  54673. innerGlow: boolean;
  54674. /**
  54675. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54676. */
  54677. outerGlow: boolean;
  54678. /**
  54679. * Specifies the horizontal size of the blur.
  54680. */
  54681. set blurHorizontalSize(value: number);
  54682. /**
  54683. * Specifies the vertical size of the blur.
  54684. */
  54685. set blurVerticalSize(value: number);
  54686. /**
  54687. * Gets the horizontal size of the blur.
  54688. */
  54689. get blurHorizontalSize(): number;
  54690. /**
  54691. * Gets the vertical size of the blur.
  54692. */
  54693. get blurVerticalSize(): number;
  54694. /**
  54695. * An event triggered when the highlight layer is being blurred.
  54696. */
  54697. onBeforeBlurObservable: Observable<HighlightLayer>;
  54698. /**
  54699. * An event triggered when the highlight layer has been blurred.
  54700. */
  54701. onAfterBlurObservable: Observable<HighlightLayer>;
  54702. private _instanceGlowingMeshStencilReference;
  54703. private _options;
  54704. private _downSamplePostprocess;
  54705. private _horizontalBlurPostprocess;
  54706. private _verticalBlurPostprocess;
  54707. private _blurTexture;
  54708. private _meshes;
  54709. private _excludedMeshes;
  54710. /**
  54711. * Instantiates a new highlight Layer and references it to the scene..
  54712. * @param name The name of the layer
  54713. * @param scene The scene to use the layer in
  54714. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54715. */
  54716. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54717. /**
  54718. * Get the effect name of the layer.
  54719. * @return The effect name
  54720. */
  54721. getEffectName(): string;
  54722. /**
  54723. * Create the merge effect. This is the shader use to blit the information back
  54724. * to the main canvas at the end of the scene rendering.
  54725. */
  54726. protected _createMergeEffect(): Effect;
  54727. /**
  54728. * Creates the render target textures and post processes used in the highlight layer.
  54729. */
  54730. protected _createTextureAndPostProcesses(): void;
  54731. /**
  54732. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54733. */
  54734. needStencil(): boolean;
  54735. /**
  54736. * Checks for the readiness of the element composing the layer.
  54737. * @param subMesh the mesh to check for
  54738. * @param useInstances specify wether or not to use instances to render the mesh
  54739. * @param emissiveTexture the associated emissive texture used to generate the glow
  54740. * @return true if ready otherwise, false
  54741. */
  54742. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54743. /**
  54744. * Implementation specific of rendering the generating effect on the main canvas.
  54745. * @param effect The effect used to render through
  54746. */
  54747. protected _internalRender(effect: Effect): void;
  54748. /**
  54749. * Returns true if the layer contains information to display, otherwise false.
  54750. */
  54751. shouldRender(): boolean;
  54752. /**
  54753. * Returns true if the mesh should render, otherwise false.
  54754. * @param mesh The mesh to render
  54755. * @returns true if it should render otherwise false
  54756. */
  54757. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54758. /**
  54759. * Sets the required values for both the emissive texture and and the main color.
  54760. */
  54761. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54762. /**
  54763. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54764. * @param mesh The mesh to exclude from the highlight layer
  54765. */
  54766. addExcludedMesh(mesh: Mesh): void;
  54767. /**
  54768. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54769. * @param mesh The mesh to highlight
  54770. */
  54771. removeExcludedMesh(mesh: Mesh): void;
  54772. /**
  54773. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54774. * @param mesh mesh to test
  54775. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54776. */
  54777. hasMesh(mesh: AbstractMesh): boolean;
  54778. /**
  54779. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54780. * @param mesh The mesh to highlight
  54781. * @param color The color of the highlight
  54782. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54783. */
  54784. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54785. /**
  54786. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54787. * @param mesh The mesh to highlight
  54788. */
  54789. removeMesh(mesh: Mesh): void;
  54790. /**
  54791. * Force the stencil to the normal expected value for none glowing parts
  54792. */
  54793. private _defaultStencilReference;
  54794. /**
  54795. * Free any resources and references associated to a mesh.
  54796. * Internal use
  54797. * @param mesh The mesh to free.
  54798. * @hidden
  54799. */
  54800. _disposeMesh(mesh: Mesh): void;
  54801. /**
  54802. * Dispose the highlight layer and free resources.
  54803. */
  54804. dispose(): void;
  54805. /**
  54806. * Gets the class name of the effect layer
  54807. * @returns the string with the class name of the effect layer
  54808. */
  54809. getClassName(): string;
  54810. /**
  54811. * Serializes this Highlight layer
  54812. * @returns a serialized Highlight layer object
  54813. */
  54814. serialize(): any;
  54815. /**
  54816. * Creates a Highlight layer from parsed Highlight layer data
  54817. * @param parsedHightlightLayer defines the Highlight layer data
  54818. * @param scene defines the current scene
  54819. * @param rootUrl defines the root URL containing the Highlight layer information
  54820. * @returns a parsed Highlight layer
  54821. */
  54822. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54823. }
  54824. }
  54825. declare module "babylonjs/Layers/layerSceneComponent" {
  54826. import { Scene } from "babylonjs/scene";
  54827. import { ISceneComponent } from "babylonjs/sceneComponent";
  54828. import { Layer } from "babylonjs/Layers/layer";
  54829. import { AbstractScene } from "babylonjs/abstractScene";
  54830. module "babylonjs/abstractScene" {
  54831. interface AbstractScene {
  54832. /**
  54833. * The list of layers (background and foreground) of the scene
  54834. */
  54835. layers: Array<Layer>;
  54836. }
  54837. }
  54838. /**
  54839. * Defines the layer scene component responsible to manage any layers
  54840. * in a given scene.
  54841. */
  54842. export class LayerSceneComponent implements ISceneComponent {
  54843. /**
  54844. * The component name helpfull to identify the component in the list of scene components.
  54845. */
  54846. readonly name: string;
  54847. /**
  54848. * The scene the component belongs to.
  54849. */
  54850. scene: Scene;
  54851. private _engine;
  54852. /**
  54853. * Creates a new instance of the component for the given scene
  54854. * @param scene Defines the scene to register the component in
  54855. */
  54856. constructor(scene: Scene);
  54857. /**
  54858. * Registers the component in a given scene
  54859. */
  54860. register(): void;
  54861. /**
  54862. * Rebuilds the elements related to this component in case of
  54863. * context lost for instance.
  54864. */
  54865. rebuild(): void;
  54866. /**
  54867. * Disposes the component and the associated ressources.
  54868. */
  54869. dispose(): void;
  54870. private _draw;
  54871. private _drawCameraPredicate;
  54872. private _drawCameraBackground;
  54873. private _drawCameraForeground;
  54874. private _drawRenderTargetPredicate;
  54875. private _drawRenderTargetBackground;
  54876. private _drawRenderTargetForeground;
  54877. /**
  54878. * Adds all the elements from the container to the scene
  54879. * @param container the container holding the elements
  54880. */
  54881. addFromContainer(container: AbstractScene): void;
  54882. /**
  54883. * Removes all the elements in the container from the scene
  54884. * @param container contains the elements to remove
  54885. * @param dispose if the removed element should be disposed (default: false)
  54886. */
  54887. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54888. }
  54889. }
  54890. declare module "babylonjs/Shaders/layer.fragment" {
  54891. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54892. /** @hidden */
  54893. export var layerPixelShader: {
  54894. name: string;
  54895. shader: string;
  54896. };
  54897. }
  54898. declare module "babylonjs/Shaders/layer.vertex" {
  54899. /** @hidden */
  54900. export var layerVertexShader: {
  54901. name: string;
  54902. shader: string;
  54903. };
  54904. }
  54905. declare module "babylonjs/Layers/layer" {
  54906. import { Observable } from "babylonjs/Misc/observable";
  54907. import { Nullable } from "babylonjs/types";
  54908. import { Scene } from "babylonjs/scene";
  54909. import { Vector2 } from "babylonjs/Maths/math.vector";
  54910. import { Color4 } from "babylonjs/Maths/math.color";
  54911. import { Texture } from "babylonjs/Materials/Textures/texture";
  54912. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54913. import "babylonjs/Shaders/layer.fragment";
  54914. import "babylonjs/Shaders/layer.vertex";
  54915. /**
  54916. * This represents a full screen 2d layer.
  54917. * This can be useful to display a picture in the background of your scene for instance.
  54918. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54919. */
  54920. export class Layer {
  54921. /**
  54922. * Define the name of the layer.
  54923. */
  54924. name: string;
  54925. /**
  54926. * Define the texture the layer should display.
  54927. */
  54928. texture: Nullable<Texture>;
  54929. /**
  54930. * Is the layer in background or foreground.
  54931. */
  54932. isBackground: boolean;
  54933. /**
  54934. * Define the color of the layer (instead of texture).
  54935. */
  54936. color: Color4;
  54937. /**
  54938. * Define the scale of the layer in order to zoom in out of the texture.
  54939. */
  54940. scale: Vector2;
  54941. /**
  54942. * Define an offset for the layer in order to shift the texture.
  54943. */
  54944. offset: Vector2;
  54945. /**
  54946. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54947. */
  54948. alphaBlendingMode: number;
  54949. /**
  54950. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54951. * Alpha test will not mix with the background color in case of transparency.
  54952. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54953. */
  54954. alphaTest: boolean;
  54955. /**
  54956. * Define a mask to restrict the layer to only some of the scene cameras.
  54957. */
  54958. layerMask: number;
  54959. /**
  54960. * Define the list of render target the layer is visible into.
  54961. */
  54962. renderTargetTextures: RenderTargetTexture[];
  54963. /**
  54964. * Define if the layer is only used in renderTarget or if it also
  54965. * renders in the main frame buffer of the canvas.
  54966. */
  54967. renderOnlyInRenderTargetTextures: boolean;
  54968. private _scene;
  54969. private _vertexBuffers;
  54970. private _indexBuffer;
  54971. private _effect;
  54972. private _previousDefines;
  54973. /**
  54974. * An event triggered when the layer is disposed.
  54975. */
  54976. onDisposeObservable: Observable<Layer>;
  54977. private _onDisposeObserver;
  54978. /**
  54979. * Back compatibility with callback before the onDisposeObservable existed.
  54980. * The set callback will be triggered when the layer has been disposed.
  54981. */
  54982. set onDispose(callback: () => void);
  54983. /**
  54984. * An event triggered before rendering the scene
  54985. */
  54986. onBeforeRenderObservable: Observable<Layer>;
  54987. private _onBeforeRenderObserver;
  54988. /**
  54989. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54990. * The set callback will be triggered just before rendering the layer.
  54991. */
  54992. set onBeforeRender(callback: () => void);
  54993. /**
  54994. * An event triggered after rendering the scene
  54995. */
  54996. onAfterRenderObservable: Observable<Layer>;
  54997. private _onAfterRenderObserver;
  54998. /**
  54999. * Back compatibility with callback before the onAfterRenderObservable existed.
  55000. * The set callback will be triggered just after rendering the layer.
  55001. */
  55002. set onAfterRender(callback: () => void);
  55003. /**
  55004. * Instantiates a new layer.
  55005. * This represents a full screen 2d layer.
  55006. * This can be useful to display a picture in the background of your scene for instance.
  55007. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55008. * @param name Define the name of the layer in the scene
  55009. * @param imgUrl Define the url of the texture to display in the layer
  55010. * @param scene Define the scene the layer belongs to
  55011. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55012. * @param color Defines a color for the layer
  55013. */
  55014. constructor(
  55015. /**
  55016. * Define the name of the layer.
  55017. */
  55018. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55019. private _createIndexBuffer;
  55020. /** @hidden */
  55021. _rebuild(): void;
  55022. /**
  55023. * Renders the layer in the scene.
  55024. */
  55025. render(): void;
  55026. /**
  55027. * Disposes and releases the associated ressources.
  55028. */
  55029. dispose(): void;
  55030. }
  55031. }
  55032. declare module "babylonjs/Layers/index" {
  55033. export * from "babylonjs/Layers/effectLayer";
  55034. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55035. export * from "babylonjs/Layers/glowLayer";
  55036. export * from "babylonjs/Layers/highlightLayer";
  55037. export * from "babylonjs/Layers/layer";
  55038. export * from "babylonjs/Layers/layerSceneComponent";
  55039. }
  55040. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55041. /** @hidden */
  55042. export var lensFlarePixelShader: {
  55043. name: string;
  55044. shader: string;
  55045. };
  55046. }
  55047. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55048. /** @hidden */
  55049. export var lensFlareVertexShader: {
  55050. name: string;
  55051. shader: string;
  55052. };
  55053. }
  55054. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55055. import { Scene } from "babylonjs/scene";
  55056. import { Vector3 } from "babylonjs/Maths/math.vector";
  55057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55058. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55059. import "babylonjs/Shaders/lensFlare.fragment";
  55060. import "babylonjs/Shaders/lensFlare.vertex";
  55061. import { Viewport } from "babylonjs/Maths/math.viewport";
  55062. /**
  55063. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55064. * It is usually composed of several `lensFlare`.
  55065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55066. */
  55067. export class LensFlareSystem {
  55068. /**
  55069. * Define the name of the lens flare system
  55070. */
  55071. name: string;
  55072. /**
  55073. * List of lens flares used in this system.
  55074. */
  55075. lensFlares: LensFlare[];
  55076. /**
  55077. * Define a limit from the border the lens flare can be visible.
  55078. */
  55079. borderLimit: number;
  55080. /**
  55081. * Define a viewport border we do not want to see the lens flare in.
  55082. */
  55083. viewportBorder: number;
  55084. /**
  55085. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55086. */
  55087. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55088. /**
  55089. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55090. */
  55091. layerMask: number;
  55092. /**
  55093. * Define the id of the lens flare system in the scene.
  55094. * (equal to name by default)
  55095. */
  55096. id: string;
  55097. private _scene;
  55098. private _emitter;
  55099. private _vertexBuffers;
  55100. private _indexBuffer;
  55101. private _effect;
  55102. private _positionX;
  55103. private _positionY;
  55104. private _isEnabled;
  55105. /** @hidden */
  55106. static _SceneComponentInitialization: (scene: Scene) => void;
  55107. /**
  55108. * Instantiates a lens flare system.
  55109. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55110. * It is usually composed of several `lensFlare`.
  55111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55112. * @param name Define the name of the lens flare system in the scene
  55113. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55114. * @param scene Define the scene the lens flare system belongs to
  55115. */
  55116. constructor(
  55117. /**
  55118. * Define the name of the lens flare system
  55119. */
  55120. name: string, emitter: any, scene: Scene);
  55121. /**
  55122. * Define if the lens flare system is enabled.
  55123. */
  55124. get isEnabled(): boolean;
  55125. set isEnabled(value: boolean);
  55126. /**
  55127. * Get the scene the effects belongs to.
  55128. * @returns the scene holding the lens flare system
  55129. */
  55130. getScene(): Scene;
  55131. /**
  55132. * Get the emitter of the lens flare system.
  55133. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55134. * @returns the emitter of the lens flare system
  55135. */
  55136. getEmitter(): any;
  55137. /**
  55138. * Set the emitter of the lens flare system.
  55139. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55140. * @param newEmitter Define the new emitter of the system
  55141. */
  55142. setEmitter(newEmitter: any): void;
  55143. /**
  55144. * Get the lens flare system emitter position.
  55145. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55146. * @returns the position
  55147. */
  55148. getEmitterPosition(): Vector3;
  55149. /**
  55150. * @hidden
  55151. */
  55152. computeEffectivePosition(globalViewport: Viewport): boolean;
  55153. /** @hidden */
  55154. _isVisible(): boolean;
  55155. /**
  55156. * @hidden
  55157. */
  55158. render(): boolean;
  55159. /**
  55160. * Dispose and release the lens flare with its associated resources.
  55161. */
  55162. dispose(): void;
  55163. /**
  55164. * Parse a lens flare system from a JSON repressentation
  55165. * @param parsedLensFlareSystem Define the JSON to parse
  55166. * @param scene Define the scene the parsed system should be instantiated in
  55167. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55168. * @returns the parsed system
  55169. */
  55170. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55171. /**
  55172. * Serialize the current Lens Flare System into a JSON representation.
  55173. * @returns the serialized JSON
  55174. */
  55175. serialize(): any;
  55176. }
  55177. }
  55178. declare module "babylonjs/LensFlares/lensFlare" {
  55179. import { Nullable } from "babylonjs/types";
  55180. import { Color3 } from "babylonjs/Maths/math.color";
  55181. import { Texture } from "babylonjs/Materials/Textures/texture";
  55182. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55183. /**
  55184. * This represents one of the lens effect in a `lensFlareSystem`.
  55185. * It controls one of the indiviual texture used in the effect.
  55186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55187. */
  55188. export class LensFlare {
  55189. /**
  55190. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55191. */
  55192. size: number;
  55193. /**
  55194. * 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.
  55195. */
  55196. position: number;
  55197. /**
  55198. * Define the lens color.
  55199. */
  55200. color: Color3;
  55201. /**
  55202. * Define the lens texture.
  55203. */
  55204. texture: Nullable<Texture>;
  55205. /**
  55206. * Define the alpha mode to render this particular lens.
  55207. */
  55208. alphaMode: number;
  55209. private _system;
  55210. /**
  55211. * Creates a new Lens Flare.
  55212. * This represents one of the lens effect in a `lensFlareSystem`.
  55213. * It controls one of the indiviual texture used in the effect.
  55214. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55215. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55216. * @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.
  55217. * @param color Define the lens color
  55218. * @param imgUrl Define the lens texture url
  55219. * @param system Define the `lensFlareSystem` this flare is part of
  55220. * @returns The newly created Lens Flare
  55221. */
  55222. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55223. /**
  55224. * Instantiates a new Lens Flare.
  55225. * This represents one of the lens effect in a `lensFlareSystem`.
  55226. * It controls one of the indiviual texture used in the effect.
  55227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55228. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55229. * @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.
  55230. * @param color Define the lens color
  55231. * @param imgUrl Define the lens texture url
  55232. * @param system Define the `lensFlareSystem` this flare is part of
  55233. */
  55234. constructor(
  55235. /**
  55236. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55237. */
  55238. size: number,
  55239. /**
  55240. * 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.
  55241. */
  55242. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55243. /**
  55244. * Dispose and release the lens flare with its associated resources.
  55245. */
  55246. dispose(): void;
  55247. }
  55248. }
  55249. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55250. import { Nullable } from "babylonjs/types";
  55251. import { Scene } from "babylonjs/scene";
  55252. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55253. import { AbstractScene } from "babylonjs/abstractScene";
  55254. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55255. module "babylonjs/abstractScene" {
  55256. interface AbstractScene {
  55257. /**
  55258. * The list of lens flare system added to the scene
  55259. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55260. */
  55261. lensFlareSystems: Array<LensFlareSystem>;
  55262. /**
  55263. * Removes the given lens flare system from this scene.
  55264. * @param toRemove The lens flare system to remove
  55265. * @returns The index of the removed lens flare system
  55266. */
  55267. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55268. /**
  55269. * Adds the given lens flare system to this scene
  55270. * @param newLensFlareSystem The lens flare system to add
  55271. */
  55272. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55273. /**
  55274. * Gets a lens flare system using its name
  55275. * @param name defines the name to look for
  55276. * @returns the lens flare system or null if not found
  55277. */
  55278. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55279. /**
  55280. * Gets a lens flare system using its id
  55281. * @param id defines the id to look for
  55282. * @returns the lens flare system or null if not found
  55283. */
  55284. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55285. }
  55286. }
  55287. /**
  55288. * Defines the lens flare scene component responsible to manage any lens flares
  55289. * in a given scene.
  55290. */
  55291. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55292. /**
  55293. * The component name helpfull to identify the component in the list of scene components.
  55294. */
  55295. readonly name: string;
  55296. /**
  55297. * The scene the component belongs to.
  55298. */
  55299. scene: Scene;
  55300. /**
  55301. * Creates a new instance of the component for the given scene
  55302. * @param scene Defines the scene to register the component in
  55303. */
  55304. constructor(scene: Scene);
  55305. /**
  55306. * Registers the component in a given scene
  55307. */
  55308. register(): void;
  55309. /**
  55310. * Rebuilds the elements related to this component in case of
  55311. * context lost for instance.
  55312. */
  55313. rebuild(): void;
  55314. /**
  55315. * Adds all the elements from the container to the scene
  55316. * @param container the container holding the elements
  55317. */
  55318. addFromContainer(container: AbstractScene): void;
  55319. /**
  55320. * Removes all the elements in the container from the scene
  55321. * @param container contains the elements to remove
  55322. * @param dispose if the removed element should be disposed (default: false)
  55323. */
  55324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55325. /**
  55326. * Serializes the component data to the specified json object
  55327. * @param serializationObject The object to serialize to
  55328. */
  55329. serialize(serializationObject: any): void;
  55330. /**
  55331. * Disposes the component and the associated ressources.
  55332. */
  55333. dispose(): void;
  55334. private _draw;
  55335. }
  55336. }
  55337. declare module "babylonjs/LensFlares/index" {
  55338. export * from "babylonjs/LensFlares/lensFlare";
  55339. export * from "babylonjs/LensFlares/lensFlareSystem";
  55340. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55341. }
  55342. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55343. import { Scene } from "babylonjs/scene";
  55344. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55345. import { AbstractScene } from "babylonjs/abstractScene";
  55346. /**
  55347. * Defines the shadow generator component responsible to manage any shadow generators
  55348. * in a given scene.
  55349. */
  55350. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55351. /**
  55352. * The component name helpfull to identify the component in the list of scene components.
  55353. */
  55354. readonly name: string;
  55355. /**
  55356. * The scene the component belongs to.
  55357. */
  55358. scene: Scene;
  55359. /**
  55360. * Creates a new instance of the component for the given scene
  55361. * @param scene Defines the scene to register the component in
  55362. */
  55363. constructor(scene: Scene);
  55364. /**
  55365. * Registers the component in a given scene
  55366. */
  55367. register(): void;
  55368. /**
  55369. * Rebuilds the elements related to this component in case of
  55370. * context lost for instance.
  55371. */
  55372. rebuild(): void;
  55373. /**
  55374. * Serializes the component data to the specified json object
  55375. * @param serializationObject The object to serialize to
  55376. */
  55377. serialize(serializationObject: any): void;
  55378. /**
  55379. * Adds all the elements from the container to the scene
  55380. * @param container the container holding the elements
  55381. */
  55382. addFromContainer(container: AbstractScene): void;
  55383. /**
  55384. * Removes all the elements in the container from the scene
  55385. * @param container contains the elements to remove
  55386. * @param dispose if the removed element should be disposed (default: false)
  55387. */
  55388. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55389. /**
  55390. * Rebuilds the elements related to this component in case of
  55391. * context lost for instance.
  55392. */
  55393. dispose(): void;
  55394. private _gatherRenderTargets;
  55395. }
  55396. }
  55397. declare module "babylonjs/Lights/Shadows/index" {
  55398. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55399. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55400. }
  55401. declare module "babylonjs/Lights/pointLight" {
  55402. import { Scene } from "babylonjs/scene";
  55403. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55405. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55406. import { Effect } from "babylonjs/Materials/effect";
  55407. /**
  55408. * A point light is a light defined by an unique point in world space.
  55409. * The light is emitted in every direction from this point.
  55410. * A good example of a point light is a standard light bulb.
  55411. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55412. */
  55413. export class PointLight extends ShadowLight {
  55414. private _shadowAngle;
  55415. /**
  55416. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55417. * This specifies what angle the shadow will use to be created.
  55418. *
  55419. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55420. */
  55421. get shadowAngle(): number;
  55422. /**
  55423. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55424. * This specifies what angle the shadow will use to be created.
  55425. *
  55426. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55427. */
  55428. set shadowAngle(value: number);
  55429. /**
  55430. * Gets the direction if it has been set.
  55431. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55432. */
  55433. get direction(): Vector3;
  55434. /**
  55435. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55436. */
  55437. set direction(value: Vector3);
  55438. /**
  55439. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55440. * A PointLight emits the light in every direction.
  55441. * It can cast shadows.
  55442. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55443. * ```javascript
  55444. * var pointLight = new PointLight("pl", camera.position, scene);
  55445. * ```
  55446. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55447. * @param name The light friendly name
  55448. * @param position The position of the point light in the scene
  55449. * @param scene The scene the lights belongs to
  55450. */
  55451. constructor(name: string, position: Vector3, scene: Scene);
  55452. /**
  55453. * Returns the string "PointLight"
  55454. * @returns the class name
  55455. */
  55456. getClassName(): string;
  55457. /**
  55458. * Returns the integer 0.
  55459. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55460. */
  55461. getTypeID(): number;
  55462. /**
  55463. * Specifies wether or not the shadowmap should be a cube texture.
  55464. * @returns true if the shadowmap needs to be a cube texture.
  55465. */
  55466. needCube(): boolean;
  55467. /**
  55468. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55469. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55470. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55471. */
  55472. getShadowDirection(faceIndex?: number): Vector3;
  55473. /**
  55474. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55475. * - fov = PI / 2
  55476. * - aspect ratio : 1.0
  55477. * - z-near and far equal to the active camera minZ and maxZ.
  55478. * Returns the PointLight.
  55479. */
  55480. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55481. protected _buildUniformLayout(): void;
  55482. /**
  55483. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55484. * @param effect The effect to update
  55485. * @param lightIndex The index of the light in the effect to update
  55486. * @returns The point light
  55487. */
  55488. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55489. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55490. /**
  55491. * Prepares the list of defines specific to the light type.
  55492. * @param defines the list of defines
  55493. * @param lightIndex defines the index of the light for the effect
  55494. */
  55495. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55496. }
  55497. }
  55498. declare module "babylonjs/Lights/index" {
  55499. export * from "babylonjs/Lights/light";
  55500. export * from "babylonjs/Lights/shadowLight";
  55501. export * from "babylonjs/Lights/Shadows/index";
  55502. export * from "babylonjs/Lights/directionalLight";
  55503. export * from "babylonjs/Lights/hemisphericLight";
  55504. export * from "babylonjs/Lights/pointLight";
  55505. export * from "babylonjs/Lights/spotLight";
  55506. }
  55507. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55508. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55509. /**
  55510. * Header information of HDR texture files.
  55511. */
  55512. export interface HDRInfo {
  55513. /**
  55514. * The height of the texture in pixels.
  55515. */
  55516. height: number;
  55517. /**
  55518. * The width of the texture in pixels.
  55519. */
  55520. width: number;
  55521. /**
  55522. * The index of the beginning of the data in the binary file.
  55523. */
  55524. dataPosition: number;
  55525. }
  55526. /**
  55527. * This groups tools to convert HDR texture to native colors array.
  55528. */
  55529. export class HDRTools {
  55530. private static Ldexp;
  55531. private static Rgbe2float;
  55532. private static readStringLine;
  55533. /**
  55534. * Reads header information from an RGBE texture stored in a native array.
  55535. * More information on this format are available here:
  55536. * https://en.wikipedia.org/wiki/RGBE_image_format
  55537. *
  55538. * @param uint8array The binary file stored in native array.
  55539. * @return The header information.
  55540. */
  55541. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55542. /**
  55543. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55544. * This RGBE texture needs to store the information as a panorama.
  55545. *
  55546. * More information on this format are available here:
  55547. * https://en.wikipedia.org/wiki/RGBE_image_format
  55548. *
  55549. * @param buffer The binary file stored in an array buffer.
  55550. * @param size The expected size of the extracted cubemap.
  55551. * @return The Cube Map information.
  55552. */
  55553. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55554. /**
  55555. * Returns the pixels data extracted from an RGBE texture.
  55556. * This pixels will be stored left to right up to down in the R G B order in one array.
  55557. *
  55558. * More information on this format are available here:
  55559. * https://en.wikipedia.org/wiki/RGBE_image_format
  55560. *
  55561. * @param uint8array The binary file stored in an array buffer.
  55562. * @param hdrInfo The header information of the file.
  55563. * @return The pixels data in RGB right to left up to down order.
  55564. */
  55565. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55566. private static RGBE_ReadPixels_RLE;
  55567. }
  55568. }
  55569. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55570. import { Nullable } from "babylonjs/types";
  55571. import { Scene } from "babylonjs/scene";
  55572. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55574. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55575. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55576. /**
  55577. * This represents a texture coming from an HDR input.
  55578. *
  55579. * The only supported format is currently panorama picture stored in RGBE format.
  55580. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55581. */
  55582. export class HDRCubeTexture extends BaseTexture {
  55583. private static _facesMapping;
  55584. private _generateHarmonics;
  55585. private _noMipmap;
  55586. private _textureMatrix;
  55587. private _size;
  55588. private _onLoad;
  55589. private _onError;
  55590. /**
  55591. * The texture URL.
  55592. */
  55593. url: string;
  55594. /**
  55595. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55596. */
  55597. coordinatesMode: number;
  55598. protected _isBlocking: boolean;
  55599. /**
  55600. * Sets wether or not the texture is blocking during loading.
  55601. */
  55602. set isBlocking(value: boolean);
  55603. /**
  55604. * Gets wether or not the texture is blocking during loading.
  55605. */
  55606. get isBlocking(): boolean;
  55607. protected _rotationY: number;
  55608. /**
  55609. * Sets texture matrix rotation angle around Y axis in radians.
  55610. */
  55611. set rotationY(value: number);
  55612. /**
  55613. * Gets texture matrix rotation angle around Y axis radians.
  55614. */
  55615. get rotationY(): number;
  55616. /**
  55617. * Gets or sets the center of the bounding box associated with the cube texture
  55618. * It must define where the camera used to render the texture was set
  55619. */
  55620. boundingBoxPosition: Vector3;
  55621. private _boundingBoxSize;
  55622. /**
  55623. * Gets or sets the size of the bounding box associated with the cube texture
  55624. * When defined, the cubemap will switch to local mode
  55625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55626. * @example https://www.babylonjs-playground.com/#RNASML
  55627. */
  55628. set boundingBoxSize(value: Vector3);
  55629. get boundingBoxSize(): Vector3;
  55630. /**
  55631. * Instantiates an HDRTexture from the following parameters.
  55632. *
  55633. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55634. * @param scene The scene the texture will be used in
  55635. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55636. * @param noMipmap Forces to not generate the mipmap if true
  55637. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55638. * @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)
  55639. * @param reserved Reserved flag for internal use.
  55640. */
  55641. 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>);
  55642. /**
  55643. * Get the current class name of the texture useful for serialization or dynamic coding.
  55644. * @returns "HDRCubeTexture"
  55645. */
  55646. getClassName(): string;
  55647. /**
  55648. * Occurs when the file is raw .hdr file.
  55649. */
  55650. private loadTexture;
  55651. clone(): HDRCubeTexture;
  55652. delayLoad(): void;
  55653. /**
  55654. * Get the texture reflection matrix used to rotate/transform the reflection.
  55655. * @returns the reflection matrix
  55656. */
  55657. getReflectionTextureMatrix(): Matrix;
  55658. /**
  55659. * Set the texture reflection matrix used to rotate/transform the reflection.
  55660. * @param value Define the reflection matrix to set
  55661. */
  55662. setReflectionTextureMatrix(value: Matrix): void;
  55663. /**
  55664. * Parses a JSON representation of an HDR Texture in order to create the texture
  55665. * @param parsedTexture Define the JSON representation
  55666. * @param scene Define the scene the texture should be created in
  55667. * @param rootUrl Define the root url in case we need to load relative dependencies
  55668. * @returns the newly created texture after parsing
  55669. */
  55670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55671. serialize(): any;
  55672. }
  55673. }
  55674. declare module "babylonjs/Physics/physicsEngine" {
  55675. import { Nullable } from "babylonjs/types";
  55676. import { Vector3 } from "babylonjs/Maths/math.vector";
  55677. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55678. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55679. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55680. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55681. /**
  55682. * Class used to control physics engine
  55683. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55684. */
  55685. export class PhysicsEngine implements IPhysicsEngine {
  55686. private _physicsPlugin;
  55687. /**
  55688. * Global value used to control the smallest number supported by the simulation
  55689. */
  55690. static Epsilon: number;
  55691. private _impostors;
  55692. private _joints;
  55693. private _subTimeStep;
  55694. /**
  55695. * Gets the gravity vector used by the simulation
  55696. */
  55697. gravity: Vector3;
  55698. /**
  55699. * Factory used to create the default physics plugin.
  55700. * @returns The default physics plugin
  55701. */
  55702. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55703. /**
  55704. * Creates a new Physics Engine
  55705. * @param gravity defines the gravity vector used by the simulation
  55706. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55707. */
  55708. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55709. /**
  55710. * Sets the gravity vector used by the simulation
  55711. * @param gravity defines the gravity vector to use
  55712. */
  55713. setGravity(gravity: Vector3): void;
  55714. /**
  55715. * Set the time step of the physics engine.
  55716. * Default is 1/60.
  55717. * To slow it down, enter 1/600 for example.
  55718. * To speed it up, 1/30
  55719. * @param newTimeStep defines the new timestep to apply to this world.
  55720. */
  55721. setTimeStep(newTimeStep?: number): void;
  55722. /**
  55723. * Get the time step of the physics engine.
  55724. * @returns the current time step
  55725. */
  55726. getTimeStep(): number;
  55727. /**
  55728. * Set the sub time step of the physics engine.
  55729. * Default is 0 meaning there is no sub steps
  55730. * To increase physics resolution precision, set a small value (like 1 ms)
  55731. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55732. */
  55733. setSubTimeStep(subTimeStep?: number): void;
  55734. /**
  55735. * Get the sub time step of the physics engine.
  55736. * @returns the current sub time step
  55737. */
  55738. getSubTimeStep(): number;
  55739. /**
  55740. * Release all resources
  55741. */
  55742. dispose(): void;
  55743. /**
  55744. * Gets the name of the current physics plugin
  55745. * @returns the name of the plugin
  55746. */
  55747. getPhysicsPluginName(): string;
  55748. /**
  55749. * Adding a new impostor for the impostor tracking.
  55750. * This will be done by the impostor itself.
  55751. * @param impostor the impostor to add
  55752. */
  55753. addImpostor(impostor: PhysicsImpostor): void;
  55754. /**
  55755. * Remove an impostor from the engine.
  55756. * This impostor and its mesh will not longer be updated by the physics engine.
  55757. * @param impostor the impostor to remove
  55758. */
  55759. removeImpostor(impostor: PhysicsImpostor): void;
  55760. /**
  55761. * Add a joint to the physics engine
  55762. * @param mainImpostor defines the main impostor to which the joint is added.
  55763. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55764. * @param joint defines the joint that will connect both impostors.
  55765. */
  55766. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55767. /**
  55768. * Removes a joint from the simulation
  55769. * @param mainImpostor defines the impostor used with the joint
  55770. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55771. * @param joint defines the joint to remove
  55772. */
  55773. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55774. /**
  55775. * Called by the scene. No need to call it.
  55776. * @param delta defines the timespam between frames
  55777. */
  55778. _step(delta: number): void;
  55779. /**
  55780. * Gets the current plugin used to run the simulation
  55781. * @returns current plugin
  55782. */
  55783. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55784. /**
  55785. * Gets the list of physic impostors
  55786. * @returns an array of PhysicsImpostor
  55787. */
  55788. getImpostors(): Array<PhysicsImpostor>;
  55789. /**
  55790. * Gets the impostor for a physics enabled object
  55791. * @param object defines the object impersonated by the impostor
  55792. * @returns the PhysicsImpostor or null if not found
  55793. */
  55794. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55795. /**
  55796. * Gets the impostor for a physics body object
  55797. * @param body defines physics body used by the impostor
  55798. * @returns the PhysicsImpostor or null if not found
  55799. */
  55800. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55801. /**
  55802. * Does a raycast in the physics world
  55803. * @param from when should the ray start?
  55804. * @param to when should the ray end?
  55805. * @returns PhysicsRaycastResult
  55806. */
  55807. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55808. }
  55809. }
  55810. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55811. import { Nullable } from "babylonjs/types";
  55812. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55814. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55815. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55816. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55817. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55818. /** @hidden */
  55819. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55820. private _useDeltaForWorldStep;
  55821. world: any;
  55822. name: string;
  55823. private _physicsMaterials;
  55824. private _fixedTimeStep;
  55825. private _cannonRaycastResult;
  55826. private _raycastResult;
  55827. private _physicsBodysToRemoveAfterStep;
  55828. BJSCANNON: any;
  55829. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55830. setGravity(gravity: Vector3): void;
  55831. setTimeStep(timeStep: number): void;
  55832. getTimeStep(): number;
  55833. executeStep(delta: number): void;
  55834. private _removeMarkedPhysicsBodiesFromWorld;
  55835. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55836. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55837. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55838. private _processChildMeshes;
  55839. removePhysicsBody(impostor: PhysicsImpostor): void;
  55840. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55841. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55842. private _addMaterial;
  55843. private _checkWithEpsilon;
  55844. private _createShape;
  55845. private _createHeightmap;
  55846. private _minus90X;
  55847. private _plus90X;
  55848. private _tmpPosition;
  55849. private _tmpDeltaPosition;
  55850. private _tmpUnityRotation;
  55851. private _updatePhysicsBodyTransformation;
  55852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55854. isSupported(): boolean;
  55855. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55856. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55857. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55858. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55859. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55860. getBodyMass(impostor: PhysicsImpostor): number;
  55861. getBodyFriction(impostor: PhysicsImpostor): number;
  55862. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55863. getBodyRestitution(impostor: PhysicsImpostor): number;
  55864. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55865. sleepBody(impostor: PhysicsImpostor): void;
  55866. wakeUpBody(impostor: PhysicsImpostor): void;
  55867. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55868. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55869. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55871. getRadius(impostor: PhysicsImpostor): number;
  55872. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55873. dispose(): void;
  55874. private _extendNamespace;
  55875. /**
  55876. * Does a raycast in the physics world
  55877. * @param from when should the ray start?
  55878. * @param to when should the ray end?
  55879. * @returns PhysicsRaycastResult
  55880. */
  55881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55882. }
  55883. }
  55884. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55885. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55886. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55887. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55889. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55890. import { Nullable } from "babylonjs/types";
  55891. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55892. /** @hidden */
  55893. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55894. world: any;
  55895. name: string;
  55896. BJSOIMO: any;
  55897. private _raycastResult;
  55898. constructor(iterations?: number, oimoInjection?: any);
  55899. setGravity(gravity: Vector3): void;
  55900. setTimeStep(timeStep: number): void;
  55901. getTimeStep(): number;
  55902. private _tmpImpostorsArray;
  55903. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55904. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55905. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55906. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55907. private _tmpPositionVector;
  55908. removePhysicsBody(impostor: PhysicsImpostor): void;
  55909. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55910. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55911. isSupported(): boolean;
  55912. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55913. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55914. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55915. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55916. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55917. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55918. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55919. getBodyMass(impostor: PhysicsImpostor): number;
  55920. getBodyFriction(impostor: PhysicsImpostor): number;
  55921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55922. getBodyRestitution(impostor: PhysicsImpostor): number;
  55923. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55924. sleepBody(impostor: PhysicsImpostor): void;
  55925. wakeUpBody(impostor: PhysicsImpostor): void;
  55926. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55927. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55928. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55929. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55930. getRadius(impostor: PhysicsImpostor): number;
  55931. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55932. dispose(): void;
  55933. /**
  55934. * Does a raycast in the physics world
  55935. * @param from when should the ray start?
  55936. * @param to when should the ray end?
  55937. * @returns PhysicsRaycastResult
  55938. */
  55939. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55940. }
  55941. }
  55942. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55943. import { Nullable } from "babylonjs/types";
  55944. import { Scene } from "babylonjs/scene";
  55945. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55946. import { Color4 } from "babylonjs/Maths/math.color";
  55947. import { Mesh } from "babylonjs/Meshes/mesh";
  55948. /**
  55949. * Class containing static functions to help procedurally build meshes
  55950. */
  55951. export class RibbonBuilder {
  55952. /**
  55953. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55954. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55955. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55956. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55957. * * 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
  55958. * * 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
  55959. * * 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
  55960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55963. * * 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
  55964. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55965. * * 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
  55966. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55968. * @param name defines the name of the mesh
  55969. * @param options defines the options used to create the mesh
  55970. * @param scene defines the hosting scene
  55971. * @returns the ribbon mesh
  55972. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55973. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55974. */
  55975. static CreateRibbon(name: string, options: {
  55976. pathArray: Vector3[][];
  55977. closeArray?: boolean;
  55978. closePath?: boolean;
  55979. offset?: number;
  55980. updatable?: boolean;
  55981. sideOrientation?: number;
  55982. frontUVs?: Vector4;
  55983. backUVs?: Vector4;
  55984. instance?: Mesh;
  55985. invertUV?: boolean;
  55986. uvs?: Vector2[];
  55987. colors?: Color4[];
  55988. }, scene?: Nullable<Scene>): Mesh;
  55989. }
  55990. }
  55991. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55992. import { Nullable } from "babylonjs/types";
  55993. import { Scene } from "babylonjs/scene";
  55994. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55995. import { Mesh } from "babylonjs/Meshes/mesh";
  55996. /**
  55997. * Class containing static functions to help procedurally build meshes
  55998. */
  55999. export class ShapeBuilder {
  56000. /**
  56001. * 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.
  56002. * * 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.
  56003. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56004. * * 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.
  56005. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56006. * * 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
  56007. * * 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
  56008. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56013. * @param name defines the name of the mesh
  56014. * @param options defines the options used to create the mesh
  56015. * @param scene defines the hosting scene
  56016. * @returns the extruded shape mesh
  56017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56019. */
  56020. static ExtrudeShape(name: string, options: {
  56021. shape: Vector3[];
  56022. path: Vector3[];
  56023. scale?: number;
  56024. rotation?: number;
  56025. cap?: number;
  56026. updatable?: boolean;
  56027. sideOrientation?: number;
  56028. frontUVs?: Vector4;
  56029. backUVs?: Vector4;
  56030. instance?: Mesh;
  56031. invertUV?: boolean;
  56032. }, scene?: Nullable<Scene>): Mesh;
  56033. /**
  56034. * Creates an custom extruded shape mesh.
  56035. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56036. * * 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.
  56037. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56038. * * 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
  56039. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56040. * * 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
  56041. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56042. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56043. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56044. * * 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
  56045. * * 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
  56046. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56051. * @param name defines the name of the mesh
  56052. * @param options defines the options used to create the mesh
  56053. * @param scene defines the hosting scene
  56054. * @returns the custom extruded shape mesh
  56055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56056. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56058. */
  56059. static ExtrudeShapeCustom(name: string, options: {
  56060. shape: Vector3[];
  56061. path: Vector3[];
  56062. scaleFunction?: any;
  56063. rotationFunction?: any;
  56064. ribbonCloseArray?: boolean;
  56065. ribbonClosePath?: boolean;
  56066. cap?: number;
  56067. updatable?: boolean;
  56068. sideOrientation?: number;
  56069. frontUVs?: Vector4;
  56070. backUVs?: Vector4;
  56071. instance?: Mesh;
  56072. invertUV?: boolean;
  56073. }, scene?: Nullable<Scene>): Mesh;
  56074. private static _ExtrudeShapeGeneric;
  56075. }
  56076. }
  56077. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56078. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56079. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56080. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56081. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56082. import { Nullable } from "babylonjs/types";
  56083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56084. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56085. /**
  56086. * AmmoJS Physics plugin
  56087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56088. * @see https://github.com/kripken/ammo.js/
  56089. */
  56090. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56091. private _useDeltaForWorldStep;
  56092. /**
  56093. * Reference to the Ammo library
  56094. */
  56095. bjsAMMO: any;
  56096. /**
  56097. * Created ammoJS world which physics bodies are added to
  56098. */
  56099. world: any;
  56100. /**
  56101. * Name of the plugin
  56102. */
  56103. name: string;
  56104. private _timeStep;
  56105. private _fixedTimeStep;
  56106. private _maxSteps;
  56107. private _tmpQuaternion;
  56108. private _tmpAmmoTransform;
  56109. private _tmpAmmoQuaternion;
  56110. private _tmpAmmoConcreteContactResultCallback;
  56111. private _collisionConfiguration;
  56112. private _dispatcher;
  56113. private _overlappingPairCache;
  56114. private _solver;
  56115. private _softBodySolver;
  56116. private _tmpAmmoVectorA;
  56117. private _tmpAmmoVectorB;
  56118. private _tmpAmmoVectorC;
  56119. private _tmpAmmoVectorD;
  56120. private _tmpContactCallbackResult;
  56121. private _tmpAmmoVectorRCA;
  56122. private _tmpAmmoVectorRCB;
  56123. private _raycastResult;
  56124. private static readonly DISABLE_COLLISION_FLAG;
  56125. private static readonly KINEMATIC_FLAG;
  56126. private static readonly DISABLE_DEACTIVATION_FLAG;
  56127. /**
  56128. * Initializes the ammoJS plugin
  56129. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56130. * @param ammoInjection can be used to inject your own ammo reference
  56131. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56132. */
  56133. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56134. /**
  56135. * Sets the gravity of the physics world (m/(s^2))
  56136. * @param gravity Gravity to set
  56137. */
  56138. setGravity(gravity: Vector3): void;
  56139. /**
  56140. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56141. * @param timeStep timestep to use in seconds
  56142. */
  56143. setTimeStep(timeStep: number): void;
  56144. /**
  56145. * 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)
  56146. * @param fixedTimeStep fixedTimeStep to use in seconds
  56147. */
  56148. setFixedTimeStep(fixedTimeStep: number): void;
  56149. /**
  56150. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56151. * @param maxSteps the maximum number of steps by the physics engine per frame
  56152. */
  56153. setMaxSteps(maxSteps: number): void;
  56154. /**
  56155. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56156. * @returns the current timestep in seconds
  56157. */
  56158. getTimeStep(): number;
  56159. /**
  56160. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56161. */
  56162. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56163. private _isImpostorInContact;
  56164. private _isImpostorPairInContact;
  56165. private _stepSimulation;
  56166. /**
  56167. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56168. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56169. * After the step the babylon meshes are set to the position of the physics imposters
  56170. * @param delta amount of time to step forward
  56171. * @param impostors array of imposters to update before/after the step
  56172. */
  56173. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56174. /**
  56175. * Update babylon mesh to match physics world object
  56176. * @param impostor imposter to match
  56177. */
  56178. private _afterSoftStep;
  56179. /**
  56180. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56181. * @param impostor imposter to match
  56182. */
  56183. private _ropeStep;
  56184. /**
  56185. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56186. * @param impostor imposter to match
  56187. */
  56188. private _softbodyOrClothStep;
  56189. private _tmpVector;
  56190. private _tmpMatrix;
  56191. /**
  56192. * Applies an impulse on the imposter
  56193. * @param impostor imposter to apply impulse to
  56194. * @param force amount of force to be applied to the imposter
  56195. * @param contactPoint the location to apply the impulse on the imposter
  56196. */
  56197. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56198. /**
  56199. * Applies a force on the imposter
  56200. * @param impostor imposter to apply force
  56201. * @param force amount of force to be applied to the imposter
  56202. * @param contactPoint the location to apply the force on the imposter
  56203. */
  56204. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56205. /**
  56206. * Creates a physics body using the plugin
  56207. * @param impostor the imposter to create the physics body on
  56208. */
  56209. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56210. /**
  56211. * Removes the physics body from the imposter and disposes of the body's memory
  56212. * @param impostor imposter to remove the physics body from
  56213. */
  56214. removePhysicsBody(impostor: PhysicsImpostor): void;
  56215. /**
  56216. * Generates a joint
  56217. * @param impostorJoint the imposter joint to create the joint with
  56218. */
  56219. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56220. /**
  56221. * Removes a joint
  56222. * @param impostorJoint the imposter joint to remove the joint from
  56223. */
  56224. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56225. private _addMeshVerts;
  56226. /**
  56227. * Initialise the soft body vertices to match its object's (mesh) vertices
  56228. * Softbody vertices (nodes) are in world space and to match this
  56229. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56230. * @param impostor to create the softbody for
  56231. */
  56232. private _softVertexData;
  56233. /**
  56234. * Create an impostor's soft body
  56235. * @param impostor to create the softbody for
  56236. */
  56237. private _createSoftbody;
  56238. /**
  56239. * Create cloth for an impostor
  56240. * @param impostor to create the softbody for
  56241. */
  56242. private _createCloth;
  56243. /**
  56244. * Create rope for an impostor
  56245. * @param impostor to create the softbody for
  56246. */
  56247. private _createRope;
  56248. /**
  56249. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56250. * @param impostor to create the custom physics shape for
  56251. */
  56252. private _createCustom;
  56253. private _addHullVerts;
  56254. private _createShape;
  56255. /**
  56256. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56257. * @param impostor imposter containing the physics body and babylon object
  56258. */
  56259. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56260. /**
  56261. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56262. * @param impostor imposter containing the physics body and babylon object
  56263. * @param newPosition new position
  56264. * @param newRotation new rotation
  56265. */
  56266. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56267. /**
  56268. * If this plugin is supported
  56269. * @returns true if its supported
  56270. */
  56271. isSupported(): boolean;
  56272. /**
  56273. * Sets the linear velocity of the physics body
  56274. * @param impostor imposter to set the velocity on
  56275. * @param velocity velocity to set
  56276. */
  56277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56278. /**
  56279. * Sets the angular velocity of the physics body
  56280. * @param impostor imposter to set the velocity on
  56281. * @param velocity velocity to set
  56282. */
  56283. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56284. /**
  56285. * gets the linear velocity
  56286. * @param impostor imposter to get linear velocity from
  56287. * @returns linear velocity
  56288. */
  56289. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56290. /**
  56291. * gets the angular velocity
  56292. * @param impostor imposter to get angular velocity from
  56293. * @returns angular velocity
  56294. */
  56295. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56296. /**
  56297. * Sets the mass of physics body
  56298. * @param impostor imposter to set the mass on
  56299. * @param mass mass to set
  56300. */
  56301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56302. /**
  56303. * Gets the mass of the physics body
  56304. * @param impostor imposter to get the mass from
  56305. * @returns mass
  56306. */
  56307. getBodyMass(impostor: PhysicsImpostor): number;
  56308. /**
  56309. * Gets friction of the impostor
  56310. * @param impostor impostor to get friction from
  56311. * @returns friction value
  56312. */
  56313. getBodyFriction(impostor: PhysicsImpostor): number;
  56314. /**
  56315. * Sets friction of the impostor
  56316. * @param impostor impostor to set friction on
  56317. * @param friction friction value
  56318. */
  56319. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56320. /**
  56321. * Gets restitution of the impostor
  56322. * @param impostor impostor to get restitution from
  56323. * @returns restitution value
  56324. */
  56325. getBodyRestitution(impostor: PhysicsImpostor): number;
  56326. /**
  56327. * Sets resitution of the impostor
  56328. * @param impostor impostor to set resitution on
  56329. * @param restitution resitution value
  56330. */
  56331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56332. /**
  56333. * Gets pressure inside the impostor
  56334. * @param impostor impostor to get pressure from
  56335. * @returns pressure value
  56336. */
  56337. getBodyPressure(impostor: PhysicsImpostor): number;
  56338. /**
  56339. * Sets pressure inside a soft body impostor
  56340. * Cloth and rope must remain 0 pressure
  56341. * @param impostor impostor to set pressure on
  56342. * @param pressure pressure value
  56343. */
  56344. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56345. /**
  56346. * Gets stiffness of the impostor
  56347. * @param impostor impostor to get stiffness from
  56348. * @returns pressure value
  56349. */
  56350. getBodyStiffness(impostor: PhysicsImpostor): number;
  56351. /**
  56352. * Sets stiffness of the impostor
  56353. * @param impostor impostor to set stiffness on
  56354. * @param stiffness stiffness value from 0 to 1
  56355. */
  56356. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56357. /**
  56358. * Gets velocityIterations of the impostor
  56359. * @param impostor impostor to get velocity iterations from
  56360. * @returns velocityIterations value
  56361. */
  56362. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56363. /**
  56364. * Sets velocityIterations of the impostor
  56365. * @param impostor impostor to set velocity iterations on
  56366. * @param velocityIterations velocityIterations value
  56367. */
  56368. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56369. /**
  56370. * Gets positionIterations of the impostor
  56371. * @param impostor impostor to get position iterations from
  56372. * @returns positionIterations value
  56373. */
  56374. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56375. /**
  56376. * Sets positionIterations of the impostor
  56377. * @param impostor impostor to set position on
  56378. * @param positionIterations positionIterations value
  56379. */
  56380. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56381. /**
  56382. * Append an anchor to a cloth object
  56383. * @param impostor is the cloth impostor to add anchor to
  56384. * @param otherImpostor is the rigid impostor to anchor to
  56385. * @param width ratio across width from 0 to 1
  56386. * @param height ratio up height from 0 to 1
  56387. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56388. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56389. */
  56390. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56391. /**
  56392. * Append an hook to a rope object
  56393. * @param impostor is the rope impostor to add hook to
  56394. * @param otherImpostor is the rigid impostor to hook to
  56395. * @param length ratio along the rope from 0 to 1
  56396. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56397. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56398. */
  56399. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56400. /**
  56401. * Sleeps the physics body and stops it from being active
  56402. * @param impostor impostor to sleep
  56403. */
  56404. sleepBody(impostor: PhysicsImpostor): void;
  56405. /**
  56406. * Activates the physics body
  56407. * @param impostor impostor to activate
  56408. */
  56409. wakeUpBody(impostor: PhysicsImpostor): void;
  56410. /**
  56411. * Updates the distance parameters of the joint
  56412. * @param joint joint to update
  56413. * @param maxDistance maximum distance of the joint
  56414. * @param minDistance minimum distance of the joint
  56415. */
  56416. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56417. /**
  56418. * Sets a motor on the joint
  56419. * @param joint joint to set motor on
  56420. * @param speed speed of the motor
  56421. * @param maxForce maximum force of the motor
  56422. * @param motorIndex index of the motor
  56423. */
  56424. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56425. /**
  56426. * Sets the motors limit
  56427. * @param joint joint to set limit on
  56428. * @param upperLimit upper limit
  56429. * @param lowerLimit lower limit
  56430. */
  56431. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56432. /**
  56433. * Syncs the position and rotation of a mesh with the impostor
  56434. * @param mesh mesh to sync
  56435. * @param impostor impostor to update the mesh with
  56436. */
  56437. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56438. /**
  56439. * Gets the radius of the impostor
  56440. * @param impostor impostor to get radius from
  56441. * @returns the radius
  56442. */
  56443. getRadius(impostor: PhysicsImpostor): number;
  56444. /**
  56445. * Gets the box size of the impostor
  56446. * @param impostor impostor to get box size from
  56447. * @param result the resulting box size
  56448. */
  56449. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56450. /**
  56451. * Disposes of the impostor
  56452. */
  56453. dispose(): void;
  56454. /**
  56455. * Does a raycast in the physics world
  56456. * @param from when should the ray start?
  56457. * @param to when should the ray end?
  56458. * @returns PhysicsRaycastResult
  56459. */
  56460. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56461. }
  56462. }
  56463. declare module "babylonjs/Probes/reflectionProbe" {
  56464. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56465. import { Vector3 } from "babylonjs/Maths/math.vector";
  56466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56467. import { Nullable } from "babylonjs/types";
  56468. import { Scene } from "babylonjs/scene";
  56469. module "babylonjs/abstractScene" {
  56470. interface AbstractScene {
  56471. /**
  56472. * The list of reflection probes added to the scene
  56473. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56474. */
  56475. reflectionProbes: Array<ReflectionProbe>;
  56476. /**
  56477. * Removes the given reflection probe from this scene.
  56478. * @param toRemove The reflection probe to remove
  56479. * @returns The index of the removed reflection probe
  56480. */
  56481. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56482. /**
  56483. * Adds the given reflection probe to this scene.
  56484. * @param newReflectionProbe The reflection probe to add
  56485. */
  56486. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56487. }
  56488. }
  56489. /**
  56490. * Class used to generate realtime reflection / refraction cube textures
  56491. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56492. */
  56493. export class ReflectionProbe {
  56494. /** defines the name of the probe */
  56495. name: string;
  56496. private _scene;
  56497. private _renderTargetTexture;
  56498. private _projectionMatrix;
  56499. private _viewMatrix;
  56500. private _target;
  56501. private _add;
  56502. private _attachedMesh;
  56503. private _invertYAxis;
  56504. /** Gets or sets probe position (center of the cube map) */
  56505. position: Vector3;
  56506. /**
  56507. * Creates a new reflection probe
  56508. * @param name defines the name of the probe
  56509. * @param size defines the texture resolution (for each face)
  56510. * @param scene defines the hosting scene
  56511. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56512. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56513. */
  56514. constructor(
  56515. /** defines the name of the probe */
  56516. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56517. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56518. get samples(): number;
  56519. set samples(value: number);
  56520. /** Gets or sets the refresh rate to use (on every frame by default) */
  56521. get refreshRate(): number;
  56522. set refreshRate(value: number);
  56523. /**
  56524. * Gets the hosting scene
  56525. * @returns a Scene
  56526. */
  56527. getScene(): Scene;
  56528. /** Gets the internal CubeTexture used to render to */
  56529. get cubeTexture(): RenderTargetTexture;
  56530. /** Gets the list of meshes to render */
  56531. get renderList(): Nullable<AbstractMesh[]>;
  56532. /**
  56533. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56534. * @param mesh defines the mesh to attach to
  56535. */
  56536. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56537. /**
  56538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56539. * @param renderingGroupId The rendering group id corresponding to its index
  56540. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56541. */
  56542. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56543. /**
  56544. * Clean all associated resources
  56545. */
  56546. dispose(): void;
  56547. /**
  56548. * Converts the reflection probe information to a readable string for debug purpose.
  56549. * @param fullDetails Supports for multiple levels of logging within scene loading
  56550. * @returns the human readable reflection probe info
  56551. */
  56552. toString(fullDetails?: boolean): string;
  56553. /**
  56554. * Get the class name of the relfection probe.
  56555. * @returns "ReflectionProbe"
  56556. */
  56557. getClassName(): string;
  56558. /**
  56559. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56560. * @returns The JSON representation of the texture
  56561. */
  56562. serialize(): any;
  56563. /**
  56564. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56565. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56566. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56567. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56568. * @returns The parsed reflection probe if successful
  56569. */
  56570. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56571. }
  56572. }
  56573. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56574. /** @hidden */
  56575. export var _BabylonLoaderRegistered: boolean;
  56576. /**
  56577. * Helps setting up some configuration for the babylon file loader.
  56578. */
  56579. export class BabylonFileLoaderConfiguration {
  56580. /**
  56581. * The loader does not allow injecting custom physix engine into the plugins.
  56582. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56583. * So you could set this variable to your engine import to make it work.
  56584. */
  56585. static LoaderInjectedPhysicsEngine: any;
  56586. }
  56587. }
  56588. declare module "babylonjs/Loading/Plugins/index" {
  56589. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56590. }
  56591. declare module "babylonjs/Loading/index" {
  56592. export * from "babylonjs/Loading/loadingScreen";
  56593. export * from "babylonjs/Loading/Plugins/index";
  56594. export * from "babylonjs/Loading/sceneLoader";
  56595. export * from "babylonjs/Loading/sceneLoaderFlags";
  56596. }
  56597. declare module "babylonjs/Materials/Background/index" {
  56598. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56599. }
  56600. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56601. import { Scene } from "babylonjs/scene";
  56602. import { Color3 } from "babylonjs/Maths/math.color";
  56603. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56605. /**
  56606. * The Physically based simple base material of BJS.
  56607. *
  56608. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56609. * It is used as the base class for both the specGloss and metalRough conventions.
  56610. */
  56611. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56612. /**
  56613. * Number of Simultaneous lights allowed on the material.
  56614. */
  56615. maxSimultaneousLights: number;
  56616. /**
  56617. * If sets to true, disables all the lights affecting the material.
  56618. */
  56619. disableLighting: boolean;
  56620. /**
  56621. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56622. */
  56623. environmentTexture: BaseTexture;
  56624. /**
  56625. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56626. */
  56627. invertNormalMapX: boolean;
  56628. /**
  56629. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56630. */
  56631. invertNormalMapY: boolean;
  56632. /**
  56633. * Normal map used in the model.
  56634. */
  56635. normalTexture: BaseTexture;
  56636. /**
  56637. * Emissivie color used to self-illuminate the model.
  56638. */
  56639. emissiveColor: Color3;
  56640. /**
  56641. * Emissivie texture used to self-illuminate the model.
  56642. */
  56643. emissiveTexture: BaseTexture;
  56644. /**
  56645. * Occlusion Channel Strenght.
  56646. */
  56647. occlusionStrength: number;
  56648. /**
  56649. * Occlusion Texture of the material (adding extra occlusion effects).
  56650. */
  56651. occlusionTexture: BaseTexture;
  56652. /**
  56653. * Defines the alpha limits in alpha test mode.
  56654. */
  56655. alphaCutOff: number;
  56656. /**
  56657. * Gets the current double sided mode.
  56658. */
  56659. get doubleSided(): boolean;
  56660. /**
  56661. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56662. */
  56663. set doubleSided(value: boolean);
  56664. /**
  56665. * Stores the pre-calculated light information of a mesh in a texture.
  56666. */
  56667. lightmapTexture: BaseTexture;
  56668. /**
  56669. * If true, the light map contains occlusion information instead of lighting info.
  56670. */
  56671. useLightmapAsShadowmap: boolean;
  56672. /**
  56673. * Instantiates a new PBRMaterial instance.
  56674. *
  56675. * @param name The material name
  56676. * @param scene The scene the material will be use in.
  56677. */
  56678. constructor(name: string, scene: Scene);
  56679. getClassName(): string;
  56680. }
  56681. }
  56682. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56683. import { Scene } from "babylonjs/scene";
  56684. import { Color3 } from "babylonjs/Maths/math.color";
  56685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56686. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56687. /**
  56688. * The PBR material of BJS following the metal roughness convention.
  56689. *
  56690. * This fits to the PBR convention in the GLTF definition:
  56691. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56692. */
  56693. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56694. /**
  56695. * The base color has two different interpretations depending on the value of metalness.
  56696. * When the material is a metal, the base color is the specific measured reflectance value
  56697. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56698. * of the material.
  56699. */
  56700. baseColor: Color3;
  56701. /**
  56702. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56703. * well as opacity information in the alpha channel.
  56704. */
  56705. baseTexture: BaseTexture;
  56706. /**
  56707. * Specifies the metallic scalar value of the material.
  56708. * Can also be used to scale the metalness values of the metallic texture.
  56709. */
  56710. metallic: number;
  56711. /**
  56712. * Specifies the roughness scalar value of the material.
  56713. * Can also be used to scale the roughness values of the metallic texture.
  56714. */
  56715. roughness: number;
  56716. /**
  56717. * Texture containing both the metallic value in the B channel and the
  56718. * roughness value in the G channel to keep better precision.
  56719. */
  56720. metallicRoughnessTexture: BaseTexture;
  56721. /**
  56722. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56723. *
  56724. * @param name The material name
  56725. * @param scene The scene the material will be use in.
  56726. */
  56727. constructor(name: string, scene: Scene);
  56728. /**
  56729. * Return the currrent class name of the material.
  56730. */
  56731. getClassName(): string;
  56732. /**
  56733. * Makes a duplicate of the current material.
  56734. * @param name - name to use for the new material.
  56735. */
  56736. clone(name: string): PBRMetallicRoughnessMaterial;
  56737. /**
  56738. * Serialize the material to a parsable JSON object.
  56739. */
  56740. serialize(): any;
  56741. /**
  56742. * Parses a JSON object correponding to the serialize function.
  56743. */
  56744. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56745. }
  56746. }
  56747. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56748. import { Scene } from "babylonjs/scene";
  56749. import { Color3 } from "babylonjs/Maths/math.color";
  56750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56751. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56752. /**
  56753. * The PBR material of BJS following the specular glossiness convention.
  56754. *
  56755. * This fits to the PBR convention in the GLTF definition:
  56756. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56757. */
  56758. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56759. /**
  56760. * Specifies the diffuse color of the material.
  56761. */
  56762. diffuseColor: Color3;
  56763. /**
  56764. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56765. * channel.
  56766. */
  56767. diffuseTexture: BaseTexture;
  56768. /**
  56769. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56770. */
  56771. specularColor: Color3;
  56772. /**
  56773. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56774. */
  56775. glossiness: number;
  56776. /**
  56777. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56778. */
  56779. specularGlossinessTexture: BaseTexture;
  56780. /**
  56781. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56782. *
  56783. * @param name The material name
  56784. * @param scene The scene the material will be use in.
  56785. */
  56786. constructor(name: string, scene: Scene);
  56787. /**
  56788. * Return the currrent class name of the material.
  56789. */
  56790. getClassName(): string;
  56791. /**
  56792. * Makes a duplicate of the current material.
  56793. * @param name - name to use for the new material.
  56794. */
  56795. clone(name: string): PBRSpecularGlossinessMaterial;
  56796. /**
  56797. * Serialize the material to a parsable JSON object.
  56798. */
  56799. serialize(): any;
  56800. /**
  56801. * Parses a JSON object correponding to the serialize function.
  56802. */
  56803. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56804. }
  56805. }
  56806. declare module "babylonjs/Materials/PBR/index" {
  56807. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56808. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56809. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56810. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56811. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56812. }
  56813. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56814. import { Nullable } from "babylonjs/types";
  56815. import { Scene } from "babylonjs/scene";
  56816. import { Matrix } from "babylonjs/Maths/math.vector";
  56817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56818. /**
  56819. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56820. * It can help converting any input color in a desired output one. This can then be used to create effects
  56821. * from sepia, black and white to sixties or futuristic rendering...
  56822. *
  56823. * The only supported format is currently 3dl.
  56824. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56825. */
  56826. export class ColorGradingTexture extends BaseTexture {
  56827. /**
  56828. * The current texture matrix. (will always be identity in color grading texture)
  56829. */
  56830. private _textureMatrix;
  56831. /**
  56832. * The texture URL.
  56833. */
  56834. url: string;
  56835. /**
  56836. * Empty line regex stored for GC.
  56837. */
  56838. private static _noneEmptyLineRegex;
  56839. private _engine;
  56840. /**
  56841. * Instantiates a ColorGradingTexture from the following parameters.
  56842. *
  56843. * @param url The location of the color gradind data (currently only supporting 3dl)
  56844. * @param scene The scene the texture will be used in
  56845. */
  56846. constructor(url: string, scene: Scene);
  56847. /**
  56848. * Returns the texture matrix used in most of the material.
  56849. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56850. */
  56851. getTextureMatrix(): Matrix;
  56852. /**
  56853. * Occurs when the file being loaded is a .3dl LUT file.
  56854. */
  56855. private load3dlTexture;
  56856. /**
  56857. * Starts the loading process of the texture.
  56858. */
  56859. private loadTexture;
  56860. /**
  56861. * Clones the color gradind texture.
  56862. */
  56863. clone(): ColorGradingTexture;
  56864. /**
  56865. * Called during delayed load for textures.
  56866. */
  56867. delayLoad(): void;
  56868. /**
  56869. * Parses a color grading texture serialized by Babylon.
  56870. * @param parsedTexture The texture information being parsedTexture
  56871. * @param scene The scene to load the texture in
  56872. * @param rootUrl The root url of the data assets to load
  56873. * @return A color gradind texture
  56874. */
  56875. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56876. /**
  56877. * Serializes the LUT texture to json format.
  56878. */
  56879. serialize(): any;
  56880. }
  56881. }
  56882. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56884. import { Scene } from "babylonjs/scene";
  56885. import { Nullable } from "babylonjs/types";
  56886. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56887. /**
  56888. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56889. */
  56890. export class EquiRectangularCubeTexture extends BaseTexture {
  56891. /** The six faces of the cube. */
  56892. private static _FacesMapping;
  56893. private _noMipmap;
  56894. private _onLoad;
  56895. private _onError;
  56896. /** The size of the cubemap. */
  56897. private _size;
  56898. /** The buffer of the image. */
  56899. private _buffer;
  56900. /** The width of the input image. */
  56901. private _width;
  56902. /** The height of the input image. */
  56903. private _height;
  56904. /** The URL to the image. */
  56905. url: string;
  56906. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56907. coordinatesMode: number;
  56908. /**
  56909. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56910. * @param url The location of the image
  56911. * @param scene The scene the texture will be used in
  56912. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56913. * @param noMipmap Forces to not generate the mipmap if true
  56914. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56915. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56916. * @param onLoad — defines a callback called when texture is loaded
  56917. * @param onError — defines a callback called if there is an error
  56918. */
  56919. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56920. /**
  56921. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56922. */
  56923. private loadImage;
  56924. /**
  56925. * Convert the image buffer into a cubemap and create a CubeTexture.
  56926. */
  56927. private loadTexture;
  56928. /**
  56929. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56930. * @param buffer The ArrayBuffer that should be converted.
  56931. * @returns The buffer as Float32Array.
  56932. */
  56933. private getFloat32ArrayFromArrayBuffer;
  56934. /**
  56935. * Get the current class name of the texture useful for serialization or dynamic coding.
  56936. * @returns "EquiRectangularCubeTexture"
  56937. */
  56938. getClassName(): string;
  56939. /**
  56940. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56941. * @returns A clone of the current EquiRectangularCubeTexture.
  56942. */
  56943. clone(): EquiRectangularCubeTexture;
  56944. }
  56945. }
  56946. declare module "babylonjs/Misc/tga" {
  56947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56948. /**
  56949. * Based on jsTGALoader - Javascript loader for TGA file
  56950. * By Vincent Thibault
  56951. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56952. */
  56953. export class TGATools {
  56954. private static _TYPE_INDEXED;
  56955. private static _TYPE_RGB;
  56956. private static _TYPE_GREY;
  56957. private static _TYPE_RLE_INDEXED;
  56958. private static _TYPE_RLE_RGB;
  56959. private static _TYPE_RLE_GREY;
  56960. private static _ORIGIN_MASK;
  56961. private static _ORIGIN_SHIFT;
  56962. private static _ORIGIN_BL;
  56963. private static _ORIGIN_BR;
  56964. private static _ORIGIN_UL;
  56965. private static _ORIGIN_UR;
  56966. /**
  56967. * Gets the header of a TGA file
  56968. * @param data defines the TGA data
  56969. * @returns the header
  56970. */
  56971. static GetTGAHeader(data: Uint8Array): any;
  56972. /**
  56973. * Uploads TGA content to a Babylon Texture
  56974. * @hidden
  56975. */
  56976. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56977. /** @hidden */
  56978. 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;
  56979. /** @hidden */
  56980. 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;
  56981. /** @hidden */
  56982. 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;
  56983. /** @hidden */
  56984. 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;
  56985. /** @hidden */
  56986. 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;
  56987. /** @hidden */
  56988. 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;
  56989. }
  56990. }
  56991. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56992. import { Nullable } from "babylonjs/types";
  56993. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56994. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56995. /**
  56996. * Implementation of the TGA Texture Loader.
  56997. * @hidden
  56998. */
  56999. export class _TGATextureLoader implements IInternalTextureLoader {
  57000. /**
  57001. * Defines wether the loader supports cascade loading the different faces.
  57002. */
  57003. readonly supportCascades: boolean;
  57004. /**
  57005. * This returns if the loader support the current file information.
  57006. * @param extension defines the file extension of the file being loaded
  57007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57008. * @param fallback defines the fallback internal texture if any
  57009. * @param isBase64 defines whether the texture is encoded as a base64
  57010. * @param isBuffer defines whether the texture data are stored as a buffer
  57011. * @returns true if the loader can load the specified file
  57012. */
  57013. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57014. /**
  57015. * Transform the url before loading if required.
  57016. * @param rootUrl the url of the texture
  57017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57018. * @returns the transformed texture
  57019. */
  57020. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57021. /**
  57022. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57023. * @param rootUrl the url of the texture
  57024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57025. * @returns the fallback texture
  57026. */
  57027. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57028. /**
  57029. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57030. * @param data contains the texture data
  57031. * @param texture defines the BabylonJS internal texture
  57032. * @param createPolynomials will be true if polynomials have been requested
  57033. * @param onLoad defines the callback to trigger once the texture is ready
  57034. * @param onError defines the callback to trigger in case of error
  57035. */
  57036. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57037. /**
  57038. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57039. * @param data contains the texture data
  57040. * @param texture defines the BabylonJS internal texture
  57041. * @param callback defines the method to call once ready to upload
  57042. */
  57043. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57044. }
  57045. }
  57046. declare module "babylonjs/Misc/basis" {
  57047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57048. /**
  57049. * Info about the .basis files
  57050. */
  57051. class BasisFileInfo {
  57052. /**
  57053. * If the file has alpha
  57054. */
  57055. hasAlpha: boolean;
  57056. /**
  57057. * Info about each image of the basis file
  57058. */
  57059. images: Array<{
  57060. levels: Array<{
  57061. width: number;
  57062. height: number;
  57063. transcodedPixels: ArrayBufferView;
  57064. }>;
  57065. }>;
  57066. }
  57067. /**
  57068. * Result of transcoding a basis file
  57069. */
  57070. class TranscodeResult {
  57071. /**
  57072. * Info about the .basis file
  57073. */
  57074. fileInfo: BasisFileInfo;
  57075. /**
  57076. * Format to use when loading the file
  57077. */
  57078. format: number;
  57079. }
  57080. /**
  57081. * Configuration options for the Basis transcoder
  57082. */
  57083. export class BasisTranscodeConfiguration {
  57084. /**
  57085. * Supported compression formats used to determine the supported output format of the transcoder
  57086. */
  57087. supportedCompressionFormats?: {
  57088. /**
  57089. * etc1 compression format
  57090. */
  57091. etc1?: boolean;
  57092. /**
  57093. * s3tc compression format
  57094. */
  57095. s3tc?: boolean;
  57096. /**
  57097. * pvrtc compression format
  57098. */
  57099. pvrtc?: boolean;
  57100. /**
  57101. * etc2 compression format
  57102. */
  57103. etc2?: boolean;
  57104. };
  57105. /**
  57106. * If mipmap levels should be loaded for transcoded images (Default: true)
  57107. */
  57108. loadMipmapLevels?: boolean;
  57109. /**
  57110. * Index of a single image to load (Default: all images)
  57111. */
  57112. loadSingleImage?: number;
  57113. }
  57114. /**
  57115. * Used to load .Basis files
  57116. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57117. */
  57118. export class BasisTools {
  57119. private static _IgnoreSupportedFormats;
  57120. /**
  57121. * URL to use when loading the basis transcoder
  57122. */
  57123. static JSModuleURL: string;
  57124. /**
  57125. * URL to use when loading the wasm module for the transcoder
  57126. */
  57127. static WasmModuleURL: string;
  57128. /**
  57129. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57130. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57131. * @returns internal format corresponding to the Basis format
  57132. */
  57133. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57134. private static _WorkerPromise;
  57135. private static _Worker;
  57136. private static _actionId;
  57137. private static _CreateWorkerAsync;
  57138. /**
  57139. * Transcodes a loaded image file to compressed pixel data
  57140. * @param imageData image data to transcode
  57141. * @param config configuration options for the transcoding
  57142. * @returns a promise resulting in the transcoded image
  57143. */
  57144. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57145. /**
  57146. * Loads a texture from the transcode result
  57147. * @param texture texture load to
  57148. * @param transcodeResult the result of transcoding the basis file to load from
  57149. */
  57150. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57151. }
  57152. }
  57153. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57154. import { Nullable } from "babylonjs/types";
  57155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57156. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57157. /**
  57158. * Loader for .basis file format
  57159. */
  57160. export class _BasisTextureLoader implements IInternalTextureLoader {
  57161. /**
  57162. * Defines whether the loader supports cascade loading the different faces.
  57163. */
  57164. readonly supportCascades: boolean;
  57165. /**
  57166. * This returns if the loader support the current file information.
  57167. * @param extension defines the file extension of the file being loaded
  57168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57169. * @param fallback defines the fallback internal texture if any
  57170. * @param isBase64 defines whether the texture is encoded as a base64
  57171. * @param isBuffer defines whether the texture data are stored as a buffer
  57172. * @returns true if the loader can load the specified file
  57173. */
  57174. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57175. /**
  57176. * Transform the url before loading if required.
  57177. * @param rootUrl the url of the texture
  57178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57179. * @returns the transformed texture
  57180. */
  57181. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57182. /**
  57183. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57184. * @param rootUrl the url of the texture
  57185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57186. * @returns the fallback texture
  57187. */
  57188. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57189. /**
  57190. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57191. * @param data contains the texture data
  57192. * @param texture defines the BabylonJS internal texture
  57193. * @param createPolynomials will be true if polynomials have been requested
  57194. * @param onLoad defines the callback to trigger once the texture is ready
  57195. * @param onError defines the callback to trigger in case of error
  57196. */
  57197. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57198. /**
  57199. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57200. * @param data contains the texture data
  57201. * @param texture defines the BabylonJS internal texture
  57202. * @param callback defines the method to call once ready to upload
  57203. */
  57204. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57205. }
  57206. }
  57207. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57208. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57209. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57210. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57211. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57212. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57213. }
  57214. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57215. import { Scene } from "babylonjs/scene";
  57216. import { Texture } from "babylonjs/Materials/Textures/texture";
  57217. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57218. /**
  57219. * 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.
  57220. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57221. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57222. */
  57223. export class CustomProceduralTexture extends ProceduralTexture {
  57224. private _animate;
  57225. private _time;
  57226. private _config;
  57227. private _texturePath;
  57228. /**
  57229. * Instantiates a new Custom Procedural Texture.
  57230. * 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.
  57231. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57232. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57233. * @param name Define the name of the texture
  57234. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57235. * @param size Define the size of the texture to create
  57236. * @param scene Define the scene the texture belongs to
  57237. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57238. * @param generateMipMaps Define if the texture should creates mip maps or not
  57239. */
  57240. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57241. private _loadJson;
  57242. /**
  57243. * Is the texture ready to be used ? (rendered at least once)
  57244. * @returns true if ready, otherwise, false.
  57245. */
  57246. isReady(): boolean;
  57247. /**
  57248. * Render the texture to its associated render target.
  57249. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57250. */
  57251. render(useCameraPostProcess?: boolean): void;
  57252. /**
  57253. * Update the list of dependant textures samplers in the shader.
  57254. */
  57255. updateTextures(): void;
  57256. /**
  57257. * Update the uniform values of the procedural texture in the shader.
  57258. */
  57259. updateShaderUniforms(): void;
  57260. /**
  57261. * Define if the texture animates or not.
  57262. */
  57263. get animate(): boolean;
  57264. set animate(value: boolean);
  57265. }
  57266. }
  57267. declare module "babylonjs/Shaders/noise.fragment" {
  57268. /** @hidden */
  57269. export var noisePixelShader: {
  57270. name: string;
  57271. shader: string;
  57272. };
  57273. }
  57274. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57275. import { Nullable } from "babylonjs/types";
  57276. import { Scene } from "babylonjs/scene";
  57277. import { Texture } from "babylonjs/Materials/Textures/texture";
  57278. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57279. import "babylonjs/Shaders/noise.fragment";
  57280. /**
  57281. * Class used to generate noise procedural textures
  57282. */
  57283. export class NoiseProceduralTexture extends ProceduralTexture {
  57284. private _time;
  57285. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57286. brightness: number;
  57287. /** Defines the number of octaves to process */
  57288. octaves: number;
  57289. /** Defines the level of persistence (0.8 by default) */
  57290. persistence: number;
  57291. /** Gets or sets animation speed factor (default is 1) */
  57292. animationSpeedFactor: number;
  57293. /**
  57294. * Creates a new NoiseProceduralTexture
  57295. * @param name defines the name fo the texture
  57296. * @param size defines the size of the texture (default is 256)
  57297. * @param scene defines the hosting scene
  57298. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57299. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57300. */
  57301. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57302. private _updateShaderUniforms;
  57303. protected _getDefines(): string;
  57304. /** Generate the current state of the procedural texture */
  57305. render(useCameraPostProcess?: boolean): void;
  57306. /**
  57307. * Serializes this noise procedural texture
  57308. * @returns a serialized noise procedural texture object
  57309. */
  57310. serialize(): any;
  57311. /**
  57312. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57313. * @param parsedTexture defines parsed texture data
  57314. * @param scene defines the current scene
  57315. * @param rootUrl defines the root URL containing noise procedural texture information
  57316. * @returns a parsed NoiseProceduralTexture
  57317. */
  57318. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57319. }
  57320. }
  57321. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57322. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57323. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57324. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57325. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57326. }
  57327. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57328. import { Nullable } from "babylonjs/types";
  57329. import { Scene } from "babylonjs/scene";
  57330. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57332. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57333. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57334. /**
  57335. * Raw cube texture where the raw buffers are passed in
  57336. */
  57337. export class RawCubeTexture extends CubeTexture {
  57338. /**
  57339. * Creates a cube texture where the raw buffers are passed in.
  57340. * @param scene defines the scene the texture is attached to
  57341. * @param data defines the array of data to use to create each face
  57342. * @param size defines the size of the textures
  57343. * @param format defines the format of the data
  57344. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57345. * @param generateMipMaps defines if the engine should generate the mip levels
  57346. * @param invertY defines if data must be stored with Y axis inverted
  57347. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57348. * @param compression defines the compression used (null by default)
  57349. */
  57350. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57351. /**
  57352. * Updates the raw cube texture.
  57353. * @param data defines the data to store
  57354. * @param format defines the data format
  57355. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57356. * @param invertY defines if data must be stored with Y axis inverted
  57357. * @param compression defines the compression used (null by default)
  57358. * @param level defines which level of the texture to update
  57359. */
  57360. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57361. /**
  57362. * Updates a raw cube texture with RGBD encoded data.
  57363. * @param data defines the array of data [mipmap][face] to use to create each face
  57364. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57365. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57366. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57367. * @returns a promsie that resolves when the operation is complete
  57368. */
  57369. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57370. /**
  57371. * Clones the raw cube texture.
  57372. * @return a new cube texture
  57373. */
  57374. clone(): CubeTexture;
  57375. /** @hidden */
  57376. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57377. }
  57378. }
  57379. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57380. import { Scene } from "babylonjs/scene";
  57381. import { Texture } from "babylonjs/Materials/Textures/texture";
  57382. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57383. /**
  57384. * Class used to store 3D textures containing user data
  57385. */
  57386. export class RawTexture3D extends Texture {
  57387. /** Gets or sets the texture format to use */
  57388. format: number;
  57389. private _engine;
  57390. /**
  57391. * Create a new RawTexture3D
  57392. * @param data defines the data of the texture
  57393. * @param width defines the width of the texture
  57394. * @param height defines the height of the texture
  57395. * @param depth defines the depth of the texture
  57396. * @param format defines the texture format to use
  57397. * @param scene defines the hosting scene
  57398. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57399. * @param invertY defines if texture must be stored with Y axis inverted
  57400. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57401. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57402. */
  57403. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57404. /** Gets or sets the texture format to use */
  57405. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57406. /**
  57407. * Update the texture with new data
  57408. * @param data defines the data to store in the texture
  57409. */
  57410. update(data: ArrayBufferView): void;
  57411. }
  57412. }
  57413. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57414. import { Scene } from "babylonjs/scene";
  57415. import { Texture } from "babylonjs/Materials/Textures/texture";
  57416. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57417. /**
  57418. * Class used to store 2D array textures containing user data
  57419. */
  57420. export class RawTexture2DArray extends Texture {
  57421. /** Gets or sets the texture format to use */
  57422. format: number;
  57423. private _engine;
  57424. /**
  57425. * Create a new RawTexture2DArray
  57426. * @param data defines the data of the texture
  57427. * @param width defines the width of the texture
  57428. * @param height defines the height of the texture
  57429. * @param depth defines the number of layers of the texture
  57430. * @param format defines the texture format to use
  57431. * @param scene defines the hosting scene
  57432. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57433. * @param invertY defines if texture must be stored with Y axis inverted
  57434. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57435. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57436. */
  57437. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57438. /** Gets or sets the texture format to use */
  57439. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57440. /**
  57441. * Update the texture with new data
  57442. * @param data defines the data to store in the texture
  57443. */
  57444. update(data: ArrayBufferView): void;
  57445. }
  57446. }
  57447. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57448. import { Scene } from "babylonjs/scene";
  57449. import { Plane } from "babylonjs/Maths/math.plane";
  57450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57451. /**
  57452. * Creates a refraction texture used by refraction channel of the standard material.
  57453. * It is like a mirror but to see through a material.
  57454. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57455. */
  57456. export class RefractionTexture extends RenderTargetTexture {
  57457. /**
  57458. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57459. * 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.
  57460. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57461. */
  57462. refractionPlane: Plane;
  57463. /**
  57464. * Define how deep under the surface we should see.
  57465. */
  57466. depth: number;
  57467. /**
  57468. * Creates a refraction texture used by refraction channel of the standard material.
  57469. * It is like a mirror but to see through a material.
  57470. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57471. * @param name Define the texture name
  57472. * @param size Define the size of the underlying texture
  57473. * @param scene Define the scene the refraction belongs to
  57474. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57475. */
  57476. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57477. /**
  57478. * Clone the refraction texture.
  57479. * @returns the cloned texture
  57480. */
  57481. clone(): RefractionTexture;
  57482. /**
  57483. * Serialize the texture to a JSON representation you could use in Parse later on
  57484. * @returns the serialized JSON representation
  57485. */
  57486. serialize(): any;
  57487. }
  57488. }
  57489. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57490. import { Nullable } from "babylonjs/types";
  57491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57492. import { Matrix } from "babylonjs/Maths/math.vector";
  57493. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57494. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57495. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57496. import { Scene } from "babylonjs/scene";
  57497. /**
  57498. * Defines the options related to the creation of an HtmlElementTexture
  57499. */
  57500. export interface IHtmlElementTextureOptions {
  57501. /**
  57502. * Defines wether mip maps should be created or not.
  57503. */
  57504. generateMipMaps?: boolean;
  57505. /**
  57506. * Defines the sampling mode of the texture.
  57507. */
  57508. samplingMode?: number;
  57509. /**
  57510. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57511. */
  57512. engine: Nullable<ThinEngine>;
  57513. /**
  57514. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57515. */
  57516. scene: Nullable<Scene>;
  57517. }
  57518. /**
  57519. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57520. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57521. * is automatically managed.
  57522. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57523. * in your application.
  57524. *
  57525. * As the update is not automatic, you need to call them manually.
  57526. */
  57527. export class HtmlElementTexture extends BaseTexture {
  57528. /**
  57529. * The texture URL.
  57530. */
  57531. element: HTMLVideoElement | HTMLCanvasElement;
  57532. private static readonly DefaultOptions;
  57533. private _textureMatrix;
  57534. private _engine;
  57535. private _isVideo;
  57536. private _generateMipMaps;
  57537. private _samplingMode;
  57538. /**
  57539. * Instantiates a HtmlElementTexture from the following parameters.
  57540. *
  57541. * @param name Defines the name of the texture
  57542. * @param element Defines the video or canvas the texture is filled with
  57543. * @param options Defines the other none mandatory texture creation options
  57544. */
  57545. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57546. private _createInternalTexture;
  57547. /**
  57548. * Returns the texture matrix used in most of the material.
  57549. */
  57550. getTextureMatrix(): Matrix;
  57551. /**
  57552. * Updates the content of the texture.
  57553. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57554. */
  57555. update(invertY?: Nullable<boolean>): void;
  57556. }
  57557. }
  57558. declare module "babylonjs/Materials/Textures/index" {
  57559. export * from "babylonjs/Materials/Textures/baseTexture";
  57560. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57561. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57562. export * from "babylonjs/Materials/Textures/cubeTexture";
  57563. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57564. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57565. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57566. export * from "babylonjs/Materials/Textures/internalTexture";
  57567. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57568. export * from "babylonjs/Materials/Textures/Loaders/index";
  57569. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57570. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57571. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57572. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57573. export * from "babylonjs/Materials/Textures/rawTexture";
  57574. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57575. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57576. export * from "babylonjs/Materials/Textures/refractionTexture";
  57577. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57578. export * from "babylonjs/Materials/Textures/texture";
  57579. export * from "babylonjs/Materials/Textures/videoTexture";
  57580. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57581. }
  57582. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57583. /**
  57584. * Enum used to define the target of a block
  57585. */
  57586. export enum NodeMaterialBlockTargets {
  57587. /** Vertex shader */
  57588. Vertex = 1,
  57589. /** Fragment shader */
  57590. Fragment = 2,
  57591. /** Neutral */
  57592. Neutral = 4,
  57593. /** Vertex and Fragment */
  57594. VertexAndFragment = 3
  57595. }
  57596. }
  57597. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57598. /**
  57599. * Defines the kind of connection point for node based material
  57600. */
  57601. export enum NodeMaterialBlockConnectionPointTypes {
  57602. /** Float */
  57603. Float = 1,
  57604. /** Int */
  57605. Int = 2,
  57606. /** Vector2 */
  57607. Vector2 = 4,
  57608. /** Vector3 */
  57609. Vector3 = 8,
  57610. /** Vector4 */
  57611. Vector4 = 16,
  57612. /** Color3 */
  57613. Color3 = 32,
  57614. /** Color4 */
  57615. Color4 = 64,
  57616. /** Matrix */
  57617. Matrix = 128,
  57618. /** Detect type based on connection */
  57619. AutoDetect = 1024,
  57620. /** Output type that will be defined by input type */
  57621. BasedOnInput = 2048
  57622. }
  57623. }
  57624. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57625. /**
  57626. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57627. */
  57628. export enum NodeMaterialBlockConnectionPointMode {
  57629. /** Value is an uniform */
  57630. Uniform = 0,
  57631. /** Value is a mesh attribute */
  57632. Attribute = 1,
  57633. /** Value is a varying between vertex and fragment shaders */
  57634. Varying = 2,
  57635. /** Mode is undefined */
  57636. Undefined = 3
  57637. }
  57638. }
  57639. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57640. /**
  57641. * Enum used to define system values e.g. values automatically provided by the system
  57642. */
  57643. export enum NodeMaterialSystemValues {
  57644. /** World */
  57645. World = 1,
  57646. /** View */
  57647. View = 2,
  57648. /** Projection */
  57649. Projection = 3,
  57650. /** ViewProjection */
  57651. ViewProjection = 4,
  57652. /** WorldView */
  57653. WorldView = 5,
  57654. /** WorldViewProjection */
  57655. WorldViewProjection = 6,
  57656. /** CameraPosition */
  57657. CameraPosition = 7,
  57658. /** Fog Color */
  57659. FogColor = 8,
  57660. /** Delta time */
  57661. DeltaTime = 9
  57662. }
  57663. }
  57664. declare module "babylonjs/Materials/Node/Enums/index" {
  57665. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57666. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57667. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57668. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57669. }
  57670. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57672. /**
  57673. * Root class for all node material optimizers
  57674. */
  57675. export class NodeMaterialOptimizer {
  57676. /**
  57677. * Function used to optimize a NodeMaterial graph
  57678. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57679. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57680. */
  57681. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57682. }
  57683. }
  57684. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57688. import { Scene } from "babylonjs/scene";
  57689. /**
  57690. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57691. */
  57692. export class TransformBlock extends NodeMaterialBlock {
  57693. /**
  57694. * Defines the value to use to complement W value to transform it to a Vector4
  57695. */
  57696. complementW: number;
  57697. /**
  57698. * Defines the value to use to complement z value to transform it to a Vector4
  57699. */
  57700. complementZ: number;
  57701. /**
  57702. * Creates a new TransformBlock
  57703. * @param name defines the block name
  57704. */
  57705. constructor(name: string);
  57706. /**
  57707. * Gets the current class name
  57708. * @returns the class name
  57709. */
  57710. getClassName(): string;
  57711. /**
  57712. * Gets the vector input
  57713. */
  57714. get vector(): NodeMaterialConnectionPoint;
  57715. /**
  57716. * Gets the output component
  57717. */
  57718. get output(): NodeMaterialConnectionPoint;
  57719. /**
  57720. * Gets the matrix transform input
  57721. */
  57722. get transform(): NodeMaterialConnectionPoint;
  57723. protected _buildBlock(state: NodeMaterialBuildState): this;
  57724. serialize(): any;
  57725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57726. protected _dumpPropertiesCode(): string;
  57727. }
  57728. }
  57729. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57733. /**
  57734. * Block used to output the vertex position
  57735. */
  57736. export class VertexOutputBlock extends NodeMaterialBlock {
  57737. /**
  57738. * Creates a new VertexOutputBlock
  57739. * @param name defines the block name
  57740. */
  57741. constructor(name: string);
  57742. /**
  57743. * Gets the current class name
  57744. * @returns the class name
  57745. */
  57746. getClassName(): string;
  57747. /**
  57748. * Gets the vector input component
  57749. */
  57750. get vector(): NodeMaterialConnectionPoint;
  57751. protected _buildBlock(state: NodeMaterialBuildState): this;
  57752. }
  57753. }
  57754. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57758. /**
  57759. * Block used to output the final color
  57760. */
  57761. export class FragmentOutputBlock extends NodeMaterialBlock {
  57762. /**
  57763. * Create a new FragmentOutputBlock
  57764. * @param name defines the block name
  57765. */
  57766. constructor(name: string);
  57767. /**
  57768. * Gets the current class name
  57769. * @returns the class name
  57770. */
  57771. getClassName(): string;
  57772. /**
  57773. * Gets the rgba input component
  57774. */
  57775. get rgba(): NodeMaterialConnectionPoint;
  57776. /**
  57777. * Gets the rgb input component
  57778. */
  57779. get rgb(): NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the a input component
  57782. */
  57783. get a(): NodeMaterialConnectionPoint;
  57784. protected _buildBlock(state: NodeMaterialBuildState): this;
  57785. }
  57786. }
  57787. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57793. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57794. import { Effect } from "babylonjs/Materials/effect";
  57795. import { Mesh } from "babylonjs/Meshes/mesh";
  57796. import { Nullable } from "babylonjs/types";
  57797. import { Scene } from "babylonjs/scene";
  57798. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57799. /**
  57800. * Block used to read a reflection texture from a sampler
  57801. */
  57802. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57803. private _define3DName;
  57804. private _defineCubicName;
  57805. private _defineExplicitName;
  57806. private _defineProjectionName;
  57807. private _defineLocalCubicName;
  57808. private _defineSphericalName;
  57809. private _definePlanarName;
  57810. private _defineEquirectangularName;
  57811. private _defineMirroredEquirectangularFixedName;
  57812. private _defineEquirectangularFixedName;
  57813. private _defineSkyboxName;
  57814. private _cubeSamplerName;
  57815. private _2DSamplerName;
  57816. private _positionUVWName;
  57817. private _directionWName;
  57818. private _reflectionCoordsName;
  57819. private _reflection2DCoordsName;
  57820. private _reflectionColorName;
  57821. private _reflectionMatrixName;
  57822. /**
  57823. * Gets or sets the texture associated with the node
  57824. */
  57825. texture: Nullable<BaseTexture>;
  57826. /**
  57827. * Create a new TextureBlock
  57828. * @param name defines the block name
  57829. */
  57830. constructor(name: string);
  57831. /**
  57832. * Gets the current class name
  57833. * @returns the class name
  57834. */
  57835. getClassName(): string;
  57836. /**
  57837. * Gets the world position input component
  57838. */
  57839. get position(): NodeMaterialConnectionPoint;
  57840. /**
  57841. * Gets the world position input component
  57842. */
  57843. get worldPosition(): NodeMaterialConnectionPoint;
  57844. /**
  57845. * Gets the world normal input component
  57846. */
  57847. get worldNormal(): NodeMaterialConnectionPoint;
  57848. /**
  57849. * Gets the world input component
  57850. */
  57851. get world(): NodeMaterialConnectionPoint;
  57852. /**
  57853. * Gets the camera (or eye) position component
  57854. */
  57855. get cameraPosition(): NodeMaterialConnectionPoint;
  57856. /**
  57857. * Gets the view input component
  57858. */
  57859. get view(): NodeMaterialConnectionPoint;
  57860. /**
  57861. * Gets the rgb output component
  57862. */
  57863. get rgb(): NodeMaterialConnectionPoint;
  57864. /**
  57865. * Gets the r output component
  57866. */
  57867. get r(): NodeMaterialConnectionPoint;
  57868. /**
  57869. * Gets the g output component
  57870. */
  57871. get g(): NodeMaterialConnectionPoint;
  57872. /**
  57873. * Gets the b output component
  57874. */
  57875. get b(): NodeMaterialConnectionPoint;
  57876. autoConfigure(material: NodeMaterial): void;
  57877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57878. isReady(): boolean;
  57879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57880. private _injectVertexCode;
  57881. private _writeOutput;
  57882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57883. protected _dumpPropertiesCode(): string;
  57884. serialize(): any;
  57885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57886. }
  57887. }
  57888. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57890. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57891. import { Scene } from "babylonjs/scene";
  57892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57893. import { Matrix } from "babylonjs/Maths/math.vector";
  57894. import { Mesh } from "babylonjs/Meshes/mesh";
  57895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57896. import { Observable } from "babylonjs/Misc/observable";
  57897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57898. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57899. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57900. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57901. import { Nullable } from "babylonjs/types";
  57902. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57903. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57904. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57905. /**
  57906. * Interface used to configure the node material editor
  57907. */
  57908. export interface INodeMaterialEditorOptions {
  57909. /** Define the URl to load node editor script */
  57910. editorURL?: string;
  57911. }
  57912. /** @hidden */
  57913. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57914. /** BONES */
  57915. NUM_BONE_INFLUENCERS: number;
  57916. BonesPerMesh: number;
  57917. BONETEXTURE: boolean;
  57918. /** MORPH TARGETS */
  57919. MORPHTARGETS: boolean;
  57920. MORPHTARGETS_NORMAL: boolean;
  57921. MORPHTARGETS_TANGENT: boolean;
  57922. MORPHTARGETS_UV: boolean;
  57923. NUM_MORPH_INFLUENCERS: number;
  57924. /** IMAGE PROCESSING */
  57925. IMAGEPROCESSING: boolean;
  57926. VIGNETTE: boolean;
  57927. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57928. VIGNETTEBLENDMODEOPAQUE: boolean;
  57929. TONEMAPPING: boolean;
  57930. TONEMAPPING_ACES: boolean;
  57931. CONTRAST: boolean;
  57932. EXPOSURE: boolean;
  57933. COLORCURVES: boolean;
  57934. COLORGRADING: boolean;
  57935. COLORGRADING3D: boolean;
  57936. SAMPLER3DGREENDEPTH: boolean;
  57937. SAMPLER3DBGRMAP: boolean;
  57938. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57939. /** MISC. */
  57940. BUMPDIRECTUV: number;
  57941. constructor();
  57942. setValue(name: string, value: boolean): void;
  57943. }
  57944. /**
  57945. * Class used to configure NodeMaterial
  57946. */
  57947. export interface INodeMaterialOptions {
  57948. /**
  57949. * Defines if blocks should emit comments
  57950. */
  57951. emitComments: boolean;
  57952. }
  57953. /**
  57954. * Class used to create a node based material built by assembling shader blocks
  57955. */
  57956. export class NodeMaterial extends PushMaterial {
  57957. private static _BuildIdGenerator;
  57958. private _options;
  57959. private _vertexCompilationState;
  57960. private _fragmentCompilationState;
  57961. private _sharedData;
  57962. private _buildId;
  57963. private _buildWasSuccessful;
  57964. private _cachedWorldViewMatrix;
  57965. private _cachedWorldViewProjectionMatrix;
  57966. private _optimizers;
  57967. private _animationFrame;
  57968. /** Define the URl to load node editor script */
  57969. static EditorURL: string;
  57970. private BJSNODEMATERIALEDITOR;
  57971. /** Get the inspector from bundle or global */
  57972. private _getGlobalNodeMaterialEditor;
  57973. /**
  57974. * Gets or sets data used by visual editor
  57975. * @see https://nme.babylonjs.com
  57976. */
  57977. editorData: any;
  57978. /**
  57979. * 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)
  57980. */
  57981. ignoreAlpha: boolean;
  57982. /**
  57983. * Defines the maximum number of lights that can be used in the material
  57984. */
  57985. maxSimultaneousLights: number;
  57986. /**
  57987. * Observable raised when the material is built
  57988. */
  57989. onBuildObservable: Observable<NodeMaterial>;
  57990. /**
  57991. * Gets or sets the root nodes of the material vertex shader
  57992. */
  57993. _vertexOutputNodes: NodeMaterialBlock[];
  57994. /**
  57995. * Gets or sets the root nodes of the material fragment (pixel) shader
  57996. */
  57997. _fragmentOutputNodes: NodeMaterialBlock[];
  57998. /** Gets or sets options to control the node material overall behavior */
  57999. get options(): INodeMaterialOptions;
  58000. set options(options: INodeMaterialOptions);
  58001. /**
  58002. * Default configuration related to image processing available in the standard Material.
  58003. */
  58004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58005. /**
  58006. * Gets the image processing configuration used either in this material.
  58007. */
  58008. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58009. /**
  58010. * Sets the Default image processing configuration used either in the this material.
  58011. *
  58012. * If sets to null, the scene one is in use.
  58013. */
  58014. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58015. /**
  58016. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58017. */
  58018. attachedBlocks: NodeMaterialBlock[];
  58019. /**
  58020. * Create a new node based material
  58021. * @param name defines the material name
  58022. * @param scene defines the hosting scene
  58023. * @param options defines creation option
  58024. */
  58025. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58026. /**
  58027. * Gets the current class name of the material e.g. "NodeMaterial"
  58028. * @returns the class name
  58029. */
  58030. getClassName(): string;
  58031. /**
  58032. * Keep track of the image processing observer to allow dispose and replace.
  58033. */
  58034. private _imageProcessingObserver;
  58035. /**
  58036. * Attaches a new image processing configuration to the Standard Material.
  58037. * @param configuration
  58038. */
  58039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58040. /**
  58041. * Get a block by its name
  58042. * @param name defines the name of the block to retrieve
  58043. * @returns the required block or null if not found
  58044. */
  58045. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58046. /**
  58047. * Get a block by its name
  58048. * @param predicate defines the predicate used to find the good candidate
  58049. * @returns the required block or null if not found
  58050. */
  58051. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58052. /**
  58053. * Get an input block by its name
  58054. * @param predicate defines the predicate used to find the good candidate
  58055. * @returns the required input block or null if not found
  58056. */
  58057. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58058. /**
  58059. * Gets the list of input blocks attached to this material
  58060. * @returns an array of InputBlocks
  58061. */
  58062. getInputBlocks(): InputBlock[];
  58063. /**
  58064. * Adds a new optimizer to the list of optimizers
  58065. * @param optimizer defines the optimizers to add
  58066. * @returns the current material
  58067. */
  58068. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58069. /**
  58070. * Remove an optimizer from the list of optimizers
  58071. * @param optimizer defines the optimizers to remove
  58072. * @returns the current material
  58073. */
  58074. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58075. /**
  58076. * Add a new block to the list of output nodes
  58077. * @param node defines the node to add
  58078. * @returns the current material
  58079. */
  58080. addOutputNode(node: NodeMaterialBlock): this;
  58081. /**
  58082. * Remove a block from the list of root nodes
  58083. * @param node defines the node to remove
  58084. * @returns the current material
  58085. */
  58086. removeOutputNode(node: NodeMaterialBlock): this;
  58087. private _addVertexOutputNode;
  58088. private _removeVertexOutputNode;
  58089. private _addFragmentOutputNode;
  58090. private _removeFragmentOutputNode;
  58091. /**
  58092. * Specifies if the material will require alpha blending
  58093. * @returns a boolean specifying if alpha blending is needed
  58094. */
  58095. needAlphaBlending(): boolean;
  58096. /**
  58097. * Specifies if this material should be rendered in alpha test mode
  58098. * @returns a boolean specifying if an alpha test is needed.
  58099. */
  58100. needAlphaTesting(): boolean;
  58101. private _initializeBlock;
  58102. private _resetDualBlocks;
  58103. /**
  58104. * Remove a block from the current node material
  58105. * @param block defines the block to remove
  58106. */
  58107. removeBlock(block: NodeMaterialBlock): void;
  58108. /**
  58109. * Build the material and generates the inner effect
  58110. * @param verbose defines if the build should log activity
  58111. */
  58112. build(verbose?: boolean): void;
  58113. /**
  58114. * Runs an otpimization phase to try to improve the shader code
  58115. */
  58116. optimize(): void;
  58117. private _prepareDefinesForAttributes;
  58118. /**
  58119. * Get if the submesh is ready to be used and all its information available.
  58120. * Child classes can use it to update shaders
  58121. * @param mesh defines the mesh to check
  58122. * @param subMesh defines which submesh to check
  58123. * @param useInstances specifies that instances should be used
  58124. * @returns a boolean indicating that the submesh is ready or not
  58125. */
  58126. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58127. /**
  58128. * Get a string representing the shaders built by the current node graph
  58129. */
  58130. get compiledShaders(): string;
  58131. /**
  58132. * Binds the world matrix to the material
  58133. * @param world defines the world transformation matrix
  58134. */
  58135. bindOnlyWorldMatrix(world: Matrix): void;
  58136. /**
  58137. * Binds the submesh to this material by preparing the effect and shader to draw
  58138. * @param world defines the world transformation matrix
  58139. * @param mesh defines the mesh containing the submesh
  58140. * @param subMesh defines the submesh to bind the material to
  58141. */
  58142. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58143. /**
  58144. * Gets the active textures from the material
  58145. * @returns an array of textures
  58146. */
  58147. getActiveTextures(): BaseTexture[];
  58148. /**
  58149. * Gets the list of texture blocks
  58150. * @returns an array of texture blocks
  58151. */
  58152. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58153. /**
  58154. * Specifies if the material uses a texture
  58155. * @param texture defines the texture to check against the material
  58156. * @returns a boolean specifying if the material uses the texture
  58157. */
  58158. hasTexture(texture: BaseTexture): boolean;
  58159. /**
  58160. * Disposes the material
  58161. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58162. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58163. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58164. */
  58165. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58166. /** Creates the node editor window. */
  58167. private _createNodeEditor;
  58168. /**
  58169. * Launch the node material editor
  58170. * @param config Define the configuration of the editor
  58171. * @return a promise fulfilled when the node editor is visible
  58172. */
  58173. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58174. /**
  58175. * Clear the current material
  58176. */
  58177. clear(): void;
  58178. /**
  58179. * Clear the current material and set it to a default state
  58180. */
  58181. setToDefault(): void;
  58182. /**
  58183. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58184. * @param url defines the url to load from
  58185. * @returns a promise that will fullfil when the material is fully loaded
  58186. */
  58187. loadAsync(url: string): Promise<void>;
  58188. private _gatherBlocks;
  58189. /**
  58190. * Generate a string containing the code declaration required to create an equivalent of this material
  58191. * @returns a string
  58192. */
  58193. generateCode(): string;
  58194. /**
  58195. * Serializes this material in a JSON representation
  58196. * @returns the serialized material object
  58197. */
  58198. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58199. private _restoreConnections;
  58200. /**
  58201. * Clear the current graph and load a new one from a serialization object
  58202. * @param source defines the JSON representation of the material
  58203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58204. */
  58205. loadFromSerialization(source: any, rootUrl?: string): void;
  58206. /**
  58207. * Creates a node material from parsed material data
  58208. * @param source defines the JSON representation of the material
  58209. * @param scene defines the hosting scene
  58210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58211. * @returns a new node material
  58212. */
  58213. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58214. /**
  58215. * Creates a new node material set to default basic configuration
  58216. * @param name defines the name of the material
  58217. * @param scene defines the hosting scene
  58218. * @returns a new NodeMaterial
  58219. */
  58220. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58221. }
  58222. }
  58223. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58226. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58229. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58230. import { Effect } from "babylonjs/Materials/effect";
  58231. import { Mesh } from "babylonjs/Meshes/mesh";
  58232. import { Nullable } from "babylonjs/types";
  58233. import { Texture } from "babylonjs/Materials/Textures/texture";
  58234. import { Scene } from "babylonjs/scene";
  58235. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58236. /**
  58237. * Block used to read a texture from a sampler
  58238. */
  58239. export class TextureBlock extends NodeMaterialBlock {
  58240. private _defineName;
  58241. private _linearDefineName;
  58242. private _tempTextureRead;
  58243. private _samplerName;
  58244. private _transformedUVName;
  58245. private _textureTransformName;
  58246. private _textureInfoName;
  58247. private _mainUVName;
  58248. private _mainUVDefineName;
  58249. /**
  58250. * Gets or sets the texture associated with the node
  58251. */
  58252. texture: Nullable<Texture>;
  58253. /**
  58254. * Create a new TextureBlock
  58255. * @param name defines the block name
  58256. */
  58257. constructor(name: string);
  58258. /**
  58259. * Gets the current class name
  58260. * @returns the class name
  58261. */
  58262. getClassName(): string;
  58263. /**
  58264. * Gets the uv input component
  58265. */
  58266. get uv(): NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the rgba output component
  58269. */
  58270. get rgba(): NodeMaterialConnectionPoint;
  58271. /**
  58272. * Gets the rgb output component
  58273. */
  58274. get rgb(): NodeMaterialConnectionPoint;
  58275. /**
  58276. * Gets the r output component
  58277. */
  58278. get r(): NodeMaterialConnectionPoint;
  58279. /**
  58280. * Gets the g output component
  58281. */
  58282. get g(): NodeMaterialConnectionPoint;
  58283. /**
  58284. * Gets the b output component
  58285. */
  58286. get b(): NodeMaterialConnectionPoint;
  58287. /**
  58288. * Gets the a output component
  58289. */
  58290. get a(): NodeMaterialConnectionPoint;
  58291. get target(): NodeMaterialBlockTargets;
  58292. autoConfigure(material: NodeMaterial): void;
  58293. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58294. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58295. private _getTextureBase;
  58296. isReady(): boolean;
  58297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58298. private get _isMixed();
  58299. private _injectVertexCode;
  58300. private _writeTextureRead;
  58301. private _writeOutput;
  58302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58303. protected _dumpPropertiesCode(): string;
  58304. serialize(): any;
  58305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58306. }
  58307. }
  58308. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58311. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58312. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58313. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58314. import { Scene } from "babylonjs/scene";
  58315. /**
  58316. * Class used to store shared data between 2 NodeMaterialBuildState
  58317. */
  58318. export class NodeMaterialBuildStateSharedData {
  58319. /**
  58320. * Gets the list of emitted varyings
  58321. */
  58322. temps: string[];
  58323. /**
  58324. * Gets the list of emitted varyings
  58325. */
  58326. varyings: string[];
  58327. /**
  58328. * Gets the varying declaration string
  58329. */
  58330. varyingDeclaration: string;
  58331. /**
  58332. * Input blocks
  58333. */
  58334. inputBlocks: InputBlock[];
  58335. /**
  58336. * Input blocks
  58337. */
  58338. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58339. /**
  58340. * Bindable blocks (Blocks that need to set data to the effect)
  58341. */
  58342. bindableBlocks: NodeMaterialBlock[];
  58343. /**
  58344. * List of blocks that can provide a compilation fallback
  58345. */
  58346. blocksWithFallbacks: NodeMaterialBlock[];
  58347. /**
  58348. * List of blocks that can provide a define update
  58349. */
  58350. blocksWithDefines: NodeMaterialBlock[];
  58351. /**
  58352. * List of blocks that can provide a repeatable content
  58353. */
  58354. repeatableContentBlocks: NodeMaterialBlock[];
  58355. /**
  58356. * List of blocks that can provide a dynamic list of uniforms
  58357. */
  58358. dynamicUniformBlocks: NodeMaterialBlock[];
  58359. /**
  58360. * List of blocks that can block the isReady function for the material
  58361. */
  58362. blockingBlocks: NodeMaterialBlock[];
  58363. /**
  58364. * Gets the list of animated inputs
  58365. */
  58366. animatedInputs: InputBlock[];
  58367. /**
  58368. * Build Id used to avoid multiple recompilations
  58369. */
  58370. buildId: number;
  58371. /** List of emitted variables */
  58372. variableNames: {
  58373. [key: string]: number;
  58374. };
  58375. /** List of emitted defines */
  58376. defineNames: {
  58377. [key: string]: number;
  58378. };
  58379. /** Should emit comments? */
  58380. emitComments: boolean;
  58381. /** Emit build activity */
  58382. verbose: boolean;
  58383. /** Gets or sets the hosting scene */
  58384. scene: Scene;
  58385. /**
  58386. * Gets the compilation hints emitted at compilation time
  58387. */
  58388. hints: {
  58389. needWorldViewMatrix: boolean;
  58390. needWorldViewProjectionMatrix: boolean;
  58391. needAlphaBlending: boolean;
  58392. needAlphaTesting: boolean;
  58393. };
  58394. /**
  58395. * List of compilation checks
  58396. */
  58397. checks: {
  58398. emitVertex: boolean;
  58399. emitFragment: boolean;
  58400. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58401. };
  58402. /** Creates a new shared data */
  58403. constructor();
  58404. /**
  58405. * Emits console errors and exceptions if there is a failing check
  58406. */
  58407. emitErrors(): void;
  58408. }
  58409. }
  58410. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58411. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58412. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58413. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58414. /**
  58415. * Class used to store node based material build state
  58416. */
  58417. export class NodeMaterialBuildState {
  58418. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58419. supportUniformBuffers: boolean;
  58420. /**
  58421. * Gets the list of emitted attributes
  58422. */
  58423. attributes: string[];
  58424. /**
  58425. * Gets the list of emitted uniforms
  58426. */
  58427. uniforms: string[];
  58428. /**
  58429. * Gets the list of emitted constants
  58430. */
  58431. constants: string[];
  58432. /**
  58433. * Gets the list of emitted samplers
  58434. */
  58435. samplers: string[];
  58436. /**
  58437. * Gets the list of emitted functions
  58438. */
  58439. functions: {
  58440. [key: string]: string;
  58441. };
  58442. /**
  58443. * Gets the list of emitted extensions
  58444. */
  58445. extensions: {
  58446. [key: string]: string;
  58447. };
  58448. /**
  58449. * Gets the target of the compilation state
  58450. */
  58451. target: NodeMaterialBlockTargets;
  58452. /**
  58453. * Gets the list of emitted counters
  58454. */
  58455. counters: {
  58456. [key: string]: number;
  58457. };
  58458. /**
  58459. * Shared data between multiple NodeMaterialBuildState instances
  58460. */
  58461. sharedData: NodeMaterialBuildStateSharedData;
  58462. /** @hidden */
  58463. _vertexState: NodeMaterialBuildState;
  58464. /** @hidden */
  58465. _attributeDeclaration: string;
  58466. /** @hidden */
  58467. _uniformDeclaration: string;
  58468. /** @hidden */
  58469. _constantDeclaration: string;
  58470. /** @hidden */
  58471. _samplerDeclaration: string;
  58472. /** @hidden */
  58473. _varyingTransfer: string;
  58474. private _repeatableContentAnchorIndex;
  58475. /** @hidden */
  58476. _builtCompilationString: string;
  58477. /**
  58478. * Gets the emitted compilation strings
  58479. */
  58480. compilationString: string;
  58481. /**
  58482. * Finalize the compilation strings
  58483. * @param state defines the current compilation state
  58484. */
  58485. finalize(state: NodeMaterialBuildState): void;
  58486. /** @hidden */
  58487. get _repeatableContentAnchor(): string;
  58488. /** @hidden */
  58489. _getFreeVariableName(prefix: string): string;
  58490. /** @hidden */
  58491. _getFreeDefineName(prefix: string): string;
  58492. /** @hidden */
  58493. _excludeVariableName(name: string): void;
  58494. /** @hidden */
  58495. _emit2DSampler(name: string): void;
  58496. /** @hidden */
  58497. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58498. /** @hidden */
  58499. _emitExtension(name: string, extension: string): void;
  58500. /** @hidden */
  58501. _emitFunction(name: string, code: string, comments: string): void;
  58502. /** @hidden */
  58503. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58504. replaceStrings?: {
  58505. search: RegExp;
  58506. replace: string;
  58507. }[];
  58508. repeatKey?: string;
  58509. }): string;
  58510. /** @hidden */
  58511. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58512. repeatKey?: string;
  58513. removeAttributes?: boolean;
  58514. removeUniforms?: boolean;
  58515. removeVaryings?: boolean;
  58516. removeIfDef?: boolean;
  58517. replaceStrings?: {
  58518. search: RegExp;
  58519. replace: string;
  58520. }[];
  58521. }, storeKey?: string): void;
  58522. /** @hidden */
  58523. _registerTempVariable(name: string): boolean;
  58524. /** @hidden */
  58525. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58526. /** @hidden */
  58527. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58528. /** @hidden */
  58529. _emitFloat(value: number): string;
  58530. }
  58531. }
  58532. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58533. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58535. import { Nullable } from "babylonjs/types";
  58536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58537. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58538. import { Effect } from "babylonjs/Materials/effect";
  58539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58540. import { Mesh } from "babylonjs/Meshes/mesh";
  58541. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58542. import { Scene } from "babylonjs/scene";
  58543. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58544. /**
  58545. * Defines a block that can be used inside a node based material
  58546. */
  58547. export class NodeMaterialBlock {
  58548. private _buildId;
  58549. private _buildTarget;
  58550. private _target;
  58551. private _isFinalMerger;
  58552. private _isInput;
  58553. protected _isUnique: boolean;
  58554. /** @hidden */
  58555. _codeVariableName: string;
  58556. /** @hidden */
  58557. _inputs: NodeMaterialConnectionPoint[];
  58558. /** @hidden */
  58559. _outputs: NodeMaterialConnectionPoint[];
  58560. /** @hidden */
  58561. _preparationId: number;
  58562. /**
  58563. * Gets or sets the name of the block
  58564. */
  58565. name: string;
  58566. /**
  58567. * Gets or sets the unique id of the node
  58568. */
  58569. uniqueId: number;
  58570. /**
  58571. * Gets or sets the comments associated with this block
  58572. */
  58573. comments: string;
  58574. /**
  58575. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58576. */
  58577. get isUnique(): boolean;
  58578. /**
  58579. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58580. */
  58581. get isFinalMerger(): boolean;
  58582. /**
  58583. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58584. */
  58585. get isInput(): boolean;
  58586. /**
  58587. * Gets or sets the build Id
  58588. */
  58589. get buildId(): number;
  58590. set buildId(value: number);
  58591. /**
  58592. * Gets or sets the target of the block
  58593. */
  58594. get target(): NodeMaterialBlockTargets;
  58595. set target(value: NodeMaterialBlockTargets);
  58596. /**
  58597. * Gets the list of input points
  58598. */
  58599. get inputs(): NodeMaterialConnectionPoint[];
  58600. /** Gets the list of output points */
  58601. get outputs(): NodeMaterialConnectionPoint[];
  58602. /**
  58603. * Find an input by its name
  58604. * @param name defines the name of the input to look for
  58605. * @returns the input or null if not found
  58606. */
  58607. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58608. /**
  58609. * Find an output by its name
  58610. * @param name defines the name of the outputto look for
  58611. * @returns the output or null if not found
  58612. */
  58613. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58614. /**
  58615. * Creates a new NodeMaterialBlock
  58616. * @param name defines the block name
  58617. * @param target defines the target of that block (Vertex by default)
  58618. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58619. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58620. */
  58621. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58622. /**
  58623. * Initialize the block and prepare the context for build
  58624. * @param state defines the state that will be used for the build
  58625. */
  58626. initialize(state: NodeMaterialBuildState): void;
  58627. /**
  58628. * Bind data to effect. Will only be called for blocks with isBindable === true
  58629. * @param effect defines the effect to bind data to
  58630. * @param nodeMaterial defines the hosting NodeMaterial
  58631. * @param mesh defines the mesh that will be rendered
  58632. */
  58633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58634. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58635. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58636. protected _writeFloat(value: number): string;
  58637. /**
  58638. * Gets the current class name e.g. "NodeMaterialBlock"
  58639. * @returns the class name
  58640. */
  58641. getClassName(): string;
  58642. /**
  58643. * Register a new input. Must be called inside a block constructor
  58644. * @param name defines the connection point name
  58645. * @param type defines the connection point type
  58646. * @param isOptional defines a boolean indicating that this input can be omitted
  58647. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58648. * @returns the current block
  58649. */
  58650. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58651. /**
  58652. * Register a new output. Must be called inside a block constructor
  58653. * @param name defines the connection point name
  58654. * @param type defines the connection point type
  58655. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58656. * @returns the current block
  58657. */
  58658. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58659. /**
  58660. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58661. * @param forOutput defines an optional connection point to check compatibility with
  58662. * @returns the first available input or null
  58663. */
  58664. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58665. /**
  58666. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58667. * @param forBlock defines an optional block to check compatibility with
  58668. * @returns the first available input or null
  58669. */
  58670. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58671. /**
  58672. * Gets the sibling of the given output
  58673. * @param current defines the current output
  58674. * @returns the next output in the list or null
  58675. */
  58676. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58677. /**
  58678. * Connect current block with another block
  58679. * @param other defines the block to connect with
  58680. * @param options define the various options to help pick the right connections
  58681. * @returns the current block
  58682. */
  58683. connectTo(other: NodeMaterialBlock, options?: {
  58684. input?: string;
  58685. output?: string;
  58686. outputSwizzle?: string;
  58687. }): this | undefined;
  58688. protected _buildBlock(state: NodeMaterialBuildState): void;
  58689. /**
  58690. * Add uniforms, samplers and uniform buffers at compilation time
  58691. * @param state defines the state to update
  58692. * @param nodeMaterial defines the node material requesting the update
  58693. * @param defines defines the material defines to update
  58694. * @param uniformBuffers defines the list of uniform buffer names
  58695. */
  58696. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58697. /**
  58698. * Add potential fallbacks if shader compilation fails
  58699. * @param mesh defines the mesh to be rendered
  58700. * @param fallbacks defines the current prioritized list of fallbacks
  58701. */
  58702. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58703. /**
  58704. * Initialize defines for shader compilation
  58705. * @param mesh defines the mesh to be rendered
  58706. * @param nodeMaterial defines the node material requesting the update
  58707. * @param defines defines the material defines to update
  58708. * @param useInstances specifies that instances should be used
  58709. */
  58710. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58711. /**
  58712. * Update defines for shader compilation
  58713. * @param mesh defines the mesh to be rendered
  58714. * @param nodeMaterial defines the node material requesting the update
  58715. * @param defines defines the material defines to update
  58716. * @param useInstances specifies that instances should be used
  58717. */
  58718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58719. /**
  58720. * Lets the block try to connect some inputs automatically
  58721. * @param material defines the hosting NodeMaterial
  58722. */
  58723. autoConfigure(material: NodeMaterial): void;
  58724. /**
  58725. * Function called when a block is declared as repeatable content generator
  58726. * @param vertexShaderState defines the current compilation state for the vertex shader
  58727. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58728. * @param mesh defines the mesh to be rendered
  58729. * @param defines defines the material defines to update
  58730. */
  58731. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58732. /**
  58733. * Checks if the block is ready
  58734. * @param mesh defines the mesh to be rendered
  58735. * @param nodeMaterial defines the node material requesting the update
  58736. * @param defines defines the material defines to update
  58737. * @param useInstances specifies that instances should be used
  58738. * @returns true if the block is ready
  58739. */
  58740. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58741. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58742. private _processBuild;
  58743. /**
  58744. * Compile the current node and generate the shader code
  58745. * @param state defines the current compilation state (uniforms, samplers, current string)
  58746. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58747. * @returns true if already built
  58748. */
  58749. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58750. protected _inputRename(name: string): string;
  58751. protected _outputRename(name: string): string;
  58752. protected _dumpPropertiesCode(): string;
  58753. /** @hidden */
  58754. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58755. /** @hidden */
  58756. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58757. /**
  58758. * Clone the current block to a new identical block
  58759. * @param scene defines the hosting scene
  58760. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58761. * @returns a copy of the current block
  58762. */
  58763. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58764. /**
  58765. * Serializes this block in a JSON representation
  58766. * @returns the serialized block object
  58767. */
  58768. serialize(): any;
  58769. /** @hidden */
  58770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58771. /**
  58772. * Release resources
  58773. */
  58774. dispose(): void;
  58775. }
  58776. }
  58777. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58778. /**
  58779. * Enum defining the type of animations supported by InputBlock
  58780. */
  58781. export enum AnimatedInputBlockTypes {
  58782. /** No animation */
  58783. None = 0,
  58784. /** Time based animation. Will only work for floats */
  58785. Time = 1
  58786. }
  58787. }
  58788. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58790. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58791. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58792. import { Nullable } from "babylonjs/types";
  58793. import { Effect } from "babylonjs/Materials/effect";
  58794. import { Matrix } from "babylonjs/Maths/math.vector";
  58795. import { Scene } from "babylonjs/scene";
  58796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58798. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58799. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58800. /**
  58801. * Block used to expose an input value
  58802. */
  58803. export class InputBlock extends NodeMaterialBlock {
  58804. private _mode;
  58805. private _associatedVariableName;
  58806. private _storedValue;
  58807. private _valueCallback;
  58808. private _type;
  58809. private _animationType;
  58810. /** Gets or set a value used to limit the range of float values */
  58811. min: number;
  58812. /** Gets or set a value used to limit the range of float values */
  58813. max: number;
  58814. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58815. matrixMode: number;
  58816. /** @hidden */
  58817. _systemValue: Nullable<NodeMaterialSystemValues>;
  58818. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58819. visibleInInspector: boolean;
  58820. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58821. isConstant: boolean;
  58822. /** Gets or sets the group to use to display this block in the Inspector */
  58823. groupInInspector: string;
  58824. /**
  58825. * Gets or sets the connection point type (default is float)
  58826. */
  58827. get type(): NodeMaterialBlockConnectionPointTypes;
  58828. /**
  58829. * Creates a new InputBlock
  58830. * @param name defines the block name
  58831. * @param target defines the target of that block (Vertex by default)
  58832. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58833. */
  58834. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58835. /**
  58836. * Gets the output component
  58837. */
  58838. get output(): NodeMaterialConnectionPoint;
  58839. /**
  58840. * Set the source of this connection point to a vertex attribute
  58841. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58842. * @returns the current connection point
  58843. */
  58844. setAsAttribute(attributeName?: string): InputBlock;
  58845. /**
  58846. * Set the source of this connection point to a system value
  58847. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58848. * @returns the current connection point
  58849. */
  58850. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58851. /**
  58852. * Gets or sets the value of that point.
  58853. * Please note that this value will be ignored if valueCallback is defined
  58854. */
  58855. get value(): any;
  58856. set value(value: any);
  58857. /**
  58858. * Gets or sets a callback used to get the value of that point.
  58859. * Please note that setting this value will force the connection point to ignore the value property
  58860. */
  58861. get valueCallback(): () => any;
  58862. set valueCallback(value: () => any);
  58863. /**
  58864. * Gets or sets the associated variable name in the shader
  58865. */
  58866. get associatedVariableName(): string;
  58867. set associatedVariableName(value: string);
  58868. /** Gets or sets the type of animation applied to the input */
  58869. get animationType(): AnimatedInputBlockTypes;
  58870. set animationType(value: AnimatedInputBlockTypes);
  58871. /**
  58872. * Gets a boolean indicating that this connection point not defined yet
  58873. */
  58874. get isUndefined(): boolean;
  58875. /**
  58876. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58877. * In this case the connection point name must be the name of the uniform to use.
  58878. * Can only be set on inputs
  58879. */
  58880. get isUniform(): boolean;
  58881. set isUniform(value: boolean);
  58882. /**
  58883. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58884. * In this case the connection point name must be the name of the attribute to use
  58885. * Can only be set on inputs
  58886. */
  58887. get isAttribute(): boolean;
  58888. set isAttribute(value: boolean);
  58889. /**
  58890. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58891. * Can only be set on exit points
  58892. */
  58893. get isVarying(): boolean;
  58894. set isVarying(value: boolean);
  58895. /**
  58896. * Gets a boolean indicating that the current connection point is a system value
  58897. */
  58898. get isSystemValue(): boolean;
  58899. /**
  58900. * Gets or sets the current well known value or null if not defined as a system value
  58901. */
  58902. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58903. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58904. /**
  58905. * Gets the current class name
  58906. * @returns the class name
  58907. */
  58908. getClassName(): string;
  58909. /**
  58910. * Animate the input if animationType !== None
  58911. * @param scene defines the rendering scene
  58912. */
  58913. animate(scene: Scene): void;
  58914. private _emitDefine;
  58915. initialize(state: NodeMaterialBuildState): void;
  58916. /**
  58917. * Set the input block to its default value (based on its type)
  58918. */
  58919. setDefaultValue(): void;
  58920. private _emitConstant;
  58921. private _emit;
  58922. /** @hidden */
  58923. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58924. /** @hidden */
  58925. _transmit(effect: Effect, scene: Scene): void;
  58926. protected _buildBlock(state: NodeMaterialBuildState): void;
  58927. protected _dumpPropertiesCode(): string;
  58928. serialize(): any;
  58929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58930. }
  58931. }
  58932. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58933. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58934. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58935. import { Nullable } from "babylonjs/types";
  58936. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58937. import { Observable } from "babylonjs/Misc/observable";
  58938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58939. /**
  58940. * Enum used to define the compatibility state between two connection points
  58941. */
  58942. export enum NodeMaterialConnectionPointCompatibilityStates {
  58943. /** Points are compatibles */
  58944. Compatible = 0,
  58945. /** Points are incompatible because of their types */
  58946. TypeIncompatible = 1,
  58947. /** Points are incompatible because of their targets (vertex vs fragment) */
  58948. TargetIncompatible = 2
  58949. }
  58950. /**
  58951. * Defines the direction of a connection point
  58952. */
  58953. export enum NodeMaterialConnectionPointDirection {
  58954. /** Input */
  58955. Input = 0,
  58956. /** Output */
  58957. Output = 1
  58958. }
  58959. /**
  58960. * Defines a connection point for a block
  58961. */
  58962. export class NodeMaterialConnectionPoint {
  58963. /** @hidden */
  58964. _ownerBlock: NodeMaterialBlock;
  58965. /** @hidden */
  58966. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58967. private _endpoints;
  58968. private _associatedVariableName;
  58969. private _direction;
  58970. /** @hidden */
  58971. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58972. /** @hidden */
  58973. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58974. private _type;
  58975. /** @hidden */
  58976. _enforceAssociatedVariableName: boolean;
  58977. /** Gets the direction of the point */
  58978. get direction(): NodeMaterialConnectionPointDirection;
  58979. /**
  58980. * Gets or sets the additional types supported by this connection point
  58981. */
  58982. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58983. /**
  58984. * Gets or sets the additional types excluded by this connection point
  58985. */
  58986. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58987. /**
  58988. * Observable triggered when this point is connected
  58989. */
  58990. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58991. /**
  58992. * Gets or sets the associated variable name in the shader
  58993. */
  58994. get associatedVariableName(): string;
  58995. set associatedVariableName(value: string);
  58996. /**
  58997. * Gets or sets the connection point type (default is float)
  58998. */
  58999. get type(): NodeMaterialBlockConnectionPointTypes;
  59000. set type(value: NodeMaterialBlockConnectionPointTypes);
  59001. /**
  59002. * Gets or sets the connection point name
  59003. */
  59004. name: string;
  59005. /**
  59006. * Gets or sets a boolean indicating that this connection point can be omitted
  59007. */
  59008. isOptional: boolean;
  59009. /**
  59010. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59011. */
  59012. define: string;
  59013. /** @hidden */
  59014. _prioritizeVertex: boolean;
  59015. private _target;
  59016. /** Gets or sets the target of that connection point */
  59017. get target(): NodeMaterialBlockTargets;
  59018. set target(value: NodeMaterialBlockTargets);
  59019. /**
  59020. * Gets a boolean indicating that the current point is connected
  59021. */
  59022. get isConnected(): boolean;
  59023. /**
  59024. * Gets a boolean indicating that the current point is connected to an input block
  59025. */
  59026. get isConnectedToInputBlock(): boolean;
  59027. /**
  59028. * Gets a the connected input block (if any)
  59029. */
  59030. get connectInputBlock(): Nullable<InputBlock>;
  59031. /** Get the other side of the connection (if any) */
  59032. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59033. /** Get the block that owns this connection point */
  59034. get ownerBlock(): NodeMaterialBlock;
  59035. /** Get the block connected on the other side of this connection (if any) */
  59036. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59037. /** Get the block connected on the endpoints of this connection (if any) */
  59038. get connectedBlocks(): Array<NodeMaterialBlock>;
  59039. /** Gets the list of connected endpoints */
  59040. get endpoints(): NodeMaterialConnectionPoint[];
  59041. /** Gets a boolean indicating if that output point is connected to at least one input */
  59042. get hasEndpoints(): boolean;
  59043. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59044. get isConnectedInVertexShader(): boolean;
  59045. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59046. get isConnectedInFragmentShader(): boolean;
  59047. /**
  59048. * Creates a new connection point
  59049. * @param name defines the connection point name
  59050. * @param ownerBlock defines the block hosting this connection point
  59051. * @param direction defines the direction of the connection point
  59052. */
  59053. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59054. /**
  59055. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59056. * @returns the class name
  59057. */
  59058. getClassName(): string;
  59059. /**
  59060. * Gets a boolean indicating if the current point can be connected to another point
  59061. * @param connectionPoint defines the other connection point
  59062. * @returns a boolean
  59063. */
  59064. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59065. /**
  59066. * Gets a number indicating if the current point can be connected to another point
  59067. * @param connectionPoint defines the other connection point
  59068. * @returns a number defining the compatibility state
  59069. */
  59070. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59071. /**
  59072. * Connect this point to another connection point
  59073. * @param connectionPoint defines the other connection point
  59074. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59075. * @returns the current connection point
  59076. */
  59077. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59078. /**
  59079. * Disconnect this point from one of his endpoint
  59080. * @param endpoint defines the other connection point
  59081. * @returns the current connection point
  59082. */
  59083. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Serializes this point in a JSON representation
  59086. * @returns the serialized point object
  59087. */
  59088. serialize(): any;
  59089. /**
  59090. * Release resources
  59091. */
  59092. dispose(): void;
  59093. }
  59094. }
  59095. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59099. import { Mesh } from "babylonjs/Meshes/mesh";
  59100. import { Effect } from "babylonjs/Materials/effect";
  59101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59102. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59103. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59104. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59105. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59106. /**
  59107. * Block used to add support for vertex skinning (bones)
  59108. */
  59109. export class BonesBlock extends NodeMaterialBlock {
  59110. /**
  59111. * Creates a new BonesBlock
  59112. * @param name defines the block name
  59113. */
  59114. constructor(name: string);
  59115. /**
  59116. * Initialize the block and prepare the context for build
  59117. * @param state defines the state that will be used for the build
  59118. */
  59119. initialize(state: NodeMaterialBuildState): void;
  59120. /**
  59121. * Gets the current class name
  59122. * @returns the class name
  59123. */
  59124. getClassName(): string;
  59125. /**
  59126. * Gets the matrix indices input component
  59127. */
  59128. get matricesIndices(): NodeMaterialConnectionPoint;
  59129. /**
  59130. * Gets the matrix weights input component
  59131. */
  59132. get matricesWeights(): NodeMaterialConnectionPoint;
  59133. /**
  59134. * Gets the extra matrix indices input component
  59135. */
  59136. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59137. /**
  59138. * Gets the extra matrix weights input component
  59139. */
  59140. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59141. /**
  59142. * Gets the world input component
  59143. */
  59144. get world(): NodeMaterialConnectionPoint;
  59145. /**
  59146. * Gets the output component
  59147. */
  59148. get output(): NodeMaterialConnectionPoint;
  59149. autoConfigure(material: NodeMaterial): void;
  59150. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this;
  59154. }
  59155. }
  59156. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59161. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59162. /**
  59163. * Block used to add support for instances
  59164. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59165. */
  59166. export class InstancesBlock extends NodeMaterialBlock {
  59167. /**
  59168. * Creates a new InstancesBlock
  59169. * @param name defines the block name
  59170. */
  59171. constructor(name: string);
  59172. /**
  59173. * Gets the current class name
  59174. * @returns the class name
  59175. */
  59176. getClassName(): string;
  59177. /**
  59178. * Gets the first world row input component
  59179. */
  59180. get world0(): NodeMaterialConnectionPoint;
  59181. /**
  59182. * Gets the second world row input component
  59183. */
  59184. get world1(): NodeMaterialConnectionPoint;
  59185. /**
  59186. * Gets the third world row input component
  59187. */
  59188. get world2(): NodeMaterialConnectionPoint;
  59189. /**
  59190. * Gets the forth world row input component
  59191. */
  59192. get world3(): NodeMaterialConnectionPoint;
  59193. /**
  59194. * Gets the world input component
  59195. */
  59196. get world(): NodeMaterialConnectionPoint;
  59197. /**
  59198. * Gets the output component
  59199. */
  59200. get output(): NodeMaterialConnectionPoint;
  59201. autoConfigure(material: NodeMaterial): void;
  59202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59203. protected _buildBlock(state: NodeMaterialBuildState): this;
  59204. }
  59205. }
  59206. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59211. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59212. import { Effect } from "babylonjs/Materials/effect";
  59213. import { Mesh } from "babylonjs/Meshes/mesh";
  59214. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59215. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59216. /**
  59217. * Block used to add morph targets support to vertex shader
  59218. */
  59219. export class MorphTargetsBlock extends NodeMaterialBlock {
  59220. private _repeatableContentAnchor;
  59221. private _repeatebleContentGenerated;
  59222. /**
  59223. * Create a new MorphTargetsBlock
  59224. * @param name defines the block name
  59225. */
  59226. constructor(name: string);
  59227. /**
  59228. * Gets the current class name
  59229. * @returns the class name
  59230. */
  59231. getClassName(): string;
  59232. /**
  59233. * Gets the position input component
  59234. */
  59235. get position(): NodeMaterialConnectionPoint;
  59236. /**
  59237. * Gets the normal input component
  59238. */
  59239. get normal(): NodeMaterialConnectionPoint;
  59240. /**
  59241. * Gets the tangent input component
  59242. */
  59243. get tangent(): NodeMaterialConnectionPoint;
  59244. /**
  59245. * Gets the tangent input component
  59246. */
  59247. get uv(): NodeMaterialConnectionPoint;
  59248. /**
  59249. * Gets the position output component
  59250. */
  59251. get positionOutput(): NodeMaterialConnectionPoint;
  59252. /**
  59253. * Gets the normal output component
  59254. */
  59255. get normalOutput(): NodeMaterialConnectionPoint;
  59256. /**
  59257. * Gets the tangent output component
  59258. */
  59259. get tangentOutput(): NodeMaterialConnectionPoint;
  59260. /**
  59261. * Gets the tangent output component
  59262. */
  59263. get uvOutput(): NodeMaterialConnectionPoint;
  59264. initialize(state: NodeMaterialBuildState): void;
  59265. autoConfigure(material: NodeMaterial): void;
  59266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59267. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59268. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59269. protected _buildBlock(state: NodeMaterialBuildState): this;
  59270. }
  59271. }
  59272. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59273. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59274. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59276. import { Nullable } from "babylonjs/types";
  59277. import { Scene } from "babylonjs/scene";
  59278. import { Effect } from "babylonjs/Materials/effect";
  59279. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59280. import { Mesh } from "babylonjs/Meshes/mesh";
  59281. import { Light } from "babylonjs/Lights/light";
  59282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59283. /**
  59284. * Block used to get data information from a light
  59285. */
  59286. export class LightInformationBlock extends NodeMaterialBlock {
  59287. private _lightDataUniformName;
  59288. private _lightColorUniformName;
  59289. private _lightTypeDefineName;
  59290. /**
  59291. * Gets or sets the light associated with this block
  59292. */
  59293. light: Nullable<Light>;
  59294. /**
  59295. * Creates a new LightInformationBlock
  59296. * @param name defines the block name
  59297. */
  59298. constructor(name: string);
  59299. /**
  59300. * Gets the current class name
  59301. * @returns the class name
  59302. */
  59303. getClassName(): string;
  59304. /**
  59305. * Gets the world position input component
  59306. */
  59307. get worldPosition(): NodeMaterialConnectionPoint;
  59308. /**
  59309. * Gets the direction output component
  59310. */
  59311. get direction(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the direction output component
  59314. */
  59315. get color(): NodeMaterialConnectionPoint;
  59316. /**
  59317. * Gets the direction output component
  59318. */
  59319. get intensity(): NodeMaterialConnectionPoint;
  59320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59322. protected _buildBlock(state: NodeMaterialBuildState): this;
  59323. serialize(): any;
  59324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59325. }
  59326. }
  59327. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59328. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59329. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59330. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59331. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59332. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59333. }
  59334. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59339. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59340. import { Effect } from "babylonjs/Materials/effect";
  59341. import { Mesh } from "babylonjs/Meshes/mesh";
  59342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59343. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59344. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59345. /**
  59346. * Block used to add image processing support to fragment shader
  59347. */
  59348. export class ImageProcessingBlock extends NodeMaterialBlock {
  59349. /**
  59350. * Create a new ImageProcessingBlock
  59351. * @param name defines the block name
  59352. */
  59353. constructor(name: string);
  59354. /**
  59355. * Gets the current class name
  59356. * @returns the class name
  59357. */
  59358. getClassName(): string;
  59359. /**
  59360. * Gets the color input component
  59361. */
  59362. get color(): NodeMaterialConnectionPoint;
  59363. /**
  59364. * Gets the output component
  59365. */
  59366. get output(): NodeMaterialConnectionPoint;
  59367. /**
  59368. * Initialize the block and prepare the context for build
  59369. * @param state defines the state that will be used for the build
  59370. */
  59371. initialize(state: NodeMaterialBuildState): void;
  59372. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59375. protected _buildBlock(state: NodeMaterialBuildState): this;
  59376. }
  59377. }
  59378. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59382. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59384. import { Effect } from "babylonjs/Materials/effect";
  59385. import { Mesh } from "babylonjs/Meshes/mesh";
  59386. import { Scene } from "babylonjs/scene";
  59387. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59388. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59389. /**
  59390. * Block used to pertub normals based on a normal map
  59391. */
  59392. export class PerturbNormalBlock extends NodeMaterialBlock {
  59393. private _tangentSpaceParameterName;
  59394. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59395. invertX: boolean;
  59396. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59397. invertY: boolean;
  59398. /**
  59399. * Create a new PerturbNormalBlock
  59400. * @param name defines the block name
  59401. */
  59402. constructor(name: string);
  59403. /**
  59404. * Gets the current class name
  59405. * @returns the class name
  59406. */
  59407. getClassName(): string;
  59408. /**
  59409. * Gets the world position input component
  59410. */
  59411. get worldPosition(): NodeMaterialConnectionPoint;
  59412. /**
  59413. * Gets the world normal input component
  59414. */
  59415. get worldNormal(): NodeMaterialConnectionPoint;
  59416. /**
  59417. * Gets the uv input component
  59418. */
  59419. get uv(): NodeMaterialConnectionPoint;
  59420. /**
  59421. * Gets the normal map color input component
  59422. */
  59423. get normalMapColor(): NodeMaterialConnectionPoint;
  59424. /**
  59425. * Gets the strength input component
  59426. */
  59427. get strength(): NodeMaterialConnectionPoint;
  59428. /**
  59429. * Gets the output component
  59430. */
  59431. get output(): NodeMaterialConnectionPoint;
  59432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59434. autoConfigure(material: NodeMaterial): void;
  59435. protected _buildBlock(state: NodeMaterialBuildState): this;
  59436. protected _dumpPropertiesCode(): string;
  59437. serialize(): any;
  59438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59439. }
  59440. }
  59441. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59445. /**
  59446. * Block used to discard a pixel if a value is smaller than a cutoff
  59447. */
  59448. export class DiscardBlock extends NodeMaterialBlock {
  59449. /**
  59450. * Create a new DiscardBlock
  59451. * @param name defines the block name
  59452. */
  59453. constructor(name: string);
  59454. /**
  59455. * Gets the current class name
  59456. * @returns the class name
  59457. */
  59458. getClassName(): string;
  59459. /**
  59460. * Gets the color input component
  59461. */
  59462. get value(): NodeMaterialConnectionPoint;
  59463. /**
  59464. * Gets the cutoff input component
  59465. */
  59466. get cutoff(): NodeMaterialConnectionPoint;
  59467. protected _buildBlock(state: NodeMaterialBuildState): this;
  59468. }
  59469. }
  59470. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59474. /**
  59475. * Block used to test if the fragment shader is front facing
  59476. */
  59477. export class FrontFacingBlock extends NodeMaterialBlock {
  59478. /**
  59479. * Creates a new FrontFacingBlock
  59480. * @param name defines the block name
  59481. */
  59482. constructor(name: string);
  59483. /**
  59484. * Gets the current class name
  59485. * @returns the class name
  59486. */
  59487. getClassName(): string;
  59488. /**
  59489. * Gets the output component
  59490. */
  59491. get output(): NodeMaterialConnectionPoint;
  59492. protected _buildBlock(state: NodeMaterialBuildState): this;
  59493. }
  59494. }
  59495. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59499. /**
  59500. * Block used to get the derivative value on x and y of a given input
  59501. */
  59502. export class DerivativeBlock extends NodeMaterialBlock {
  59503. /**
  59504. * Create a new DerivativeBlock
  59505. * @param name defines the block name
  59506. */
  59507. constructor(name: string);
  59508. /**
  59509. * Gets the current class name
  59510. * @returns the class name
  59511. */
  59512. getClassName(): string;
  59513. /**
  59514. * Gets the input component
  59515. */
  59516. get input(): NodeMaterialConnectionPoint;
  59517. /**
  59518. * Gets the derivative output on x
  59519. */
  59520. get dx(): NodeMaterialConnectionPoint;
  59521. /**
  59522. * Gets the derivative output on y
  59523. */
  59524. get dy(): NodeMaterialConnectionPoint;
  59525. protected _buildBlock(state: NodeMaterialBuildState): this;
  59526. }
  59527. }
  59528. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59529. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59530. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59531. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59532. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59533. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59534. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59535. }
  59536. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59539. import { Mesh } from "babylonjs/Meshes/mesh";
  59540. import { Effect } from "babylonjs/Materials/effect";
  59541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59543. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59544. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59545. /**
  59546. * Block used to add support for scene fog
  59547. */
  59548. export class FogBlock extends NodeMaterialBlock {
  59549. private _fogDistanceName;
  59550. private _fogParameters;
  59551. /**
  59552. * Create a new FogBlock
  59553. * @param name defines the block name
  59554. */
  59555. constructor(name: string);
  59556. /**
  59557. * Gets the current class name
  59558. * @returns the class name
  59559. */
  59560. getClassName(): string;
  59561. /**
  59562. * Gets the world position input component
  59563. */
  59564. get worldPosition(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the view input component
  59567. */
  59568. get view(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the color input component
  59571. */
  59572. get input(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the fog color input component
  59575. */
  59576. get fogColor(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the output component
  59579. */
  59580. get output(): NodeMaterialConnectionPoint;
  59581. autoConfigure(material: NodeMaterial): void;
  59582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59584. protected _buildBlock(state: NodeMaterialBuildState): this;
  59585. }
  59586. }
  59587. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59592. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59593. import { Effect } from "babylonjs/Materials/effect";
  59594. import { Mesh } from "babylonjs/Meshes/mesh";
  59595. import { Light } from "babylonjs/Lights/light";
  59596. import { Nullable } from "babylonjs/types";
  59597. import { Scene } from "babylonjs/scene";
  59598. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59599. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59600. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59601. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59602. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59603. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59604. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59605. /**
  59606. * Block used to add light in the fragment shader
  59607. */
  59608. export class LightBlock extends NodeMaterialBlock {
  59609. private _lightId;
  59610. /**
  59611. * Gets or sets the light associated with this block
  59612. */
  59613. light: Nullable<Light>;
  59614. /**
  59615. * Create a new LightBlock
  59616. * @param name defines the block name
  59617. */
  59618. constructor(name: string);
  59619. /**
  59620. * Gets the current class name
  59621. * @returns the class name
  59622. */
  59623. getClassName(): string;
  59624. /**
  59625. * Gets the world position input component
  59626. */
  59627. get worldPosition(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the world normal input component
  59630. */
  59631. get worldNormal(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the camera (or eye) position component
  59634. */
  59635. get cameraPosition(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the glossiness component
  59638. */
  59639. get glossiness(): NodeMaterialConnectionPoint;
  59640. /**
  59641. * Gets the glossinness power component
  59642. */
  59643. get glossPower(): NodeMaterialConnectionPoint;
  59644. /**
  59645. * Gets the diffuse color component
  59646. */
  59647. get diffuseColor(): NodeMaterialConnectionPoint;
  59648. /**
  59649. * Gets the specular color component
  59650. */
  59651. get specularColor(): NodeMaterialConnectionPoint;
  59652. /**
  59653. * Gets the diffuse output component
  59654. */
  59655. get diffuseOutput(): NodeMaterialConnectionPoint;
  59656. /**
  59657. * Gets the specular output component
  59658. */
  59659. get specularOutput(): NodeMaterialConnectionPoint;
  59660. /**
  59661. * Gets the shadow output component
  59662. */
  59663. get shadow(): NodeMaterialConnectionPoint;
  59664. autoConfigure(material: NodeMaterial): void;
  59665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59666. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59667. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59668. private _injectVertexCode;
  59669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59670. serialize(): any;
  59671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59672. }
  59673. }
  59674. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59675. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59676. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59677. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59678. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59679. }
  59680. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59681. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59682. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59683. }
  59684. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59688. /**
  59689. * Block used to multiply 2 values
  59690. */
  59691. export class MultiplyBlock extends NodeMaterialBlock {
  59692. /**
  59693. * Creates a new MultiplyBlock
  59694. * @param name defines the block name
  59695. */
  59696. constructor(name: string);
  59697. /**
  59698. * Gets the current class name
  59699. * @returns the class name
  59700. */
  59701. getClassName(): string;
  59702. /**
  59703. * Gets the left operand input component
  59704. */
  59705. get left(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the right operand input component
  59708. */
  59709. get right(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the output component
  59712. */
  59713. get output(): NodeMaterialConnectionPoint;
  59714. protected _buildBlock(state: NodeMaterialBuildState): this;
  59715. }
  59716. }
  59717. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59721. /**
  59722. * Block used to add 2 vectors
  59723. */
  59724. export class AddBlock extends NodeMaterialBlock {
  59725. /**
  59726. * Creates a new AddBlock
  59727. * @param name defines the block name
  59728. */
  59729. constructor(name: string);
  59730. /**
  59731. * Gets the current class name
  59732. * @returns the class name
  59733. */
  59734. getClassName(): string;
  59735. /**
  59736. * Gets the left operand input component
  59737. */
  59738. get left(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the right operand input component
  59741. */
  59742. get right(): NodeMaterialConnectionPoint;
  59743. /**
  59744. * Gets the output component
  59745. */
  59746. get output(): NodeMaterialConnectionPoint;
  59747. protected _buildBlock(state: NodeMaterialBuildState): this;
  59748. }
  59749. }
  59750. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59754. /**
  59755. * Block used to scale a vector by a float
  59756. */
  59757. export class ScaleBlock extends NodeMaterialBlock {
  59758. /**
  59759. * Creates a new ScaleBlock
  59760. * @param name defines the block name
  59761. */
  59762. constructor(name: string);
  59763. /**
  59764. * Gets the current class name
  59765. * @returns the class name
  59766. */
  59767. getClassName(): string;
  59768. /**
  59769. * Gets the input component
  59770. */
  59771. get input(): NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the factor input component
  59774. */
  59775. get factor(): NodeMaterialConnectionPoint;
  59776. /**
  59777. * Gets the output component
  59778. */
  59779. get output(): NodeMaterialConnectionPoint;
  59780. protected _buildBlock(state: NodeMaterialBuildState): this;
  59781. }
  59782. }
  59783. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59787. import { Scene } from "babylonjs/scene";
  59788. /**
  59789. * Block used to clamp a float
  59790. */
  59791. export class ClampBlock extends NodeMaterialBlock {
  59792. /** Gets or sets the minimum range */
  59793. minimum: number;
  59794. /** Gets or sets the maximum range */
  59795. maximum: number;
  59796. /**
  59797. * Creates a new ClampBlock
  59798. * @param name defines the block name
  59799. */
  59800. constructor(name: string);
  59801. /**
  59802. * Gets the current class name
  59803. * @returns the class name
  59804. */
  59805. getClassName(): string;
  59806. /**
  59807. * Gets the value input component
  59808. */
  59809. get value(): NodeMaterialConnectionPoint;
  59810. /**
  59811. * Gets the output component
  59812. */
  59813. get output(): NodeMaterialConnectionPoint;
  59814. protected _buildBlock(state: NodeMaterialBuildState): this;
  59815. protected _dumpPropertiesCode(): string;
  59816. serialize(): any;
  59817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59818. }
  59819. }
  59820. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59824. /**
  59825. * Block used to apply a cross product between 2 vectors
  59826. */
  59827. export class CrossBlock extends NodeMaterialBlock {
  59828. /**
  59829. * Creates a new CrossBlock
  59830. * @param name defines the block name
  59831. */
  59832. constructor(name: string);
  59833. /**
  59834. * Gets the current class name
  59835. * @returns the class name
  59836. */
  59837. getClassName(): string;
  59838. /**
  59839. * Gets the left operand input component
  59840. */
  59841. get left(): NodeMaterialConnectionPoint;
  59842. /**
  59843. * Gets the right operand input component
  59844. */
  59845. get right(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the output component
  59848. */
  59849. get output(): NodeMaterialConnectionPoint;
  59850. protected _buildBlock(state: NodeMaterialBuildState): this;
  59851. }
  59852. }
  59853. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59857. /**
  59858. * Block used to apply a dot product between 2 vectors
  59859. */
  59860. export class DotBlock extends NodeMaterialBlock {
  59861. /**
  59862. * Creates a new DotBlock
  59863. * @param name defines the block name
  59864. */
  59865. constructor(name: string);
  59866. /**
  59867. * Gets the current class name
  59868. * @returns the class name
  59869. */
  59870. getClassName(): string;
  59871. /**
  59872. * Gets the left operand input component
  59873. */
  59874. get left(): NodeMaterialConnectionPoint;
  59875. /**
  59876. * Gets the right operand input component
  59877. */
  59878. get right(): NodeMaterialConnectionPoint;
  59879. /**
  59880. * Gets the output component
  59881. */
  59882. get output(): NodeMaterialConnectionPoint;
  59883. protected _buildBlock(state: NodeMaterialBuildState): this;
  59884. }
  59885. }
  59886. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59890. import { Vector2 } from "babylonjs/Maths/math.vector";
  59891. import { Scene } from "babylonjs/scene";
  59892. /**
  59893. * Block used to remap a float from a range to a new one
  59894. */
  59895. export class RemapBlock extends NodeMaterialBlock {
  59896. /**
  59897. * Gets or sets the source range
  59898. */
  59899. sourceRange: Vector2;
  59900. /**
  59901. * Gets or sets the target range
  59902. */
  59903. targetRange: Vector2;
  59904. /**
  59905. * Creates a new RemapBlock
  59906. * @param name defines the block name
  59907. */
  59908. constructor(name: string);
  59909. /**
  59910. * Gets the current class name
  59911. * @returns the class name
  59912. */
  59913. getClassName(): string;
  59914. /**
  59915. * Gets the input component
  59916. */
  59917. get input(): NodeMaterialConnectionPoint;
  59918. /**
  59919. * Gets the source min input component
  59920. */
  59921. get sourceMin(): NodeMaterialConnectionPoint;
  59922. /**
  59923. * Gets the source max input component
  59924. */
  59925. get sourceMax(): NodeMaterialConnectionPoint;
  59926. /**
  59927. * Gets the target min input component
  59928. */
  59929. get targetMin(): NodeMaterialConnectionPoint;
  59930. /**
  59931. * Gets the target max input component
  59932. */
  59933. get targetMax(): NodeMaterialConnectionPoint;
  59934. /**
  59935. * Gets the output component
  59936. */
  59937. get output(): NodeMaterialConnectionPoint;
  59938. protected _buildBlock(state: NodeMaterialBuildState): this;
  59939. protected _dumpPropertiesCode(): string;
  59940. serialize(): any;
  59941. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59942. }
  59943. }
  59944. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59948. /**
  59949. * Block used to normalize a vector
  59950. */
  59951. export class NormalizeBlock extends NodeMaterialBlock {
  59952. /**
  59953. * Creates a new NormalizeBlock
  59954. * @param name defines the block name
  59955. */
  59956. constructor(name: string);
  59957. /**
  59958. * Gets the current class name
  59959. * @returns the class name
  59960. */
  59961. getClassName(): string;
  59962. /**
  59963. * Gets the input component
  59964. */
  59965. get input(): NodeMaterialConnectionPoint;
  59966. /**
  59967. * Gets the output component
  59968. */
  59969. get output(): NodeMaterialConnectionPoint;
  59970. protected _buildBlock(state: NodeMaterialBuildState): this;
  59971. }
  59972. }
  59973. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59976. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59977. import { Scene } from "babylonjs/scene";
  59978. /**
  59979. * Operations supported by the Trigonometry block
  59980. */
  59981. export enum TrigonometryBlockOperations {
  59982. /** Cos */
  59983. Cos = 0,
  59984. /** Sin */
  59985. Sin = 1,
  59986. /** Abs */
  59987. Abs = 2,
  59988. /** Exp */
  59989. Exp = 3,
  59990. /** Exp2 */
  59991. Exp2 = 4,
  59992. /** Round */
  59993. Round = 5,
  59994. /** Floor */
  59995. Floor = 6,
  59996. /** Ceiling */
  59997. Ceiling = 7,
  59998. /** Square root */
  59999. Sqrt = 8,
  60000. /** Log */
  60001. Log = 9,
  60002. /** Tangent */
  60003. Tan = 10,
  60004. /** Arc tangent */
  60005. ArcTan = 11,
  60006. /** Arc cosinus */
  60007. ArcCos = 12,
  60008. /** Arc sinus */
  60009. ArcSin = 13,
  60010. /** Fraction */
  60011. Fract = 14,
  60012. /** Sign */
  60013. Sign = 15,
  60014. /** To radians (from degrees) */
  60015. Radians = 16,
  60016. /** To degrees (from radians) */
  60017. Degrees = 17
  60018. }
  60019. /**
  60020. * Block used to apply trigonometry operation to floats
  60021. */
  60022. export class TrigonometryBlock extends NodeMaterialBlock {
  60023. /**
  60024. * Gets or sets the operation applied by the block
  60025. */
  60026. operation: TrigonometryBlockOperations;
  60027. /**
  60028. * Creates a new TrigonometryBlock
  60029. * @param name defines the block name
  60030. */
  60031. constructor(name: string);
  60032. /**
  60033. * Gets the current class name
  60034. * @returns the class name
  60035. */
  60036. getClassName(): string;
  60037. /**
  60038. * Gets the input component
  60039. */
  60040. get input(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the output component
  60043. */
  60044. get output(): NodeMaterialConnectionPoint;
  60045. protected _buildBlock(state: NodeMaterialBuildState): this;
  60046. serialize(): any;
  60047. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60048. protected _dumpPropertiesCode(): string;
  60049. }
  60050. }
  60051. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60055. /**
  60056. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60057. */
  60058. export class ColorMergerBlock extends NodeMaterialBlock {
  60059. /**
  60060. * Create a new ColorMergerBlock
  60061. * @param name defines the block name
  60062. */
  60063. constructor(name: string);
  60064. /**
  60065. * Gets the current class name
  60066. * @returns the class name
  60067. */
  60068. getClassName(): string;
  60069. /**
  60070. * Gets the rgb component (input)
  60071. */
  60072. get rgbIn(): NodeMaterialConnectionPoint;
  60073. /**
  60074. * Gets the r component (input)
  60075. */
  60076. get r(): NodeMaterialConnectionPoint;
  60077. /**
  60078. * Gets the g component (input)
  60079. */
  60080. get g(): NodeMaterialConnectionPoint;
  60081. /**
  60082. * Gets the b component (input)
  60083. */
  60084. get b(): NodeMaterialConnectionPoint;
  60085. /**
  60086. * Gets the a component (input)
  60087. */
  60088. get a(): NodeMaterialConnectionPoint;
  60089. /**
  60090. * Gets the rgba component (output)
  60091. */
  60092. get rgba(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the rgb component (output)
  60095. */
  60096. get rgbOut(): NodeMaterialConnectionPoint;
  60097. /**
  60098. * Gets the rgb component (output)
  60099. * @deprecated Please use rgbOut instead.
  60100. */
  60101. get rgb(): NodeMaterialConnectionPoint;
  60102. protected _buildBlock(state: NodeMaterialBuildState): this;
  60103. }
  60104. }
  60105. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60109. /**
  60110. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60111. */
  60112. export class VectorMergerBlock extends NodeMaterialBlock {
  60113. /**
  60114. * Create a new VectorMergerBlock
  60115. * @param name defines the block name
  60116. */
  60117. constructor(name: string);
  60118. /**
  60119. * Gets the current class name
  60120. * @returns the class name
  60121. */
  60122. getClassName(): string;
  60123. /**
  60124. * Gets the xyz component (input)
  60125. */
  60126. get xyzIn(): NodeMaterialConnectionPoint;
  60127. /**
  60128. * Gets the xy component (input)
  60129. */
  60130. get xyIn(): NodeMaterialConnectionPoint;
  60131. /**
  60132. * Gets the x component (input)
  60133. */
  60134. get x(): NodeMaterialConnectionPoint;
  60135. /**
  60136. * Gets the y component (input)
  60137. */
  60138. get y(): NodeMaterialConnectionPoint;
  60139. /**
  60140. * Gets the z component (input)
  60141. */
  60142. get z(): NodeMaterialConnectionPoint;
  60143. /**
  60144. * Gets the w component (input)
  60145. */
  60146. get w(): NodeMaterialConnectionPoint;
  60147. /**
  60148. * Gets the xyzw component (output)
  60149. */
  60150. get xyzw(): NodeMaterialConnectionPoint;
  60151. /**
  60152. * Gets the xyz component (output)
  60153. */
  60154. get xyzOut(): NodeMaterialConnectionPoint;
  60155. /**
  60156. * Gets the xy component (output)
  60157. */
  60158. get xyOut(): NodeMaterialConnectionPoint;
  60159. /**
  60160. * Gets the xy component (output)
  60161. * @deprecated Please use xyOut instead.
  60162. */
  60163. get xy(): NodeMaterialConnectionPoint;
  60164. /**
  60165. * Gets the xyz component (output)
  60166. * @deprecated Please use xyzOut instead.
  60167. */
  60168. get xyz(): NodeMaterialConnectionPoint;
  60169. protected _buildBlock(state: NodeMaterialBuildState): this;
  60170. }
  60171. }
  60172. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60176. /**
  60177. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60178. */
  60179. export class ColorSplitterBlock extends NodeMaterialBlock {
  60180. /**
  60181. * Create a new ColorSplitterBlock
  60182. * @param name defines the block name
  60183. */
  60184. constructor(name: string);
  60185. /**
  60186. * Gets the current class name
  60187. * @returns the class name
  60188. */
  60189. getClassName(): string;
  60190. /**
  60191. * Gets the rgba component (input)
  60192. */
  60193. get rgba(): NodeMaterialConnectionPoint;
  60194. /**
  60195. * Gets the rgb component (input)
  60196. */
  60197. get rgbIn(): NodeMaterialConnectionPoint;
  60198. /**
  60199. * Gets the rgb component (output)
  60200. */
  60201. get rgbOut(): NodeMaterialConnectionPoint;
  60202. /**
  60203. * Gets the r component (output)
  60204. */
  60205. get r(): NodeMaterialConnectionPoint;
  60206. /**
  60207. * Gets the g component (output)
  60208. */
  60209. get g(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the b component (output)
  60212. */
  60213. get b(): NodeMaterialConnectionPoint;
  60214. /**
  60215. * Gets the a component (output)
  60216. */
  60217. get a(): NodeMaterialConnectionPoint;
  60218. protected _inputRename(name: string): string;
  60219. protected _outputRename(name: string): string;
  60220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60221. }
  60222. }
  60223. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60227. /**
  60228. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60229. */
  60230. export class VectorSplitterBlock extends NodeMaterialBlock {
  60231. /**
  60232. * Create a new VectorSplitterBlock
  60233. * @param name defines the block name
  60234. */
  60235. constructor(name: string);
  60236. /**
  60237. * Gets the current class name
  60238. * @returns the class name
  60239. */
  60240. getClassName(): string;
  60241. /**
  60242. * Gets the xyzw component (input)
  60243. */
  60244. get xyzw(): NodeMaterialConnectionPoint;
  60245. /**
  60246. * Gets the xyz component (input)
  60247. */
  60248. get xyzIn(): NodeMaterialConnectionPoint;
  60249. /**
  60250. * Gets the xy component (input)
  60251. */
  60252. get xyIn(): NodeMaterialConnectionPoint;
  60253. /**
  60254. * Gets the xyz component (output)
  60255. */
  60256. get xyzOut(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the xy component (output)
  60259. */
  60260. get xyOut(): NodeMaterialConnectionPoint;
  60261. /**
  60262. * Gets the x component (output)
  60263. */
  60264. get x(): NodeMaterialConnectionPoint;
  60265. /**
  60266. * Gets the y component (output)
  60267. */
  60268. get y(): NodeMaterialConnectionPoint;
  60269. /**
  60270. * Gets the z component (output)
  60271. */
  60272. get z(): NodeMaterialConnectionPoint;
  60273. /**
  60274. * Gets the w component (output)
  60275. */
  60276. get w(): NodeMaterialConnectionPoint;
  60277. protected _inputRename(name: string): string;
  60278. protected _outputRename(name: string): string;
  60279. protected _buildBlock(state: NodeMaterialBuildState): this;
  60280. }
  60281. }
  60282. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60286. /**
  60287. * Block used to lerp between 2 values
  60288. */
  60289. export class LerpBlock extends NodeMaterialBlock {
  60290. /**
  60291. * Creates a new LerpBlock
  60292. * @param name defines the block name
  60293. */
  60294. constructor(name: string);
  60295. /**
  60296. * Gets the current class name
  60297. * @returns the class name
  60298. */
  60299. getClassName(): string;
  60300. /**
  60301. * Gets the left operand input component
  60302. */
  60303. get left(): NodeMaterialConnectionPoint;
  60304. /**
  60305. * Gets the right operand input component
  60306. */
  60307. get right(): NodeMaterialConnectionPoint;
  60308. /**
  60309. * Gets the gradient operand input component
  60310. */
  60311. get gradient(): NodeMaterialConnectionPoint;
  60312. /**
  60313. * Gets the output component
  60314. */
  60315. get output(): NodeMaterialConnectionPoint;
  60316. protected _buildBlock(state: NodeMaterialBuildState): this;
  60317. }
  60318. }
  60319. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60323. /**
  60324. * Block used to divide 2 vectors
  60325. */
  60326. export class DivideBlock extends NodeMaterialBlock {
  60327. /**
  60328. * Creates a new DivideBlock
  60329. * @param name defines the block name
  60330. */
  60331. constructor(name: string);
  60332. /**
  60333. * Gets the current class name
  60334. * @returns the class name
  60335. */
  60336. getClassName(): string;
  60337. /**
  60338. * Gets the left operand input component
  60339. */
  60340. get left(): NodeMaterialConnectionPoint;
  60341. /**
  60342. * Gets the right operand input component
  60343. */
  60344. get right(): NodeMaterialConnectionPoint;
  60345. /**
  60346. * Gets the output component
  60347. */
  60348. get output(): NodeMaterialConnectionPoint;
  60349. protected _buildBlock(state: NodeMaterialBuildState): this;
  60350. }
  60351. }
  60352. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60356. /**
  60357. * Block used to subtract 2 vectors
  60358. */
  60359. export class SubtractBlock extends NodeMaterialBlock {
  60360. /**
  60361. * Creates a new SubtractBlock
  60362. * @param name defines the block name
  60363. */
  60364. constructor(name: string);
  60365. /**
  60366. * Gets the current class name
  60367. * @returns the class name
  60368. */
  60369. getClassName(): string;
  60370. /**
  60371. * Gets the left operand input component
  60372. */
  60373. get left(): NodeMaterialConnectionPoint;
  60374. /**
  60375. * Gets the right operand input component
  60376. */
  60377. get right(): NodeMaterialConnectionPoint;
  60378. /**
  60379. * Gets the output component
  60380. */
  60381. get output(): NodeMaterialConnectionPoint;
  60382. protected _buildBlock(state: NodeMaterialBuildState): this;
  60383. }
  60384. }
  60385. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60389. /**
  60390. * Block used to step a value
  60391. */
  60392. export class StepBlock extends NodeMaterialBlock {
  60393. /**
  60394. * Creates a new StepBlock
  60395. * @param name defines the block name
  60396. */
  60397. constructor(name: string);
  60398. /**
  60399. * Gets the current class name
  60400. * @returns the class name
  60401. */
  60402. getClassName(): string;
  60403. /**
  60404. * Gets the value operand input component
  60405. */
  60406. get value(): NodeMaterialConnectionPoint;
  60407. /**
  60408. * Gets the edge operand input component
  60409. */
  60410. get edge(): NodeMaterialConnectionPoint;
  60411. /**
  60412. * Gets the output component
  60413. */
  60414. get output(): NodeMaterialConnectionPoint;
  60415. protected _buildBlock(state: NodeMaterialBuildState): this;
  60416. }
  60417. }
  60418. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60422. /**
  60423. * Block used to get the opposite (1 - x) of a value
  60424. */
  60425. export class OneMinusBlock extends NodeMaterialBlock {
  60426. /**
  60427. * Creates a new OneMinusBlock
  60428. * @param name defines the block name
  60429. */
  60430. constructor(name: string);
  60431. /**
  60432. * Gets the current class name
  60433. * @returns the class name
  60434. */
  60435. getClassName(): string;
  60436. /**
  60437. * Gets the input component
  60438. */
  60439. get input(): NodeMaterialConnectionPoint;
  60440. /**
  60441. * Gets the output component
  60442. */
  60443. get output(): NodeMaterialConnectionPoint;
  60444. protected _buildBlock(state: NodeMaterialBuildState): this;
  60445. }
  60446. }
  60447. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60451. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60452. /**
  60453. * Block used to get the view direction
  60454. */
  60455. export class ViewDirectionBlock extends NodeMaterialBlock {
  60456. /**
  60457. * Creates a new ViewDirectionBlock
  60458. * @param name defines the block name
  60459. */
  60460. constructor(name: string);
  60461. /**
  60462. * Gets the current class name
  60463. * @returns the class name
  60464. */
  60465. getClassName(): string;
  60466. /**
  60467. * Gets the world position component
  60468. */
  60469. get worldPosition(): NodeMaterialConnectionPoint;
  60470. /**
  60471. * Gets the camera position component
  60472. */
  60473. get cameraPosition(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the output component
  60476. */
  60477. get output(): NodeMaterialConnectionPoint;
  60478. autoConfigure(material: NodeMaterial): void;
  60479. protected _buildBlock(state: NodeMaterialBuildState): this;
  60480. }
  60481. }
  60482. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60486. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60487. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60488. /**
  60489. * Block used to compute fresnel value
  60490. */
  60491. export class FresnelBlock extends NodeMaterialBlock {
  60492. /**
  60493. * Create a new FresnelBlock
  60494. * @param name defines the block name
  60495. */
  60496. constructor(name: string);
  60497. /**
  60498. * Gets the current class name
  60499. * @returns the class name
  60500. */
  60501. getClassName(): string;
  60502. /**
  60503. * Gets the world normal input component
  60504. */
  60505. get worldNormal(): NodeMaterialConnectionPoint;
  60506. /**
  60507. * Gets the view direction input component
  60508. */
  60509. get viewDirection(): NodeMaterialConnectionPoint;
  60510. /**
  60511. * Gets the bias input component
  60512. */
  60513. get bias(): NodeMaterialConnectionPoint;
  60514. /**
  60515. * Gets the camera (or eye) position component
  60516. */
  60517. get power(): NodeMaterialConnectionPoint;
  60518. /**
  60519. * Gets the fresnel output component
  60520. */
  60521. get fresnel(): NodeMaterialConnectionPoint;
  60522. autoConfigure(material: NodeMaterial): void;
  60523. protected _buildBlock(state: NodeMaterialBuildState): this;
  60524. }
  60525. }
  60526. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60527. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60528. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60530. /**
  60531. * Block used to get the max of 2 values
  60532. */
  60533. export class MaxBlock extends NodeMaterialBlock {
  60534. /**
  60535. * Creates a new MaxBlock
  60536. * @param name defines the block name
  60537. */
  60538. constructor(name: string);
  60539. /**
  60540. * Gets the current class name
  60541. * @returns the class name
  60542. */
  60543. getClassName(): string;
  60544. /**
  60545. * Gets the left operand input component
  60546. */
  60547. get left(): NodeMaterialConnectionPoint;
  60548. /**
  60549. * Gets the right operand input component
  60550. */
  60551. get right(): NodeMaterialConnectionPoint;
  60552. /**
  60553. * Gets the output component
  60554. */
  60555. get output(): NodeMaterialConnectionPoint;
  60556. protected _buildBlock(state: NodeMaterialBuildState): this;
  60557. }
  60558. }
  60559. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60563. /**
  60564. * Block used to get the min of 2 values
  60565. */
  60566. export class MinBlock extends NodeMaterialBlock {
  60567. /**
  60568. * Creates a new MinBlock
  60569. * @param name defines the block name
  60570. */
  60571. constructor(name: string);
  60572. /**
  60573. * Gets the current class name
  60574. * @returns the class name
  60575. */
  60576. getClassName(): string;
  60577. /**
  60578. * Gets the left operand input component
  60579. */
  60580. get left(): NodeMaterialConnectionPoint;
  60581. /**
  60582. * Gets the right operand input component
  60583. */
  60584. get right(): NodeMaterialConnectionPoint;
  60585. /**
  60586. * Gets the output component
  60587. */
  60588. get output(): NodeMaterialConnectionPoint;
  60589. protected _buildBlock(state: NodeMaterialBuildState): this;
  60590. }
  60591. }
  60592. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60596. /**
  60597. * Block used to get the distance between 2 values
  60598. */
  60599. export class DistanceBlock extends NodeMaterialBlock {
  60600. /**
  60601. * Creates a new DistanceBlock
  60602. * @param name defines the block name
  60603. */
  60604. constructor(name: string);
  60605. /**
  60606. * Gets the current class name
  60607. * @returns the class name
  60608. */
  60609. getClassName(): string;
  60610. /**
  60611. * Gets the left operand input component
  60612. */
  60613. get left(): NodeMaterialConnectionPoint;
  60614. /**
  60615. * Gets the right operand input component
  60616. */
  60617. get right(): NodeMaterialConnectionPoint;
  60618. /**
  60619. * Gets the output component
  60620. */
  60621. get output(): NodeMaterialConnectionPoint;
  60622. protected _buildBlock(state: NodeMaterialBuildState): this;
  60623. }
  60624. }
  60625. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60629. /**
  60630. * Block used to get the length of a vector
  60631. */
  60632. export class LengthBlock extends NodeMaterialBlock {
  60633. /**
  60634. * Creates a new LengthBlock
  60635. * @param name defines the block name
  60636. */
  60637. constructor(name: string);
  60638. /**
  60639. * Gets the current class name
  60640. * @returns the class name
  60641. */
  60642. getClassName(): string;
  60643. /**
  60644. * Gets the value input component
  60645. */
  60646. get value(): NodeMaterialConnectionPoint;
  60647. /**
  60648. * Gets the output component
  60649. */
  60650. get output(): NodeMaterialConnectionPoint;
  60651. protected _buildBlock(state: NodeMaterialBuildState): this;
  60652. }
  60653. }
  60654. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60658. /**
  60659. * Block used to get negative version of a value (i.e. x * -1)
  60660. */
  60661. export class NegateBlock extends NodeMaterialBlock {
  60662. /**
  60663. * Creates a new NegateBlock
  60664. * @param name defines the block name
  60665. */
  60666. constructor(name: string);
  60667. /**
  60668. * Gets the current class name
  60669. * @returns the class name
  60670. */
  60671. getClassName(): string;
  60672. /**
  60673. * Gets the value input component
  60674. */
  60675. get value(): NodeMaterialConnectionPoint;
  60676. /**
  60677. * Gets the output component
  60678. */
  60679. get output(): NodeMaterialConnectionPoint;
  60680. protected _buildBlock(state: NodeMaterialBuildState): this;
  60681. }
  60682. }
  60683. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60687. /**
  60688. * Block used to get the value of the first parameter raised to the power of the second
  60689. */
  60690. export class PowBlock extends NodeMaterialBlock {
  60691. /**
  60692. * Creates a new PowBlock
  60693. * @param name defines the block name
  60694. */
  60695. constructor(name: string);
  60696. /**
  60697. * Gets the current class name
  60698. * @returns the class name
  60699. */
  60700. getClassName(): string;
  60701. /**
  60702. * Gets the value operand input component
  60703. */
  60704. get value(): NodeMaterialConnectionPoint;
  60705. /**
  60706. * Gets the power operand input component
  60707. */
  60708. get power(): NodeMaterialConnectionPoint;
  60709. /**
  60710. * Gets the output component
  60711. */
  60712. get output(): NodeMaterialConnectionPoint;
  60713. protected _buildBlock(state: NodeMaterialBuildState): this;
  60714. }
  60715. }
  60716. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60720. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60721. /**
  60722. * Block used to get a random number
  60723. */
  60724. export class RandomNumberBlock extends NodeMaterialBlock {
  60725. /**
  60726. * Creates a new RandomNumberBlock
  60727. * @param name defines the block name
  60728. */
  60729. constructor(name: string);
  60730. /**
  60731. * Gets the current class name
  60732. * @returns the class name
  60733. */
  60734. getClassName(): string;
  60735. /**
  60736. * Gets the seed input component
  60737. */
  60738. get seed(): NodeMaterialConnectionPoint;
  60739. /**
  60740. * Gets the output component
  60741. */
  60742. get output(): NodeMaterialConnectionPoint;
  60743. protected _buildBlock(state: NodeMaterialBuildState): this;
  60744. }
  60745. }
  60746. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60750. /**
  60751. * Block used to compute arc tangent of 2 values
  60752. */
  60753. export class ArcTan2Block extends NodeMaterialBlock {
  60754. /**
  60755. * Creates a new ArcTan2Block
  60756. * @param name defines the block name
  60757. */
  60758. constructor(name: string);
  60759. /**
  60760. * Gets the current class name
  60761. * @returns the class name
  60762. */
  60763. getClassName(): string;
  60764. /**
  60765. * Gets the x operand input component
  60766. */
  60767. get x(): NodeMaterialConnectionPoint;
  60768. /**
  60769. * Gets the y operand input component
  60770. */
  60771. get y(): NodeMaterialConnectionPoint;
  60772. /**
  60773. * Gets the output component
  60774. */
  60775. get output(): NodeMaterialConnectionPoint;
  60776. protected _buildBlock(state: NodeMaterialBuildState): this;
  60777. }
  60778. }
  60779. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60783. /**
  60784. * Block used to smooth step a value
  60785. */
  60786. export class SmoothStepBlock extends NodeMaterialBlock {
  60787. /**
  60788. * Creates a new SmoothStepBlock
  60789. * @param name defines the block name
  60790. */
  60791. constructor(name: string);
  60792. /**
  60793. * Gets the current class name
  60794. * @returns the class name
  60795. */
  60796. getClassName(): string;
  60797. /**
  60798. * Gets the value operand input component
  60799. */
  60800. get value(): NodeMaterialConnectionPoint;
  60801. /**
  60802. * Gets the first edge operand input component
  60803. */
  60804. get edge0(): NodeMaterialConnectionPoint;
  60805. /**
  60806. * Gets the second edge operand input component
  60807. */
  60808. get edge1(): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Gets the output component
  60811. */
  60812. get output(): NodeMaterialConnectionPoint;
  60813. protected _buildBlock(state: NodeMaterialBuildState): this;
  60814. }
  60815. }
  60816. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60817. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60818. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60820. /**
  60821. * Block used to get the reciprocal (1 / x) of a value
  60822. */
  60823. export class ReciprocalBlock extends NodeMaterialBlock {
  60824. /**
  60825. * Creates a new ReciprocalBlock
  60826. * @param name defines the block name
  60827. */
  60828. constructor(name: string);
  60829. /**
  60830. * Gets the current class name
  60831. * @returns the class name
  60832. */
  60833. getClassName(): string;
  60834. /**
  60835. * Gets the input component
  60836. */
  60837. get input(): NodeMaterialConnectionPoint;
  60838. /**
  60839. * Gets the output component
  60840. */
  60841. get output(): NodeMaterialConnectionPoint;
  60842. protected _buildBlock(state: NodeMaterialBuildState): this;
  60843. }
  60844. }
  60845. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60849. /**
  60850. * Block used to replace a color by another one
  60851. */
  60852. export class ReplaceColorBlock extends NodeMaterialBlock {
  60853. /**
  60854. * Creates a new ReplaceColorBlock
  60855. * @param name defines the block name
  60856. */
  60857. constructor(name: string);
  60858. /**
  60859. * Gets the current class name
  60860. * @returns the class name
  60861. */
  60862. getClassName(): string;
  60863. /**
  60864. * Gets the value input component
  60865. */
  60866. get value(): NodeMaterialConnectionPoint;
  60867. /**
  60868. * Gets the reference input component
  60869. */
  60870. get reference(): NodeMaterialConnectionPoint;
  60871. /**
  60872. * Gets the distance input component
  60873. */
  60874. get distance(): NodeMaterialConnectionPoint;
  60875. /**
  60876. * Gets the replacement input component
  60877. */
  60878. get replacement(): NodeMaterialConnectionPoint;
  60879. /**
  60880. * Gets the output component
  60881. */
  60882. get output(): NodeMaterialConnectionPoint;
  60883. protected _buildBlock(state: NodeMaterialBuildState): this;
  60884. }
  60885. }
  60886. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60890. /**
  60891. * Block used to posterize a value
  60892. * @see https://en.wikipedia.org/wiki/Posterization
  60893. */
  60894. export class PosterizeBlock extends NodeMaterialBlock {
  60895. /**
  60896. * Creates a new PosterizeBlock
  60897. * @param name defines the block name
  60898. */
  60899. constructor(name: string);
  60900. /**
  60901. * Gets the current class name
  60902. * @returns the class name
  60903. */
  60904. getClassName(): string;
  60905. /**
  60906. * Gets the value input component
  60907. */
  60908. get value(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the steps input component
  60911. */
  60912. get steps(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the output component
  60915. */
  60916. get output(): NodeMaterialConnectionPoint;
  60917. protected _buildBlock(state: NodeMaterialBuildState): this;
  60918. }
  60919. }
  60920. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60924. import { Scene } from "babylonjs/scene";
  60925. /**
  60926. * Operations supported by the Wave block
  60927. */
  60928. export enum WaveBlockKind {
  60929. /** SawTooth */
  60930. SawTooth = 0,
  60931. /** Square */
  60932. Square = 1,
  60933. /** Triangle */
  60934. Triangle = 2
  60935. }
  60936. /**
  60937. * Block used to apply wave operation to floats
  60938. */
  60939. export class WaveBlock extends NodeMaterialBlock {
  60940. /**
  60941. * Gets or sets the kibnd of wave to be applied by the block
  60942. */
  60943. kind: WaveBlockKind;
  60944. /**
  60945. * Creates a new WaveBlock
  60946. * @param name defines the block name
  60947. */
  60948. constructor(name: string);
  60949. /**
  60950. * Gets the current class name
  60951. * @returns the class name
  60952. */
  60953. getClassName(): string;
  60954. /**
  60955. * Gets the input component
  60956. */
  60957. get input(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the output component
  60960. */
  60961. get output(): NodeMaterialConnectionPoint;
  60962. protected _buildBlock(state: NodeMaterialBuildState): this;
  60963. serialize(): any;
  60964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60965. }
  60966. }
  60967. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60971. import { Color3 } from "babylonjs/Maths/math.color";
  60972. import { Scene } from "babylonjs/scene";
  60973. /**
  60974. * Class used to store a color step for the GradientBlock
  60975. */
  60976. export class GradientBlockColorStep {
  60977. /**
  60978. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60979. */
  60980. step: number;
  60981. /**
  60982. * Gets or sets the color associated with this step
  60983. */
  60984. color: Color3;
  60985. /**
  60986. * Creates a new GradientBlockColorStep
  60987. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60988. * @param color defines the color associated with this step
  60989. */
  60990. constructor(
  60991. /**
  60992. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60993. */
  60994. step: number,
  60995. /**
  60996. * Gets or sets the color associated with this step
  60997. */
  60998. color: Color3);
  60999. }
  61000. /**
  61001. * Block used to return a color from a gradient based on an input value between 0 and 1
  61002. */
  61003. export class GradientBlock extends NodeMaterialBlock {
  61004. /**
  61005. * Gets or sets the list of color steps
  61006. */
  61007. colorSteps: GradientBlockColorStep[];
  61008. /**
  61009. * Creates a new GradientBlock
  61010. * @param name defines the block name
  61011. */
  61012. constructor(name: string);
  61013. /**
  61014. * Gets the current class name
  61015. * @returns the class name
  61016. */
  61017. getClassName(): string;
  61018. /**
  61019. * Gets the gradient input component
  61020. */
  61021. get gradient(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the output component
  61024. */
  61025. get output(): NodeMaterialConnectionPoint;
  61026. private _writeColorConstant;
  61027. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61028. serialize(): any;
  61029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61030. protected _dumpPropertiesCode(): string;
  61031. }
  61032. }
  61033. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  61034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61037. /**
  61038. * Block used to normalize lerp between 2 values
  61039. */
  61040. export class NLerpBlock extends NodeMaterialBlock {
  61041. /**
  61042. * Creates a new NLerpBlock
  61043. * @param name defines the block name
  61044. */
  61045. constructor(name: string);
  61046. /**
  61047. * Gets the current class name
  61048. * @returns the class name
  61049. */
  61050. getClassName(): string;
  61051. /**
  61052. * Gets the left operand input component
  61053. */
  61054. get left(): NodeMaterialConnectionPoint;
  61055. /**
  61056. * Gets the right operand input component
  61057. */
  61058. get right(): NodeMaterialConnectionPoint;
  61059. /**
  61060. * Gets the gradient operand input component
  61061. */
  61062. get gradient(): NodeMaterialConnectionPoint;
  61063. /**
  61064. * Gets the output component
  61065. */
  61066. get output(): NodeMaterialConnectionPoint;
  61067. protected _buildBlock(state: NodeMaterialBuildState): this;
  61068. }
  61069. }
  61070. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61074. import { Scene } from "babylonjs/scene";
  61075. /**
  61076. * block used to Generate a Worley Noise 3D Noise Pattern
  61077. */
  61078. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61079. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61080. manhattanDistance: boolean;
  61081. /**
  61082. * Creates a new WorleyNoise3DBlock
  61083. * @param name defines the block name
  61084. */
  61085. constructor(name: string);
  61086. /**
  61087. * Gets the current class name
  61088. * @returns the class name
  61089. */
  61090. getClassName(): string;
  61091. /**
  61092. * Gets the seed input component
  61093. */
  61094. get seed(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the jitter input component
  61097. */
  61098. get jitter(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the output component
  61101. */
  61102. get output(): NodeMaterialConnectionPoint;
  61103. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61104. /**
  61105. * Exposes the properties to the UI?
  61106. */
  61107. protected _dumpPropertiesCode(): string;
  61108. /**
  61109. * Exposes the properties to the Seralize?
  61110. */
  61111. serialize(): any;
  61112. /**
  61113. * Exposes the properties to the deseralize?
  61114. */
  61115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61116. }
  61117. }
  61118. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61122. /**
  61123. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61124. */
  61125. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61126. /**
  61127. * Creates a new SimplexPerlin3DBlock
  61128. * @param name defines the block name
  61129. */
  61130. constructor(name: string);
  61131. /**
  61132. * Gets the current class name
  61133. * @returns the class name
  61134. */
  61135. getClassName(): string;
  61136. /**
  61137. * Gets the seed operand input component
  61138. */
  61139. get seed(): NodeMaterialConnectionPoint;
  61140. /**
  61141. * Gets the output component
  61142. */
  61143. get output(): NodeMaterialConnectionPoint;
  61144. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61145. }
  61146. }
  61147. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61151. /**
  61152. * Block used to blend normals
  61153. */
  61154. export class NormalBlendBlock extends NodeMaterialBlock {
  61155. /**
  61156. * Creates a new NormalBlendBlock
  61157. * @param name defines the block name
  61158. */
  61159. constructor(name: string);
  61160. /**
  61161. * Gets the current class name
  61162. * @returns the class name
  61163. */
  61164. getClassName(): string;
  61165. /**
  61166. * Gets the first input component
  61167. */
  61168. get normalMap0(): NodeMaterialConnectionPoint;
  61169. /**
  61170. * Gets the second input component
  61171. */
  61172. get normalMap1(): NodeMaterialConnectionPoint;
  61173. /**
  61174. * Gets the output component
  61175. */
  61176. get output(): NodeMaterialConnectionPoint;
  61177. protected _buildBlock(state: NodeMaterialBuildState): this;
  61178. }
  61179. }
  61180. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61184. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61185. /**
  61186. * Block used to rotate a 2d vector by a given angle
  61187. */
  61188. export class Rotate2dBlock extends NodeMaterialBlock {
  61189. /**
  61190. * Creates a new Rotate2dBlock
  61191. * @param name defines the block name
  61192. */
  61193. constructor(name: string);
  61194. /**
  61195. * Gets the current class name
  61196. * @returns the class name
  61197. */
  61198. getClassName(): string;
  61199. /**
  61200. * Gets the input vector
  61201. */
  61202. get input(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the input angle
  61205. */
  61206. get angle(): NodeMaterialConnectionPoint;
  61207. /**
  61208. * Gets the output component
  61209. */
  61210. get output(): NodeMaterialConnectionPoint;
  61211. autoConfigure(material: NodeMaterial): void;
  61212. protected _buildBlock(state: NodeMaterialBuildState): this;
  61213. }
  61214. }
  61215. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61219. /**
  61220. * Block used to get the reflected vector from a direction and a normal
  61221. */
  61222. export class ReflectBlock extends NodeMaterialBlock {
  61223. /**
  61224. * Creates a new ReflectBlock
  61225. * @param name defines the block name
  61226. */
  61227. constructor(name: string);
  61228. /**
  61229. * Gets the current class name
  61230. * @returns the class name
  61231. */
  61232. getClassName(): string;
  61233. /**
  61234. * Gets the incident component
  61235. */
  61236. get incident(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the normal component
  61239. */
  61240. get normal(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the output component
  61243. */
  61244. get output(): NodeMaterialConnectionPoint;
  61245. protected _buildBlock(state: NodeMaterialBuildState): this;
  61246. }
  61247. }
  61248. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61252. /**
  61253. * Block used to get the refracted vector from a direction and a normal
  61254. */
  61255. export class RefractBlock extends NodeMaterialBlock {
  61256. /**
  61257. * Creates a new RefractBlock
  61258. * @param name defines the block name
  61259. */
  61260. constructor(name: string);
  61261. /**
  61262. * Gets the current class name
  61263. * @returns the class name
  61264. */
  61265. getClassName(): string;
  61266. /**
  61267. * Gets the incident component
  61268. */
  61269. get incident(): NodeMaterialConnectionPoint;
  61270. /**
  61271. * Gets the normal component
  61272. */
  61273. get normal(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the index of refraction component
  61276. */
  61277. get ior(): NodeMaterialConnectionPoint;
  61278. /**
  61279. * Gets the output component
  61280. */
  61281. get output(): NodeMaterialConnectionPoint;
  61282. protected _buildBlock(state: NodeMaterialBuildState): this;
  61283. }
  61284. }
  61285. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61288. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61289. /**
  61290. * Block used to desaturate a color
  61291. */
  61292. export class DesaturateBlock extends NodeMaterialBlock {
  61293. /**
  61294. * Creates a new DesaturateBlock
  61295. * @param name defines the block name
  61296. */
  61297. constructor(name: string);
  61298. /**
  61299. * Gets the current class name
  61300. * @returns the class name
  61301. */
  61302. getClassName(): string;
  61303. /**
  61304. * Gets the color operand input component
  61305. */
  61306. get color(): NodeMaterialConnectionPoint;
  61307. /**
  61308. * Gets the level operand input component
  61309. */
  61310. get level(): NodeMaterialConnectionPoint;
  61311. /**
  61312. * Gets the output component
  61313. */
  61314. get output(): NodeMaterialConnectionPoint;
  61315. protected _buildBlock(state: NodeMaterialBuildState): this;
  61316. }
  61317. }
  61318. declare module "babylonjs/Materials/Node/Blocks/index" {
  61319. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61320. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61321. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61322. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61323. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61324. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61325. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61326. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61327. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61328. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61329. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61330. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61331. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61332. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61333. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61334. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61335. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61336. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61337. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61338. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61339. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61340. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61341. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61342. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61343. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61344. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61345. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61346. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61347. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61348. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61349. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61350. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61351. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61352. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61353. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61354. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61355. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61356. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61357. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61358. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61359. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61360. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61361. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61362. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61363. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61364. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61365. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61366. }
  61367. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61368. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61369. }
  61370. declare module "babylonjs/Materials/Node/index" {
  61371. export * from "babylonjs/Materials/Node/Enums/index";
  61372. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61373. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61374. export * from "babylonjs/Materials/Node/nodeMaterial";
  61375. export * from "babylonjs/Materials/Node/Blocks/index";
  61376. export * from "babylonjs/Materials/Node/Optimizers/index";
  61377. }
  61378. declare module "babylonjs/Materials/effectRenderer" {
  61379. import { Nullable } from "babylonjs/types";
  61380. import { Texture } from "babylonjs/Materials/Textures/texture";
  61381. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61382. import { Viewport } from "babylonjs/Maths/math.viewport";
  61383. import { Observable } from "babylonjs/Misc/observable";
  61384. import { Effect } from "babylonjs/Materials/effect";
  61385. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61386. import "babylonjs/Shaders/postprocess.vertex";
  61387. /**
  61388. * Effect Render Options
  61389. */
  61390. export interface IEffectRendererOptions {
  61391. /**
  61392. * Defines the vertices positions.
  61393. */
  61394. positions?: number[];
  61395. /**
  61396. * Defines the indices.
  61397. */
  61398. indices?: number[];
  61399. }
  61400. /**
  61401. * Helper class to render one or more effects
  61402. */
  61403. export class EffectRenderer {
  61404. private engine;
  61405. private static _DefaultOptions;
  61406. private _vertexBuffers;
  61407. private _indexBuffer;
  61408. private _ringBufferIndex;
  61409. private _ringScreenBuffer;
  61410. private _fullscreenViewport;
  61411. private _getNextFrameBuffer;
  61412. /**
  61413. * Creates an effect renderer
  61414. * @param engine the engine to use for rendering
  61415. * @param options defines the options of the effect renderer
  61416. */
  61417. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61418. /**
  61419. * Sets the current viewport in normalized coordinates 0-1
  61420. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61421. */
  61422. setViewport(viewport?: Viewport): void;
  61423. /**
  61424. * Binds the embedded attributes buffer to the effect.
  61425. * @param effect Defines the effect to bind the attributes for
  61426. */
  61427. bindBuffers(effect: Effect): void;
  61428. /**
  61429. * Sets the current effect wrapper to use during draw.
  61430. * The effect needs to be ready before calling this api.
  61431. * This also sets the default full screen position attribute.
  61432. * @param effectWrapper Defines the effect to draw with
  61433. */
  61434. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61435. /**
  61436. * Draws a full screen quad.
  61437. */
  61438. draw(): void;
  61439. /**
  61440. * renders one or more effects to a specified texture
  61441. * @param effectWrappers list of effects to renderer
  61442. * @param outputTexture texture to draw to, if null it will render to the screen
  61443. */
  61444. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61445. /**
  61446. * Disposes of the effect renderer
  61447. */
  61448. dispose(): void;
  61449. }
  61450. /**
  61451. * Options to create an EffectWrapper
  61452. */
  61453. interface EffectWrapperCreationOptions {
  61454. /**
  61455. * Engine to use to create the effect
  61456. */
  61457. engine: ThinEngine;
  61458. /**
  61459. * Fragment shader for the effect
  61460. */
  61461. fragmentShader: string;
  61462. /**
  61463. * Vertex shader for the effect
  61464. */
  61465. vertexShader?: string;
  61466. /**
  61467. * Attributes to use in the shader
  61468. */
  61469. attributeNames?: Array<string>;
  61470. /**
  61471. * Uniforms to use in the shader
  61472. */
  61473. uniformNames?: Array<string>;
  61474. /**
  61475. * Texture sampler names to use in the shader
  61476. */
  61477. samplerNames?: Array<string>;
  61478. /**
  61479. * The friendly name of the effect displayed in Spector.
  61480. */
  61481. name?: string;
  61482. }
  61483. /**
  61484. * Wraps an effect to be used for rendering
  61485. */
  61486. export class EffectWrapper {
  61487. /**
  61488. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61489. */
  61490. onApplyObservable: Observable<{}>;
  61491. /**
  61492. * The underlying effect
  61493. */
  61494. effect: Effect;
  61495. /**
  61496. * Creates an effect to be renderer
  61497. * @param creationOptions options to create the effect
  61498. */
  61499. constructor(creationOptions: EffectWrapperCreationOptions);
  61500. /**
  61501. * Disposes of the effect wrapper
  61502. */
  61503. dispose(): void;
  61504. }
  61505. }
  61506. declare module "babylonjs/Materials/index" {
  61507. export * from "babylonjs/Materials/Background/index";
  61508. export * from "babylonjs/Materials/colorCurves";
  61509. export * from "babylonjs/Materials/iEffectFallbacks";
  61510. export * from "babylonjs/Materials/effectFallbacks";
  61511. export * from "babylonjs/Materials/effect";
  61512. export * from "babylonjs/Materials/fresnelParameters";
  61513. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61514. export * from "babylonjs/Materials/material";
  61515. export * from "babylonjs/Materials/materialDefines";
  61516. export * from "babylonjs/Materials/materialHelper";
  61517. export * from "babylonjs/Materials/multiMaterial";
  61518. export * from "babylonjs/Materials/PBR/index";
  61519. export * from "babylonjs/Materials/pushMaterial";
  61520. export * from "babylonjs/Materials/shaderMaterial";
  61521. export * from "babylonjs/Materials/standardMaterial";
  61522. export * from "babylonjs/Materials/Textures/index";
  61523. export * from "babylonjs/Materials/uniformBuffer";
  61524. export * from "babylonjs/Materials/materialFlags";
  61525. export * from "babylonjs/Materials/Node/index";
  61526. export * from "babylonjs/Materials/effectRenderer";
  61527. }
  61528. declare module "babylonjs/Maths/index" {
  61529. export * from "babylonjs/Maths/math.scalar";
  61530. export * from "babylonjs/Maths/math";
  61531. export * from "babylonjs/Maths/sphericalPolynomial";
  61532. }
  61533. declare module "babylonjs/Misc/workerPool" {
  61534. import { IDisposable } from "babylonjs/scene";
  61535. /**
  61536. * Helper class to push actions to a pool of workers.
  61537. */
  61538. export class WorkerPool implements IDisposable {
  61539. private _workerInfos;
  61540. private _pendingActions;
  61541. /**
  61542. * Constructor
  61543. * @param workers Array of workers to use for actions
  61544. */
  61545. constructor(workers: Array<Worker>);
  61546. /**
  61547. * Terminates all workers and clears any pending actions.
  61548. */
  61549. dispose(): void;
  61550. /**
  61551. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61552. * pended until a worker has completed its action.
  61553. * @param action The action to perform. Call onComplete when the action is complete.
  61554. */
  61555. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61556. private _execute;
  61557. }
  61558. }
  61559. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61560. import { IDisposable } from "babylonjs/scene";
  61561. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61562. /**
  61563. * Configuration for Draco compression
  61564. */
  61565. export interface IDracoCompressionConfiguration {
  61566. /**
  61567. * Configuration for the decoder.
  61568. */
  61569. decoder: {
  61570. /**
  61571. * The url to the WebAssembly module.
  61572. */
  61573. wasmUrl?: string;
  61574. /**
  61575. * The url to the WebAssembly binary.
  61576. */
  61577. wasmBinaryUrl?: string;
  61578. /**
  61579. * The url to the fallback JavaScript module.
  61580. */
  61581. fallbackUrl?: string;
  61582. };
  61583. }
  61584. /**
  61585. * Draco compression (https://google.github.io/draco/)
  61586. *
  61587. * This class wraps the Draco module.
  61588. *
  61589. * **Encoder**
  61590. *
  61591. * The encoder is not currently implemented.
  61592. *
  61593. * **Decoder**
  61594. *
  61595. * 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.
  61596. *
  61597. * To update the configuration, use the following code:
  61598. * ```javascript
  61599. * DracoCompression.Configuration = {
  61600. * decoder: {
  61601. * wasmUrl: "<url to the WebAssembly library>",
  61602. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61603. * fallbackUrl: "<url to the fallback JavaScript library>",
  61604. * }
  61605. * };
  61606. * ```
  61607. *
  61608. * 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.
  61609. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61610. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61611. *
  61612. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61613. * ```javascript
  61614. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61615. * ```
  61616. *
  61617. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61618. */
  61619. export class DracoCompression implements IDisposable {
  61620. private _workerPoolPromise?;
  61621. private _decoderModulePromise?;
  61622. /**
  61623. * The configuration. Defaults to the following urls:
  61624. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61625. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61626. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61627. */
  61628. static Configuration: IDracoCompressionConfiguration;
  61629. /**
  61630. * Returns true if the decoder configuration is available.
  61631. */
  61632. static get DecoderAvailable(): boolean;
  61633. /**
  61634. * Default number of workers to create when creating the draco compression object.
  61635. */
  61636. static DefaultNumWorkers: number;
  61637. private static GetDefaultNumWorkers;
  61638. private static _Default;
  61639. /**
  61640. * Default instance for the draco compression object.
  61641. */
  61642. static get Default(): DracoCompression;
  61643. /**
  61644. * Constructor
  61645. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61646. */
  61647. constructor(numWorkers?: number);
  61648. /**
  61649. * Stop all async operations and release resources.
  61650. */
  61651. dispose(): void;
  61652. /**
  61653. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61654. * @returns a promise that resolves when ready
  61655. */
  61656. whenReadyAsync(): Promise<void>;
  61657. /**
  61658. * Decode Draco compressed mesh data to vertex data.
  61659. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61660. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61661. * @returns A promise that resolves with the decoded vertex data
  61662. */
  61663. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61664. [kind: string]: number;
  61665. }): Promise<VertexData>;
  61666. }
  61667. }
  61668. declare module "babylonjs/Meshes/Compression/index" {
  61669. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61670. }
  61671. declare module "babylonjs/Meshes/csg" {
  61672. import { Nullable } from "babylonjs/types";
  61673. import { Scene } from "babylonjs/scene";
  61674. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61675. import { Mesh } from "babylonjs/Meshes/mesh";
  61676. import { Material } from "babylonjs/Materials/material";
  61677. /**
  61678. * Class for building Constructive Solid Geometry
  61679. */
  61680. export class CSG {
  61681. private polygons;
  61682. /**
  61683. * The world matrix
  61684. */
  61685. matrix: Matrix;
  61686. /**
  61687. * Stores the position
  61688. */
  61689. position: Vector3;
  61690. /**
  61691. * Stores the rotation
  61692. */
  61693. rotation: Vector3;
  61694. /**
  61695. * Stores the rotation quaternion
  61696. */
  61697. rotationQuaternion: Nullable<Quaternion>;
  61698. /**
  61699. * Stores the scaling vector
  61700. */
  61701. scaling: Vector3;
  61702. /**
  61703. * Convert the Mesh to CSG
  61704. * @param mesh The Mesh to convert to CSG
  61705. * @returns A new CSG from the Mesh
  61706. */
  61707. static FromMesh(mesh: Mesh): CSG;
  61708. /**
  61709. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61710. * @param polygons Polygons used to construct a CSG solid
  61711. */
  61712. private static FromPolygons;
  61713. /**
  61714. * Clones, or makes a deep copy, of the CSG
  61715. * @returns A new CSG
  61716. */
  61717. clone(): CSG;
  61718. /**
  61719. * Unions this CSG with another CSG
  61720. * @param csg The CSG to union against this CSG
  61721. * @returns The unioned CSG
  61722. */
  61723. union(csg: CSG): CSG;
  61724. /**
  61725. * Unions this CSG with another CSG in place
  61726. * @param csg The CSG to union against this CSG
  61727. */
  61728. unionInPlace(csg: CSG): void;
  61729. /**
  61730. * Subtracts this CSG with another CSG
  61731. * @param csg The CSG to subtract against this CSG
  61732. * @returns A new CSG
  61733. */
  61734. subtract(csg: CSG): CSG;
  61735. /**
  61736. * Subtracts this CSG with another CSG in place
  61737. * @param csg The CSG to subtact against this CSG
  61738. */
  61739. subtractInPlace(csg: CSG): void;
  61740. /**
  61741. * Intersect this CSG with another CSG
  61742. * @param csg The CSG to intersect against this CSG
  61743. * @returns A new CSG
  61744. */
  61745. intersect(csg: CSG): CSG;
  61746. /**
  61747. * Intersects this CSG with another CSG in place
  61748. * @param csg The CSG to intersect against this CSG
  61749. */
  61750. intersectInPlace(csg: CSG): void;
  61751. /**
  61752. * Return a new CSG solid with solid and empty space switched. This solid is
  61753. * not modified.
  61754. * @returns A new CSG solid with solid and empty space switched
  61755. */
  61756. inverse(): CSG;
  61757. /**
  61758. * Inverses the CSG in place
  61759. */
  61760. inverseInPlace(): void;
  61761. /**
  61762. * This is used to keep meshes transformations so they can be restored
  61763. * when we build back a Babylon Mesh
  61764. * NB : All CSG operations are performed in world coordinates
  61765. * @param csg The CSG to copy the transform attributes from
  61766. * @returns This CSG
  61767. */
  61768. copyTransformAttributes(csg: CSG): CSG;
  61769. /**
  61770. * Build Raw mesh from CSG
  61771. * Coordinates here are in world space
  61772. * @param name The name of the mesh geometry
  61773. * @param scene The Scene
  61774. * @param keepSubMeshes Specifies if the submeshes should be kept
  61775. * @returns A new Mesh
  61776. */
  61777. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61778. /**
  61779. * Build Mesh from CSG taking material and transforms into account
  61780. * @param name The name of the Mesh
  61781. * @param material The material of the Mesh
  61782. * @param scene The Scene
  61783. * @param keepSubMeshes Specifies if submeshes should be kept
  61784. * @returns The new Mesh
  61785. */
  61786. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61787. }
  61788. }
  61789. declare module "babylonjs/Meshes/trailMesh" {
  61790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61791. import { Mesh } from "babylonjs/Meshes/mesh";
  61792. import { Scene } from "babylonjs/scene";
  61793. /**
  61794. * Class used to create a trail following a mesh
  61795. */
  61796. export class TrailMesh extends Mesh {
  61797. private _generator;
  61798. private _autoStart;
  61799. private _running;
  61800. private _diameter;
  61801. private _length;
  61802. private _sectionPolygonPointsCount;
  61803. private _sectionVectors;
  61804. private _sectionNormalVectors;
  61805. private _beforeRenderObserver;
  61806. /**
  61807. * @constructor
  61808. * @param name The value used by scene.getMeshByName() to do a lookup.
  61809. * @param generator The mesh to generate a trail.
  61810. * @param scene The scene to add this mesh to.
  61811. * @param diameter Diameter of trailing mesh. Default is 1.
  61812. * @param length Length of trailing mesh. Default is 60.
  61813. * @param autoStart Automatically start trailing mesh. Default true.
  61814. */
  61815. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61816. /**
  61817. * "TrailMesh"
  61818. * @returns "TrailMesh"
  61819. */
  61820. getClassName(): string;
  61821. private _createMesh;
  61822. /**
  61823. * Start trailing mesh.
  61824. */
  61825. start(): void;
  61826. /**
  61827. * Stop trailing mesh.
  61828. */
  61829. stop(): void;
  61830. /**
  61831. * Update trailing mesh geometry.
  61832. */
  61833. update(): void;
  61834. /**
  61835. * Returns a new TrailMesh object.
  61836. * @param name is a string, the name given to the new mesh
  61837. * @param newGenerator use new generator object for cloned trail mesh
  61838. * @returns a new mesh
  61839. */
  61840. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61841. /**
  61842. * Serializes this trail mesh
  61843. * @param serializationObject object to write serialization to
  61844. */
  61845. serialize(serializationObject: any): void;
  61846. /**
  61847. * Parses a serialized trail mesh
  61848. * @param parsedMesh the serialized mesh
  61849. * @param scene the scene to create the trail mesh in
  61850. * @returns the created trail mesh
  61851. */
  61852. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61853. }
  61854. }
  61855. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61856. import { Nullable } from "babylonjs/types";
  61857. import { Scene } from "babylonjs/scene";
  61858. import { Vector4 } from "babylonjs/Maths/math.vector";
  61859. import { Color4 } from "babylonjs/Maths/math.color";
  61860. import { Mesh } from "babylonjs/Meshes/mesh";
  61861. /**
  61862. * Class containing static functions to help procedurally build meshes
  61863. */
  61864. export class TiledBoxBuilder {
  61865. /**
  61866. * Creates a box mesh
  61867. * 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)
  61868. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61872. * @param name defines the name of the mesh
  61873. * @param options defines the options used to create the mesh
  61874. * @param scene defines the hosting scene
  61875. * @returns the box mesh
  61876. */
  61877. static CreateTiledBox(name: string, options: {
  61878. pattern?: number;
  61879. width?: number;
  61880. height?: number;
  61881. depth?: number;
  61882. tileSize?: number;
  61883. tileWidth?: number;
  61884. tileHeight?: number;
  61885. alignHorizontal?: number;
  61886. alignVertical?: number;
  61887. faceUV?: Vector4[];
  61888. faceColors?: Color4[];
  61889. sideOrientation?: number;
  61890. updatable?: boolean;
  61891. }, scene?: Nullable<Scene>): Mesh;
  61892. }
  61893. }
  61894. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61895. import { Vector4 } from "babylonjs/Maths/math.vector";
  61896. import { Mesh } from "babylonjs/Meshes/mesh";
  61897. /**
  61898. * Class containing static functions to help procedurally build meshes
  61899. */
  61900. export class TorusKnotBuilder {
  61901. /**
  61902. * Creates a torus knot mesh
  61903. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61904. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61905. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61906. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61910. * @param name defines the name of the mesh
  61911. * @param options defines the options used to create the mesh
  61912. * @param scene defines the hosting scene
  61913. * @returns the torus knot mesh
  61914. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61915. */
  61916. static CreateTorusKnot(name: string, options: {
  61917. radius?: number;
  61918. tube?: number;
  61919. radialSegments?: number;
  61920. tubularSegments?: number;
  61921. p?: number;
  61922. q?: number;
  61923. updatable?: boolean;
  61924. sideOrientation?: number;
  61925. frontUVs?: Vector4;
  61926. backUVs?: Vector4;
  61927. }, scene: any): Mesh;
  61928. }
  61929. }
  61930. declare module "babylonjs/Meshes/polygonMesh" {
  61931. import { Scene } from "babylonjs/scene";
  61932. import { Vector2 } from "babylonjs/Maths/math.vector";
  61933. import { Mesh } from "babylonjs/Meshes/mesh";
  61934. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61935. import { Path2 } from "babylonjs/Maths/math.path";
  61936. /**
  61937. * Polygon
  61938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61939. */
  61940. export class Polygon {
  61941. /**
  61942. * Creates a rectangle
  61943. * @param xmin bottom X coord
  61944. * @param ymin bottom Y coord
  61945. * @param xmax top X coord
  61946. * @param ymax top Y coord
  61947. * @returns points that make the resulting rectation
  61948. */
  61949. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61950. /**
  61951. * Creates a circle
  61952. * @param radius radius of circle
  61953. * @param cx scale in x
  61954. * @param cy scale in y
  61955. * @param numberOfSides number of sides that make up the circle
  61956. * @returns points that make the resulting circle
  61957. */
  61958. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61959. /**
  61960. * Creates a polygon from input string
  61961. * @param input Input polygon data
  61962. * @returns the parsed points
  61963. */
  61964. static Parse(input: string): Vector2[];
  61965. /**
  61966. * Starts building a polygon from x and y coordinates
  61967. * @param x x coordinate
  61968. * @param y y coordinate
  61969. * @returns the started path2
  61970. */
  61971. static StartingAt(x: number, y: number): Path2;
  61972. }
  61973. /**
  61974. * Builds a polygon
  61975. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61976. */
  61977. export class PolygonMeshBuilder {
  61978. private _points;
  61979. private _outlinepoints;
  61980. private _holes;
  61981. private _name;
  61982. private _scene;
  61983. private _epoints;
  61984. private _eholes;
  61985. private _addToepoint;
  61986. /**
  61987. * Babylon reference to the earcut plugin.
  61988. */
  61989. bjsEarcut: any;
  61990. /**
  61991. * Creates a PolygonMeshBuilder
  61992. * @param name name of the builder
  61993. * @param contours Path of the polygon
  61994. * @param scene scene to add to when creating the mesh
  61995. * @param earcutInjection can be used to inject your own earcut reference
  61996. */
  61997. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61998. /**
  61999. * Adds a whole within the polygon
  62000. * @param hole Array of points defining the hole
  62001. * @returns this
  62002. */
  62003. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62004. /**
  62005. * Creates the polygon
  62006. * @param updatable If the mesh should be updatable
  62007. * @param depth The depth of the mesh created
  62008. * @returns the created mesh
  62009. */
  62010. build(updatable?: boolean, depth?: number): Mesh;
  62011. /**
  62012. * Creates the polygon
  62013. * @param depth The depth of the mesh created
  62014. * @returns the created VertexData
  62015. */
  62016. buildVertexData(depth?: number): VertexData;
  62017. /**
  62018. * Adds a side to the polygon
  62019. * @param positions points that make the polygon
  62020. * @param normals normals of the polygon
  62021. * @param uvs uvs of the polygon
  62022. * @param indices indices of the polygon
  62023. * @param bounds bounds of the polygon
  62024. * @param points points of the polygon
  62025. * @param depth depth of the polygon
  62026. * @param flip flip of the polygon
  62027. */
  62028. private addSide;
  62029. }
  62030. }
  62031. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  62032. import { Scene } from "babylonjs/scene";
  62033. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62034. import { Color4 } from "babylonjs/Maths/math.color";
  62035. import { Mesh } from "babylonjs/Meshes/mesh";
  62036. import { Nullable } from "babylonjs/types";
  62037. /**
  62038. * Class containing static functions to help procedurally build meshes
  62039. */
  62040. export class PolygonBuilder {
  62041. /**
  62042. * Creates a polygon mesh
  62043. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62044. * * 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
  62045. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62048. * * Remember you can only change the shape positions, not their number when updating a polygon
  62049. * @param name defines the name of the mesh
  62050. * @param options defines the options used to create the mesh
  62051. * @param scene defines the hosting scene
  62052. * @param earcutInjection can be used to inject your own earcut reference
  62053. * @returns the polygon mesh
  62054. */
  62055. static CreatePolygon(name: string, options: {
  62056. shape: Vector3[];
  62057. holes?: Vector3[][];
  62058. depth?: number;
  62059. faceUV?: Vector4[];
  62060. faceColors?: Color4[];
  62061. updatable?: boolean;
  62062. sideOrientation?: number;
  62063. frontUVs?: Vector4;
  62064. backUVs?: Vector4;
  62065. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62066. /**
  62067. * Creates an extruded polygon mesh, with depth in the Y direction.
  62068. * * 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)
  62069. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62070. * @param name defines the name of the mesh
  62071. * @param options defines the options used to create the mesh
  62072. * @param scene defines the hosting scene
  62073. * @param earcutInjection can be used to inject your own earcut reference
  62074. * @returns the polygon mesh
  62075. */
  62076. static ExtrudePolygon(name: string, options: {
  62077. shape: Vector3[];
  62078. holes?: Vector3[][];
  62079. depth?: number;
  62080. faceUV?: Vector4[];
  62081. faceColors?: Color4[];
  62082. updatable?: boolean;
  62083. sideOrientation?: number;
  62084. frontUVs?: Vector4;
  62085. backUVs?: Vector4;
  62086. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62087. }
  62088. }
  62089. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62090. import { Scene } from "babylonjs/scene";
  62091. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62092. import { Mesh } from "babylonjs/Meshes/mesh";
  62093. import { Nullable } from "babylonjs/types";
  62094. /**
  62095. * Class containing static functions to help procedurally build meshes
  62096. */
  62097. export class LatheBuilder {
  62098. /**
  62099. * Creates lathe mesh.
  62100. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62101. * * 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
  62102. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62103. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62104. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62105. * * 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
  62106. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62107. * * 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
  62108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62110. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62112. * @param name defines the name of the mesh
  62113. * @param options defines the options used to create the mesh
  62114. * @param scene defines the hosting scene
  62115. * @returns the lathe mesh
  62116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62117. */
  62118. static CreateLathe(name: string, options: {
  62119. shape: Vector3[];
  62120. radius?: number;
  62121. tessellation?: number;
  62122. clip?: number;
  62123. arc?: number;
  62124. closed?: boolean;
  62125. updatable?: boolean;
  62126. sideOrientation?: number;
  62127. frontUVs?: Vector4;
  62128. backUVs?: Vector4;
  62129. cap?: number;
  62130. invertUV?: boolean;
  62131. }, scene?: Nullable<Scene>): Mesh;
  62132. }
  62133. }
  62134. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62135. import { Nullable } from "babylonjs/types";
  62136. import { Scene } from "babylonjs/scene";
  62137. import { Vector4 } from "babylonjs/Maths/math.vector";
  62138. import { Mesh } from "babylonjs/Meshes/mesh";
  62139. /**
  62140. * Class containing static functions to help procedurally build meshes
  62141. */
  62142. export class TiledPlaneBuilder {
  62143. /**
  62144. * Creates a tiled plane mesh
  62145. * * The parameter `pattern` will, depending on value, do nothing or
  62146. * * * flip (reflect about central vertical) alternate tiles across and up
  62147. * * * flip every tile on alternate rows
  62148. * * * rotate (180 degs) alternate tiles across and up
  62149. * * * rotate every tile on alternate rows
  62150. * * * flip and rotate alternate tiles across and up
  62151. * * * flip and rotate every tile on alternate rows
  62152. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62153. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62156. * * 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)
  62157. * * 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)
  62158. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62159. * @param name defines the name of the mesh
  62160. * @param options defines the options used to create the mesh
  62161. * @param scene defines the hosting scene
  62162. * @returns the box mesh
  62163. */
  62164. static CreateTiledPlane(name: string, options: {
  62165. pattern?: number;
  62166. tileSize?: number;
  62167. tileWidth?: number;
  62168. tileHeight?: number;
  62169. size?: number;
  62170. width?: number;
  62171. height?: number;
  62172. alignHorizontal?: number;
  62173. alignVertical?: number;
  62174. sideOrientation?: number;
  62175. frontUVs?: Vector4;
  62176. backUVs?: Vector4;
  62177. updatable?: boolean;
  62178. }, scene?: Nullable<Scene>): Mesh;
  62179. }
  62180. }
  62181. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62182. import { Nullable } from "babylonjs/types";
  62183. import { Scene } from "babylonjs/scene";
  62184. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62185. import { Mesh } from "babylonjs/Meshes/mesh";
  62186. /**
  62187. * Class containing static functions to help procedurally build meshes
  62188. */
  62189. export class TubeBuilder {
  62190. /**
  62191. * Creates a tube mesh.
  62192. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62193. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62194. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62195. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62196. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62197. * * 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)
  62198. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62199. * * 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
  62200. * * 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
  62201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62205. * @param name defines the name of the mesh
  62206. * @param options defines the options used to create the mesh
  62207. * @param scene defines the hosting scene
  62208. * @returns the tube mesh
  62209. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62210. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62211. */
  62212. static CreateTube(name: string, options: {
  62213. path: Vector3[];
  62214. radius?: number;
  62215. tessellation?: number;
  62216. radiusFunction?: {
  62217. (i: number, distance: number): number;
  62218. };
  62219. cap?: number;
  62220. arc?: number;
  62221. updatable?: boolean;
  62222. sideOrientation?: number;
  62223. frontUVs?: Vector4;
  62224. backUVs?: Vector4;
  62225. instance?: Mesh;
  62226. invertUV?: boolean;
  62227. }, scene?: Nullable<Scene>): Mesh;
  62228. }
  62229. }
  62230. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62231. import { Scene } from "babylonjs/scene";
  62232. import { Vector4 } from "babylonjs/Maths/math.vector";
  62233. import { Mesh } from "babylonjs/Meshes/mesh";
  62234. import { Nullable } from "babylonjs/types";
  62235. /**
  62236. * Class containing static functions to help procedurally build meshes
  62237. */
  62238. export class IcoSphereBuilder {
  62239. /**
  62240. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62241. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62242. * * 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`)
  62243. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62244. * * 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
  62245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62248. * @param name defines the name of the mesh
  62249. * @param options defines the options used to create the mesh
  62250. * @param scene defines the hosting scene
  62251. * @returns the icosahedron mesh
  62252. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62253. */
  62254. static CreateIcoSphere(name: string, options: {
  62255. radius?: number;
  62256. radiusX?: number;
  62257. radiusY?: number;
  62258. radiusZ?: number;
  62259. flat?: boolean;
  62260. subdivisions?: number;
  62261. sideOrientation?: number;
  62262. frontUVs?: Vector4;
  62263. backUVs?: Vector4;
  62264. updatable?: boolean;
  62265. }, scene?: Nullable<Scene>): Mesh;
  62266. }
  62267. }
  62268. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62269. import { Vector3 } from "babylonjs/Maths/math.vector";
  62270. import { Mesh } from "babylonjs/Meshes/mesh";
  62271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62272. /**
  62273. * Class containing static functions to help procedurally build meshes
  62274. */
  62275. export class DecalBuilder {
  62276. /**
  62277. * Creates a decal mesh.
  62278. * 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
  62279. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62280. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62281. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62282. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62283. * @param name defines the name of the mesh
  62284. * @param sourceMesh defines the mesh where the decal must be applied
  62285. * @param options defines the options used to create the mesh
  62286. * @param scene defines the hosting scene
  62287. * @returns the decal mesh
  62288. * @see https://doc.babylonjs.com/how_to/decals
  62289. */
  62290. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62291. position?: Vector3;
  62292. normal?: Vector3;
  62293. size?: Vector3;
  62294. angle?: number;
  62295. }): Mesh;
  62296. }
  62297. }
  62298. declare module "babylonjs/Meshes/meshBuilder" {
  62299. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62300. import { Nullable } from "babylonjs/types";
  62301. import { Scene } from "babylonjs/scene";
  62302. import { Mesh } from "babylonjs/Meshes/mesh";
  62303. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62304. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62306. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62307. import { Plane } from "babylonjs/Maths/math.plane";
  62308. /**
  62309. * Class containing static functions to help procedurally build meshes
  62310. */
  62311. export class MeshBuilder {
  62312. /**
  62313. * Creates a box mesh
  62314. * * The parameter `size` sets the size (float) of each box side (default 1)
  62315. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62316. * * 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)
  62317. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62321. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62322. * @param name defines the name of the mesh
  62323. * @param options defines the options used to create the mesh
  62324. * @param scene defines the hosting scene
  62325. * @returns the box mesh
  62326. */
  62327. static CreateBox(name: string, options: {
  62328. size?: number;
  62329. width?: number;
  62330. height?: number;
  62331. depth?: number;
  62332. faceUV?: Vector4[];
  62333. faceColors?: Color4[];
  62334. sideOrientation?: number;
  62335. frontUVs?: Vector4;
  62336. backUVs?: Vector4;
  62337. updatable?: boolean;
  62338. }, scene?: Nullable<Scene>): Mesh;
  62339. /**
  62340. * Creates a tiled box mesh
  62341. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62343. * @param name defines the name of the mesh
  62344. * @param options defines the options used to create the mesh
  62345. * @param scene defines the hosting scene
  62346. * @returns the tiled box mesh
  62347. */
  62348. static CreateTiledBox(name: string, options: {
  62349. pattern?: number;
  62350. size?: number;
  62351. width?: number;
  62352. height?: number;
  62353. depth: number;
  62354. tileSize?: number;
  62355. tileWidth?: number;
  62356. tileHeight?: number;
  62357. faceUV?: Vector4[];
  62358. faceColors?: Color4[];
  62359. alignHorizontal?: number;
  62360. alignVertical?: number;
  62361. sideOrientation?: number;
  62362. updatable?: boolean;
  62363. }, scene?: Nullable<Scene>): Mesh;
  62364. /**
  62365. * Creates a sphere mesh
  62366. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62367. * * 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`)
  62368. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62369. * * 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
  62370. * * 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)
  62371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62374. * @param name defines the name of the mesh
  62375. * @param options defines the options used to create the mesh
  62376. * @param scene defines the hosting scene
  62377. * @returns the sphere mesh
  62378. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62379. */
  62380. static CreateSphere(name: string, options: {
  62381. segments?: number;
  62382. diameter?: number;
  62383. diameterX?: number;
  62384. diameterY?: number;
  62385. diameterZ?: number;
  62386. arc?: number;
  62387. slice?: number;
  62388. sideOrientation?: number;
  62389. frontUVs?: Vector4;
  62390. backUVs?: Vector4;
  62391. updatable?: boolean;
  62392. }, scene?: Nullable<Scene>): Mesh;
  62393. /**
  62394. * Creates a plane polygonal mesh. By default, this is a disc
  62395. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62396. * * 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
  62397. * * 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
  62398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62401. * @param name defines the name of the mesh
  62402. * @param options defines the options used to create the mesh
  62403. * @param scene defines the hosting scene
  62404. * @returns the plane polygonal mesh
  62405. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62406. */
  62407. static CreateDisc(name: string, options: {
  62408. radius?: number;
  62409. tessellation?: number;
  62410. arc?: number;
  62411. updatable?: boolean;
  62412. sideOrientation?: number;
  62413. frontUVs?: Vector4;
  62414. backUVs?: Vector4;
  62415. }, scene?: Nullable<Scene>): Mesh;
  62416. /**
  62417. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62418. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62419. * * 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`)
  62420. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62421. * * 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
  62422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62425. * @param name defines the name of the mesh
  62426. * @param options defines the options used to create the mesh
  62427. * @param scene defines the hosting scene
  62428. * @returns the icosahedron mesh
  62429. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62430. */
  62431. static CreateIcoSphere(name: string, options: {
  62432. radius?: number;
  62433. radiusX?: number;
  62434. radiusY?: number;
  62435. radiusZ?: number;
  62436. flat?: boolean;
  62437. subdivisions?: number;
  62438. sideOrientation?: number;
  62439. frontUVs?: Vector4;
  62440. backUVs?: Vector4;
  62441. updatable?: boolean;
  62442. }, scene?: Nullable<Scene>): Mesh;
  62443. /**
  62444. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62445. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62446. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62447. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62448. * * 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
  62449. * * 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
  62450. * * 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
  62451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62454. * * 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
  62455. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62456. * * 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
  62457. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62459. * @param name defines the name of the mesh
  62460. * @param options defines the options used to create the mesh
  62461. * @param scene defines the hosting scene
  62462. * @returns the ribbon mesh
  62463. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62465. */
  62466. static CreateRibbon(name: string, options: {
  62467. pathArray: Vector3[][];
  62468. closeArray?: boolean;
  62469. closePath?: boolean;
  62470. offset?: number;
  62471. updatable?: boolean;
  62472. sideOrientation?: number;
  62473. frontUVs?: Vector4;
  62474. backUVs?: Vector4;
  62475. instance?: Mesh;
  62476. invertUV?: boolean;
  62477. uvs?: Vector2[];
  62478. colors?: Color4[];
  62479. }, scene?: Nullable<Scene>): Mesh;
  62480. /**
  62481. * Creates a cylinder or a cone mesh
  62482. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62483. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62484. * * 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.
  62485. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62486. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62487. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62488. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62489. * * 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).
  62490. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62491. * * 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).
  62492. * * 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
  62493. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62494. * * 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
  62495. * * 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.
  62496. * * If `enclose` is false, a ring surface is one element.
  62497. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62498. * * 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
  62499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62502. * @param name defines the name of the mesh
  62503. * @param options defines the options used to create the mesh
  62504. * @param scene defines the hosting scene
  62505. * @returns the cylinder mesh
  62506. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62507. */
  62508. static CreateCylinder(name: string, options: {
  62509. height?: number;
  62510. diameterTop?: number;
  62511. diameterBottom?: number;
  62512. diameter?: number;
  62513. tessellation?: number;
  62514. subdivisions?: number;
  62515. arc?: number;
  62516. faceColors?: Color4[];
  62517. faceUV?: Vector4[];
  62518. updatable?: boolean;
  62519. hasRings?: boolean;
  62520. enclose?: boolean;
  62521. cap?: number;
  62522. sideOrientation?: number;
  62523. frontUVs?: Vector4;
  62524. backUVs?: Vector4;
  62525. }, scene?: Nullable<Scene>): Mesh;
  62526. /**
  62527. * Creates a torus mesh
  62528. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62529. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62530. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62534. * @param name defines the name of the mesh
  62535. * @param options defines the options used to create the mesh
  62536. * @param scene defines the hosting scene
  62537. * @returns the torus mesh
  62538. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62539. */
  62540. static CreateTorus(name: string, options: {
  62541. diameter?: number;
  62542. thickness?: number;
  62543. tessellation?: number;
  62544. updatable?: boolean;
  62545. sideOrientation?: number;
  62546. frontUVs?: Vector4;
  62547. backUVs?: Vector4;
  62548. }, scene?: Nullable<Scene>): Mesh;
  62549. /**
  62550. * Creates a torus knot mesh
  62551. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62552. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62553. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62554. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62558. * @param name defines the name of the mesh
  62559. * @param options defines the options used to create the mesh
  62560. * @param scene defines the hosting scene
  62561. * @returns the torus knot mesh
  62562. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62563. */
  62564. static CreateTorusKnot(name: string, options: {
  62565. radius?: number;
  62566. tube?: number;
  62567. radialSegments?: number;
  62568. tubularSegments?: number;
  62569. p?: number;
  62570. q?: number;
  62571. updatable?: boolean;
  62572. sideOrientation?: number;
  62573. frontUVs?: Vector4;
  62574. backUVs?: Vector4;
  62575. }, scene?: Nullable<Scene>): Mesh;
  62576. /**
  62577. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62578. * * 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
  62579. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62580. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62581. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62582. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62583. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62584. * * 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
  62585. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62588. * @param name defines the name of the new line system
  62589. * @param options defines the options used to create the line system
  62590. * @param scene defines the hosting scene
  62591. * @returns a new line system mesh
  62592. */
  62593. static CreateLineSystem(name: string, options: {
  62594. lines: Vector3[][];
  62595. updatable?: boolean;
  62596. instance?: Nullable<LinesMesh>;
  62597. colors?: Nullable<Color4[][]>;
  62598. useVertexAlpha?: boolean;
  62599. }, scene: Nullable<Scene>): LinesMesh;
  62600. /**
  62601. * Creates a line mesh
  62602. * 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
  62603. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62604. * * The parameter `points` is an array successive Vector3
  62605. * * 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
  62606. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62607. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62608. * * When updating an instance, remember that only point positions can change, not the number of points
  62609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62611. * @param name defines the name of the new line system
  62612. * @param options defines the options used to create the line system
  62613. * @param scene defines the hosting scene
  62614. * @returns a new line mesh
  62615. */
  62616. static CreateLines(name: string, options: {
  62617. points: Vector3[];
  62618. updatable?: boolean;
  62619. instance?: Nullable<LinesMesh>;
  62620. colors?: Color4[];
  62621. useVertexAlpha?: boolean;
  62622. }, scene?: Nullable<Scene>): LinesMesh;
  62623. /**
  62624. * Creates a dashed line mesh
  62625. * * 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
  62626. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62627. * * The parameter `points` is an array successive Vector3
  62628. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62629. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62630. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62631. * * 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
  62632. * * When updating an instance, remember that only point positions can change, not the number of points
  62633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62634. * @param name defines the name of the mesh
  62635. * @param options defines the options used to create the mesh
  62636. * @param scene defines the hosting scene
  62637. * @returns the dashed line mesh
  62638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62639. */
  62640. static CreateDashedLines(name: string, options: {
  62641. points: Vector3[];
  62642. dashSize?: number;
  62643. gapSize?: number;
  62644. dashNb?: number;
  62645. updatable?: boolean;
  62646. instance?: LinesMesh;
  62647. }, scene?: Nullable<Scene>): LinesMesh;
  62648. /**
  62649. * 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.
  62650. * * 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.
  62651. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62652. * * 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.
  62653. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62654. * * 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
  62655. * * 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
  62656. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62661. * @param name defines the name of the mesh
  62662. * @param options defines the options used to create the mesh
  62663. * @param scene defines the hosting scene
  62664. * @returns the extruded shape mesh
  62665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62667. */
  62668. static ExtrudeShape(name: string, options: {
  62669. shape: Vector3[];
  62670. path: Vector3[];
  62671. scale?: number;
  62672. rotation?: number;
  62673. cap?: number;
  62674. updatable?: boolean;
  62675. sideOrientation?: number;
  62676. frontUVs?: Vector4;
  62677. backUVs?: Vector4;
  62678. instance?: Mesh;
  62679. invertUV?: boolean;
  62680. }, scene?: Nullable<Scene>): Mesh;
  62681. /**
  62682. * Creates an custom extruded shape mesh.
  62683. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62684. * * 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.
  62685. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62686. * * 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
  62687. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62688. * * 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
  62689. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62690. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62691. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62692. * * 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
  62693. * * 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
  62694. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62699. * @param name defines the name of the mesh
  62700. * @param options defines the options used to create the mesh
  62701. * @param scene defines the hosting scene
  62702. * @returns the custom extruded shape mesh
  62703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62704. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62706. */
  62707. static ExtrudeShapeCustom(name: string, options: {
  62708. shape: Vector3[];
  62709. path: Vector3[];
  62710. scaleFunction?: any;
  62711. rotationFunction?: any;
  62712. ribbonCloseArray?: boolean;
  62713. ribbonClosePath?: boolean;
  62714. cap?: number;
  62715. updatable?: boolean;
  62716. sideOrientation?: number;
  62717. frontUVs?: Vector4;
  62718. backUVs?: Vector4;
  62719. instance?: Mesh;
  62720. invertUV?: boolean;
  62721. }, scene?: Nullable<Scene>): Mesh;
  62722. /**
  62723. * Creates lathe mesh.
  62724. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62725. * * 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
  62726. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62727. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62728. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62729. * * 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
  62730. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62731. * * 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
  62732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62736. * @param name defines the name of the mesh
  62737. * @param options defines the options used to create the mesh
  62738. * @param scene defines the hosting scene
  62739. * @returns the lathe mesh
  62740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62741. */
  62742. static CreateLathe(name: string, options: {
  62743. shape: Vector3[];
  62744. radius?: number;
  62745. tessellation?: number;
  62746. clip?: number;
  62747. arc?: number;
  62748. closed?: boolean;
  62749. updatable?: boolean;
  62750. sideOrientation?: number;
  62751. frontUVs?: Vector4;
  62752. backUVs?: Vector4;
  62753. cap?: number;
  62754. invertUV?: boolean;
  62755. }, scene?: Nullable<Scene>): Mesh;
  62756. /**
  62757. * Creates a tiled plane mesh
  62758. * * You can set a limited pattern arrangement with the tiles
  62759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62762. * @param name defines the name of the mesh
  62763. * @param options defines the options used to create the mesh
  62764. * @param scene defines the hosting scene
  62765. * @returns the plane mesh
  62766. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62767. */
  62768. static CreateTiledPlane(name: string, options: {
  62769. pattern?: number;
  62770. tileSize?: number;
  62771. tileWidth?: number;
  62772. tileHeight?: number;
  62773. size?: number;
  62774. width?: number;
  62775. height?: number;
  62776. alignHorizontal?: number;
  62777. alignVertical?: number;
  62778. sideOrientation?: number;
  62779. frontUVs?: Vector4;
  62780. backUVs?: Vector4;
  62781. updatable?: boolean;
  62782. }, scene?: Nullable<Scene>): Mesh;
  62783. /**
  62784. * Creates a plane mesh
  62785. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62786. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62787. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62791. * @param name defines the name of the mesh
  62792. * @param options defines the options used to create the mesh
  62793. * @param scene defines the hosting scene
  62794. * @returns the plane mesh
  62795. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62796. */
  62797. static CreatePlane(name: string, options: {
  62798. size?: number;
  62799. width?: number;
  62800. height?: number;
  62801. sideOrientation?: number;
  62802. frontUVs?: Vector4;
  62803. backUVs?: Vector4;
  62804. updatable?: boolean;
  62805. sourcePlane?: Plane;
  62806. }, scene?: Nullable<Scene>): Mesh;
  62807. /**
  62808. * Creates a ground mesh
  62809. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62810. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62812. * @param name defines the name of the mesh
  62813. * @param options defines the options used to create the mesh
  62814. * @param scene defines the hosting scene
  62815. * @returns the ground mesh
  62816. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62817. */
  62818. static CreateGround(name: string, options: {
  62819. width?: number;
  62820. height?: number;
  62821. subdivisions?: number;
  62822. subdivisionsX?: number;
  62823. subdivisionsY?: number;
  62824. updatable?: boolean;
  62825. }, scene?: Nullable<Scene>): Mesh;
  62826. /**
  62827. * Creates a tiled ground mesh
  62828. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62829. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62830. * * 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
  62831. * * 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
  62832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62833. * @param name defines the name of the mesh
  62834. * @param options defines the options used to create the mesh
  62835. * @param scene defines the hosting scene
  62836. * @returns the tiled ground mesh
  62837. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62838. */
  62839. static CreateTiledGround(name: string, options: {
  62840. xmin: number;
  62841. zmin: number;
  62842. xmax: number;
  62843. zmax: number;
  62844. subdivisions?: {
  62845. w: number;
  62846. h: number;
  62847. };
  62848. precision?: {
  62849. w: number;
  62850. h: number;
  62851. };
  62852. updatable?: boolean;
  62853. }, scene?: Nullable<Scene>): Mesh;
  62854. /**
  62855. * Creates a ground mesh from a height map
  62856. * * The parameter `url` sets the URL of the height map image resource.
  62857. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62858. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62859. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62860. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62861. * * 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.
  62862. * * 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).
  62863. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62865. * @param name defines the name of the mesh
  62866. * @param url defines the url to the height map
  62867. * @param options defines the options used to create the mesh
  62868. * @param scene defines the hosting scene
  62869. * @returns the ground mesh
  62870. * @see https://doc.babylonjs.com/babylon101/height_map
  62871. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62872. */
  62873. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62874. width?: number;
  62875. height?: number;
  62876. subdivisions?: number;
  62877. minHeight?: number;
  62878. maxHeight?: number;
  62879. colorFilter?: Color3;
  62880. alphaFilter?: number;
  62881. updatable?: boolean;
  62882. onReady?: (mesh: GroundMesh) => void;
  62883. }, scene?: Nullable<Scene>): GroundMesh;
  62884. /**
  62885. * Creates a polygon mesh
  62886. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62887. * * 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
  62888. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62891. * * Remember you can only change the shape positions, not their number when updating a polygon
  62892. * @param name defines the name of the mesh
  62893. * @param options defines the options used to create the mesh
  62894. * @param scene defines the hosting scene
  62895. * @param earcutInjection can be used to inject your own earcut reference
  62896. * @returns the polygon mesh
  62897. */
  62898. static CreatePolygon(name: string, options: {
  62899. shape: Vector3[];
  62900. holes?: Vector3[][];
  62901. depth?: number;
  62902. faceUV?: Vector4[];
  62903. faceColors?: Color4[];
  62904. updatable?: boolean;
  62905. sideOrientation?: number;
  62906. frontUVs?: Vector4;
  62907. backUVs?: Vector4;
  62908. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62909. /**
  62910. * Creates an extruded polygon mesh, with depth in the Y direction.
  62911. * * 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)
  62912. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62913. * @param name defines the name of the mesh
  62914. * @param options defines the options used to create the mesh
  62915. * @param scene defines the hosting scene
  62916. * @param earcutInjection can be used to inject your own earcut reference
  62917. * @returns the polygon mesh
  62918. */
  62919. static ExtrudePolygon(name: string, options: {
  62920. shape: Vector3[];
  62921. holes?: Vector3[][];
  62922. depth?: number;
  62923. faceUV?: Vector4[];
  62924. faceColors?: Color4[];
  62925. updatable?: boolean;
  62926. sideOrientation?: number;
  62927. frontUVs?: Vector4;
  62928. backUVs?: Vector4;
  62929. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62930. /**
  62931. * Creates a tube mesh.
  62932. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62933. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62934. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62935. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62936. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62937. * * 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)
  62938. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62939. * * 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
  62940. * * 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
  62941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62945. * @param name defines the name of the mesh
  62946. * @param options defines the options used to create the mesh
  62947. * @param scene defines the hosting scene
  62948. * @returns the tube mesh
  62949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62950. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62951. */
  62952. static CreateTube(name: string, options: {
  62953. path: Vector3[];
  62954. radius?: number;
  62955. tessellation?: number;
  62956. radiusFunction?: {
  62957. (i: number, distance: number): number;
  62958. };
  62959. cap?: number;
  62960. arc?: number;
  62961. updatable?: boolean;
  62962. sideOrientation?: number;
  62963. frontUVs?: Vector4;
  62964. backUVs?: Vector4;
  62965. instance?: Mesh;
  62966. invertUV?: boolean;
  62967. }, scene?: Nullable<Scene>): Mesh;
  62968. /**
  62969. * Creates a polyhedron mesh
  62970. * * 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
  62971. * * The parameter `size` (positive float, default 1) sets the polygon size
  62972. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62973. * * 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`
  62974. * * 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
  62975. * * 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)`)
  62976. * * 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
  62977. * * 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
  62978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62981. * @param name defines the name of the mesh
  62982. * @param options defines the options used to create the mesh
  62983. * @param scene defines the hosting scene
  62984. * @returns the polyhedron mesh
  62985. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62986. */
  62987. static CreatePolyhedron(name: string, options: {
  62988. type?: number;
  62989. size?: number;
  62990. sizeX?: number;
  62991. sizeY?: number;
  62992. sizeZ?: number;
  62993. custom?: any;
  62994. faceUV?: Vector4[];
  62995. faceColors?: Color4[];
  62996. flat?: boolean;
  62997. updatable?: boolean;
  62998. sideOrientation?: number;
  62999. frontUVs?: Vector4;
  63000. backUVs?: Vector4;
  63001. }, scene?: Nullable<Scene>): Mesh;
  63002. /**
  63003. * Creates a decal mesh.
  63004. * 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
  63005. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63006. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63007. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63008. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63009. * @param name defines the name of the mesh
  63010. * @param sourceMesh defines the mesh where the decal must be applied
  63011. * @param options defines the options used to create the mesh
  63012. * @param scene defines the hosting scene
  63013. * @returns the decal mesh
  63014. * @see https://doc.babylonjs.com/how_to/decals
  63015. */
  63016. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63017. position?: Vector3;
  63018. normal?: Vector3;
  63019. size?: Vector3;
  63020. angle?: number;
  63021. }): Mesh;
  63022. }
  63023. }
  63024. declare module "babylonjs/Meshes/meshSimplification" {
  63025. import { Mesh } from "babylonjs/Meshes/mesh";
  63026. /**
  63027. * A simplifier interface for future simplification implementations
  63028. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63029. */
  63030. export interface ISimplifier {
  63031. /**
  63032. * Simplification of a given mesh according to the given settings.
  63033. * Since this requires computation, it is assumed that the function runs async.
  63034. * @param settings The settings of the simplification, including quality and distance
  63035. * @param successCallback A callback that will be called after the mesh was simplified.
  63036. * @param errorCallback in case of an error, this callback will be called. optional.
  63037. */
  63038. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63039. }
  63040. /**
  63041. * Expected simplification settings.
  63042. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63043. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63044. */
  63045. export interface ISimplificationSettings {
  63046. /**
  63047. * Gets or sets the expected quality
  63048. */
  63049. quality: number;
  63050. /**
  63051. * Gets or sets the distance when this optimized version should be used
  63052. */
  63053. distance: number;
  63054. /**
  63055. * Gets an already optimized mesh
  63056. */
  63057. optimizeMesh?: boolean;
  63058. }
  63059. /**
  63060. * Class used to specify simplification options
  63061. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63062. */
  63063. export class SimplificationSettings implements ISimplificationSettings {
  63064. /** expected quality */
  63065. quality: number;
  63066. /** distance when this optimized version should be used */
  63067. distance: number;
  63068. /** already optimized mesh */
  63069. optimizeMesh?: boolean | undefined;
  63070. /**
  63071. * Creates a SimplificationSettings
  63072. * @param quality expected quality
  63073. * @param distance distance when this optimized version should be used
  63074. * @param optimizeMesh already optimized mesh
  63075. */
  63076. constructor(
  63077. /** expected quality */
  63078. quality: number,
  63079. /** distance when this optimized version should be used */
  63080. distance: number,
  63081. /** already optimized mesh */
  63082. optimizeMesh?: boolean | undefined);
  63083. }
  63084. /**
  63085. * Interface used to define a simplification task
  63086. */
  63087. export interface ISimplificationTask {
  63088. /**
  63089. * Array of settings
  63090. */
  63091. settings: Array<ISimplificationSettings>;
  63092. /**
  63093. * Simplification type
  63094. */
  63095. simplificationType: SimplificationType;
  63096. /**
  63097. * Mesh to simplify
  63098. */
  63099. mesh: Mesh;
  63100. /**
  63101. * Callback called on success
  63102. */
  63103. successCallback?: () => void;
  63104. /**
  63105. * Defines if parallel processing can be used
  63106. */
  63107. parallelProcessing: boolean;
  63108. }
  63109. /**
  63110. * Queue used to order the simplification tasks
  63111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63112. */
  63113. export class SimplificationQueue {
  63114. private _simplificationArray;
  63115. /**
  63116. * Gets a boolean indicating that the process is still running
  63117. */
  63118. running: boolean;
  63119. /**
  63120. * Creates a new queue
  63121. */
  63122. constructor();
  63123. /**
  63124. * Adds a new simplification task
  63125. * @param task defines a task to add
  63126. */
  63127. addTask(task: ISimplificationTask): void;
  63128. /**
  63129. * Execute next task
  63130. */
  63131. executeNext(): void;
  63132. /**
  63133. * Execute a simplification task
  63134. * @param task defines the task to run
  63135. */
  63136. runSimplification(task: ISimplificationTask): void;
  63137. private getSimplifier;
  63138. }
  63139. /**
  63140. * The implemented types of simplification
  63141. * At the moment only Quadratic Error Decimation is implemented
  63142. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63143. */
  63144. export enum SimplificationType {
  63145. /** Quadratic error decimation */
  63146. QUADRATIC = 0
  63147. }
  63148. }
  63149. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63150. import { Scene } from "babylonjs/scene";
  63151. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63152. import { ISceneComponent } from "babylonjs/sceneComponent";
  63153. module "babylonjs/scene" {
  63154. interface Scene {
  63155. /** @hidden (Backing field) */
  63156. _simplificationQueue: SimplificationQueue;
  63157. /**
  63158. * Gets or sets the simplification queue attached to the scene
  63159. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63160. */
  63161. simplificationQueue: SimplificationQueue;
  63162. }
  63163. }
  63164. module "babylonjs/Meshes/mesh" {
  63165. interface Mesh {
  63166. /**
  63167. * Simplify the mesh according to the given array of settings.
  63168. * Function will return immediately and will simplify async
  63169. * @param settings a collection of simplification settings
  63170. * @param parallelProcessing should all levels calculate parallel or one after the other
  63171. * @param simplificationType the type of simplification to run
  63172. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63173. * @returns the current mesh
  63174. */
  63175. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63176. }
  63177. }
  63178. /**
  63179. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63180. * created in a scene
  63181. */
  63182. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63183. /**
  63184. * The component name helpfull to identify the component in the list of scene components.
  63185. */
  63186. readonly name: string;
  63187. /**
  63188. * The scene the component belongs to.
  63189. */
  63190. scene: Scene;
  63191. /**
  63192. * Creates a new instance of the component for the given scene
  63193. * @param scene Defines the scene to register the component in
  63194. */
  63195. constructor(scene: Scene);
  63196. /**
  63197. * Registers the component in a given scene
  63198. */
  63199. register(): void;
  63200. /**
  63201. * Rebuilds the elements related to this component in case of
  63202. * context lost for instance.
  63203. */
  63204. rebuild(): void;
  63205. /**
  63206. * Disposes the component and the associated ressources
  63207. */
  63208. dispose(): void;
  63209. private _beforeCameraUpdate;
  63210. }
  63211. }
  63212. declare module "babylonjs/Meshes/Builders/index" {
  63213. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63214. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63215. export * from "babylonjs/Meshes/Builders/discBuilder";
  63216. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63217. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63218. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63219. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63220. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63221. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63222. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63223. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63224. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63225. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63226. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63227. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63228. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63229. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63230. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63231. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63232. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63233. }
  63234. declare module "babylonjs/Meshes/index" {
  63235. export * from "babylonjs/Meshes/abstractMesh";
  63236. export * from "babylonjs/Meshes/buffer";
  63237. export * from "babylonjs/Meshes/Compression/index";
  63238. export * from "babylonjs/Meshes/csg";
  63239. export * from "babylonjs/Meshes/geometry";
  63240. export * from "babylonjs/Meshes/groundMesh";
  63241. export * from "babylonjs/Meshes/trailMesh";
  63242. export * from "babylonjs/Meshes/instancedMesh";
  63243. export * from "babylonjs/Meshes/linesMesh";
  63244. export * from "babylonjs/Meshes/mesh";
  63245. export * from "babylonjs/Meshes/mesh.vertexData";
  63246. export * from "babylonjs/Meshes/meshBuilder";
  63247. export * from "babylonjs/Meshes/meshSimplification";
  63248. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63249. export * from "babylonjs/Meshes/polygonMesh";
  63250. export * from "babylonjs/Meshes/subMesh";
  63251. export * from "babylonjs/Meshes/meshLODLevel";
  63252. export * from "babylonjs/Meshes/transformNode";
  63253. export * from "babylonjs/Meshes/Builders/index";
  63254. export * from "babylonjs/Meshes/dataBuffer";
  63255. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63256. }
  63257. declare module "babylonjs/Morph/index" {
  63258. export * from "babylonjs/Morph/morphTarget";
  63259. export * from "babylonjs/Morph/morphTargetManager";
  63260. }
  63261. declare module "babylonjs/Navigation/INavigationEngine" {
  63262. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63263. import { Vector3 } from "babylonjs/Maths/math";
  63264. import { Mesh } from "babylonjs/Meshes/mesh";
  63265. import { Scene } from "babylonjs/scene";
  63266. /**
  63267. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63268. */
  63269. export interface INavigationEnginePlugin {
  63270. /**
  63271. * plugin name
  63272. */
  63273. name: string;
  63274. /**
  63275. * Creates a navigation mesh
  63276. * @param meshes array of all the geometry used to compute the navigatio mesh
  63277. * @param parameters bunch of parameters used to filter geometry
  63278. */
  63279. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63280. /**
  63281. * Create a navigation mesh debug mesh
  63282. * @param scene is where the mesh will be added
  63283. * @returns debug display mesh
  63284. */
  63285. createDebugNavMesh(scene: Scene): Mesh;
  63286. /**
  63287. * Get a navigation mesh constrained position, closest to the parameter position
  63288. * @param position world position
  63289. * @returns the closest point to position constrained by the navigation mesh
  63290. */
  63291. getClosestPoint(position: Vector3): Vector3;
  63292. /**
  63293. * Get a navigation mesh constrained position, within a particular radius
  63294. * @param position world position
  63295. * @param maxRadius the maximum distance to the constrained world position
  63296. * @returns the closest point to position constrained by the navigation mesh
  63297. */
  63298. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63299. /**
  63300. * Compute the final position from a segment made of destination-position
  63301. * @param position world position
  63302. * @param destination world position
  63303. * @returns the resulting point along the navmesh
  63304. */
  63305. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63306. /**
  63307. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63308. * @param start world position
  63309. * @param end world position
  63310. * @returns array containing world position composing the path
  63311. */
  63312. computePath(start: Vector3, end: Vector3): Vector3[];
  63313. /**
  63314. * If this plugin is supported
  63315. * @returns true if plugin is supported
  63316. */
  63317. isSupported(): boolean;
  63318. /**
  63319. * Create a new Crowd so you can add agents
  63320. * @param maxAgents the maximum agent count in the crowd
  63321. * @param maxAgentRadius the maximum radius an agent can have
  63322. * @param scene to attach the crowd to
  63323. * @returns the crowd you can add agents to
  63324. */
  63325. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63326. /**
  63327. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63328. * The queries will try to find a solution within those bounds
  63329. * default is (1,1,1)
  63330. * @param extent x,y,z value that define the extent around the queries point of reference
  63331. */
  63332. setDefaultQueryExtent(extent: Vector3): void;
  63333. /**
  63334. * Get the Bounding box extent specified by setDefaultQueryExtent
  63335. * @returns the box extent values
  63336. */
  63337. getDefaultQueryExtent(): Vector3;
  63338. /**
  63339. * Release all resources
  63340. */
  63341. dispose(): void;
  63342. }
  63343. /**
  63344. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63345. */
  63346. export interface ICrowd {
  63347. /**
  63348. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63349. * You can attach anything to that node. The node position is updated in the scene update tick.
  63350. * @param pos world position that will be constrained by the navigation mesh
  63351. * @param parameters agent parameters
  63352. * @param transform hooked to the agent that will be update by the scene
  63353. * @returns agent index
  63354. */
  63355. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63356. /**
  63357. * Returns the agent position in world space
  63358. * @param index agent index returned by addAgent
  63359. * @returns world space position
  63360. */
  63361. getAgentPosition(index: number): Vector3;
  63362. /**
  63363. * Gets the agent velocity in world space
  63364. * @param index agent index returned by addAgent
  63365. * @returns world space velocity
  63366. */
  63367. getAgentVelocity(index: number): Vector3;
  63368. /**
  63369. * remove a particular agent previously created
  63370. * @param index agent index returned by addAgent
  63371. */
  63372. removeAgent(index: number): void;
  63373. /**
  63374. * get the list of all agents attached to this crowd
  63375. * @returns list of agent indices
  63376. */
  63377. getAgents(): number[];
  63378. /**
  63379. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63380. * @param deltaTime in seconds
  63381. */
  63382. update(deltaTime: number): void;
  63383. /**
  63384. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63385. * @param index agent index returned by addAgent
  63386. * @param destination targeted world position
  63387. */
  63388. agentGoto(index: number, destination: Vector3): void;
  63389. /**
  63390. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63391. * The queries will try to find a solution within those bounds
  63392. * default is (1,1,1)
  63393. * @param extent x,y,z value that define the extent around the queries point of reference
  63394. */
  63395. setDefaultQueryExtent(extent: Vector3): void;
  63396. /**
  63397. * Get the Bounding box extent specified by setDefaultQueryExtent
  63398. * @returns the box extent values
  63399. */
  63400. getDefaultQueryExtent(): Vector3;
  63401. /**
  63402. * Release all resources
  63403. */
  63404. dispose(): void;
  63405. }
  63406. /**
  63407. * Configures an agent
  63408. */
  63409. export interface IAgentParameters {
  63410. /**
  63411. * Agent radius. [Limit: >= 0]
  63412. */
  63413. radius: number;
  63414. /**
  63415. * Agent height. [Limit: > 0]
  63416. */
  63417. height: number;
  63418. /**
  63419. * Maximum allowed acceleration. [Limit: >= 0]
  63420. */
  63421. maxAcceleration: number;
  63422. /**
  63423. * Maximum allowed speed. [Limit: >= 0]
  63424. */
  63425. maxSpeed: number;
  63426. /**
  63427. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63428. */
  63429. collisionQueryRange: number;
  63430. /**
  63431. * The path visibility optimization range. [Limit: > 0]
  63432. */
  63433. pathOptimizationRange: number;
  63434. /**
  63435. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63436. */
  63437. separationWeight: number;
  63438. }
  63439. /**
  63440. * Configures the navigation mesh creation
  63441. */
  63442. export interface INavMeshParameters {
  63443. /**
  63444. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63445. */
  63446. cs: number;
  63447. /**
  63448. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63449. */
  63450. ch: number;
  63451. /**
  63452. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63453. */
  63454. walkableSlopeAngle: number;
  63455. /**
  63456. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63457. * be considered walkable. [Limit: >= 3] [Units: vx]
  63458. */
  63459. walkableHeight: number;
  63460. /**
  63461. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63462. */
  63463. walkableClimb: number;
  63464. /**
  63465. * The distance to erode/shrink the walkable area of the heightfield away from
  63466. * obstructions. [Limit: >=0] [Units: vx]
  63467. */
  63468. walkableRadius: number;
  63469. /**
  63470. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63471. */
  63472. maxEdgeLen: number;
  63473. /**
  63474. * The maximum distance a simplfied contour's border edges should deviate
  63475. * the original raw contour. [Limit: >=0] [Units: vx]
  63476. */
  63477. maxSimplificationError: number;
  63478. /**
  63479. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63480. */
  63481. minRegionArea: number;
  63482. /**
  63483. * Any regions with a span count smaller than this value will, if possible,
  63484. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63485. */
  63486. mergeRegionArea: number;
  63487. /**
  63488. * The maximum number of vertices allowed for polygons generated during the
  63489. * contour to polygon conversion process. [Limit: >= 3]
  63490. */
  63491. maxVertsPerPoly: number;
  63492. /**
  63493. * Sets the sampling distance to use when generating the detail mesh.
  63494. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63495. */
  63496. detailSampleDist: number;
  63497. /**
  63498. * The maximum distance the detail mesh surface should deviate from heightfield
  63499. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63500. */
  63501. detailSampleMaxError: number;
  63502. }
  63503. }
  63504. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63505. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63506. import { Mesh } from "babylonjs/Meshes/mesh";
  63507. import { Scene } from "babylonjs/scene";
  63508. import { Vector3 } from "babylonjs/Maths/math";
  63509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63510. /**
  63511. * RecastJS navigation plugin
  63512. */
  63513. export class RecastJSPlugin implements INavigationEnginePlugin {
  63514. /**
  63515. * Reference to the Recast library
  63516. */
  63517. bjsRECAST: any;
  63518. /**
  63519. * plugin name
  63520. */
  63521. name: string;
  63522. /**
  63523. * the first navmesh created. We might extend this to support multiple navmeshes
  63524. */
  63525. navMesh: any;
  63526. /**
  63527. * Initializes the recastJS plugin
  63528. * @param recastInjection can be used to inject your own recast reference
  63529. */
  63530. constructor(recastInjection?: any);
  63531. /**
  63532. * Creates a navigation mesh
  63533. * @param meshes array of all the geometry used to compute the navigatio mesh
  63534. * @param parameters bunch of parameters used to filter geometry
  63535. */
  63536. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63537. /**
  63538. * Create a navigation mesh debug mesh
  63539. * @param scene is where the mesh will be added
  63540. * @returns debug display mesh
  63541. */
  63542. createDebugNavMesh(scene: Scene): Mesh;
  63543. /**
  63544. * Get a navigation mesh constrained position, closest to the parameter position
  63545. * @param position world position
  63546. * @returns the closest point to position constrained by the navigation mesh
  63547. */
  63548. getClosestPoint(position: Vector3): Vector3;
  63549. /**
  63550. * Get a navigation mesh constrained position, within a particular radius
  63551. * @param position world position
  63552. * @param maxRadius the maximum distance to the constrained world position
  63553. * @returns the closest point to position constrained by the navigation mesh
  63554. */
  63555. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63556. /**
  63557. * Compute the final position from a segment made of destination-position
  63558. * @param position world position
  63559. * @param destination world position
  63560. * @returns the resulting point along the navmesh
  63561. */
  63562. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63563. /**
  63564. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63565. * @param start world position
  63566. * @param end world position
  63567. * @returns array containing world position composing the path
  63568. */
  63569. computePath(start: Vector3, end: Vector3): Vector3[];
  63570. /**
  63571. * Create a new Crowd so you can add agents
  63572. * @param maxAgents the maximum agent count in the crowd
  63573. * @param maxAgentRadius the maximum radius an agent can have
  63574. * @param scene to attach the crowd to
  63575. * @returns the crowd you can add agents to
  63576. */
  63577. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63578. /**
  63579. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63580. * The queries will try to find a solution within those bounds
  63581. * default is (1,1,1)
  63582. * @param extent x,y,z value that define the extent around the queries point of reference
  63583. */
  63584. setDefaultQueryExtent(extent: Vector3): void;
  63585. /**
  63586. * Get the Bounding box extent specified by setDefaultQueryExtent
  63587. * @returns the box extent values
  63588. */
  63589. getDefaultQueryExtent(): Vector3;
  63590. /**
  63591. * Disposes
  63592. */
  63593. dispose(): void;
  63594. /**
  63595. * If this plugin is supported
  63596. * @returns true if plugin is supported
  63597. */
  63598. isSupported(): boolean;
  63599. }
  63600. /**
  63601. * Recast detour crowd implementation
  63602. */
  63603. export class RecastJSCrowd implements ICrowd {
  63604. /**
  63605. * Recast/detour plugin
  63606. */
  63607. bjsRECASTPlugin: RecastJSPlugin;
  63608. /**
  63609. * Link to the detour crowd
  63610. */
  63611. recastCrowd: any;
  63612. /**
  63613. * One transform per agent
  63614. */
  63615. transforms: TransformNode[];
  63616. /**
  63617. * All agents created
  63618. */
  63619. agents: number[];
  63620. /**
  63621. * Link to the scene is kept to unregister the crowd from the scene
  63622. */
  63623. private _scene;
  63624. /**
  63625. * Observer for crowd updates
  63626. */
  63627. private _onBeforeAnimationsObserver;
  63628. /**
  63629. * Constructor
  63630. * @param plugin recastJS plugin
  63631. * @param maxAgents the maximum agent count in the crowd
  63632. * @param maxAgentRadius the maximum radius an agent can have
  63633. * @param scene to attach the crowd to
  63634. * @returns the crowd you can add agents to
  63635. */
  63636. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63637. /**
  63638. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63639. * You can attach anything to that node. The node position is updated in the scene update tick.
  63640. * @param pos world position that will be constrained by the navigation mesh
  63641. * @param parameters agent parameters
  63642. * @param transform hooked to the agent that will be update by the scene
  63643. * @returns agent index
  63644. */
  63645. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63646. /**
  63647. * Returns the agent position in world space
  63648. * @param index agent index returned by addAgent
  63649. * @returns world space position
  63650. */
  63651. getAgentPosition(index: number): Vector3;
  63652. /**
  63653. * Returns the agent velocity in world space
  63654. * @param index agent index returned by addAgent
  63655. * @returns world space velocity
  63656. */
  63657. getAgentVelocity(index: number): Vector3;
  63658. /**
  63659. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63660. * @param index agent index returned by addAgent
  63661. * @param destination targeted world position
  63662. */
  63663. agentGoto(index: number, destination: Vector3): void;
  63664. /**
  63665. * remove a particular agent previously created
  63666. * @param index agent index returned by addAgent
  63667. */
  63668. removeAgent(index: number): void;
  63669. /**
  63670. * get the list of all agents attached to this crowd
  63671. * @returns list of agent indices
  63672. */
  63673. getAgents(): number[];
  63674. /**
  63675. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63676. * @param deltaTime in seconds
  63677. */
  63678. update(deltaTime: number): void;
  63679. /**
  63680. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63681. * The queries will try to find a solution within those bounds
  63682. * default is (1,1,1)
  63683. * @param extent x,y,z value that define the extent around the queries point of reference
  63684. */
  63685. setDefaultQueryExtent(extent: Vector3): void;
  63686. /**
  63687. * Get the Bounding box extent specified by setDefaultQueryExtent
  63688. * @returns the box extent values
  63689. */
  63690. getDefaultQueryExtent(): Vector3;
  63691. /**
  63692. * Release all resources
  63693. */
  63694. dispose(): void;
  63695. }
  63696. }
  63697. declare module "babylonjs/Navigation/Plugins/index" {
  63698. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63699. }
  63700. declare module "babylonjs/Navigation/index" {
  63701. export * from "babylonjs/Navigation/INavigationEngine";
  63702. export * from "babylonjs/Navigation/Plugins/index";
  63703. }
  63704. declare module "babylonjs/Offline/database" {
  63705. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63706. /**
  63707. * Class used to enable access to IndexedDB
  63708. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63709. */
  63710. export class Database implements IOfflineProvider {
  63711. private _callbackManifestChecked;
  63712. private _currentSceneUrl;
  63713. private _db;
  63714. private _enableSceneOffline;
  63715. private _enableTexturesOffline;
  63716. private _manifestVersionFound;
  63717. private _mustUpdateRessources;
  63718. private _hasReachedQuota;
  63719. private _isSupported;
  63720. private _idbFactory;
  63721. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63722. private static IsUASupportingBlobStorage;
  63723. /**
  63724. * Gets a boolean indicating if Database storate is enabled (off by default)
  63725. */
  63726. static IDBStorageEnabled: boolean;
  63727. /**
  63728. * Gets a boolean indicating if scene must be saved in the database
  63729. */
  63730. get enableSceneOffline(): boolean;
  63731. /**
  63732. * Gets a boolean indicating if textures must be saved in the database
  63733. */
  63734. get enableTexturesOffline(): boolean;
  63735. /**
  63736. * Creates a new Database
  63737. * @param urlToScene defines the url to load the scene
  63738. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63739. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63740. */
  63741. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63742. private static _ParseURL;
  63743. private static _ReturnFullUrlLocation;
  63744. private _checkManifestFile;
  63745. /**
  63746. * Open the database and make it available
  63747. * @param successCallback defines the callback to call on success
  63748. * @param errorCallback defines the callback to call on error
  63749. */
  63750. open(successCallback: () => void, errorCallback: () => void): void;
  63751. /**
  63752. * Loads an image from the database
  63753. * @param url defines the url to load from
  63754. * @param image defines the target DOM image
  63755. */
  63756. loadImage(url: string, image: HTMLImageElement): void;
  63757. private _loadImageFromDBAsync;
  63758. private _saveImageIntoDBAsync;
  63759. private _checkVersionFromDB;
  63760. private _loadVersionFromDBAsync;
  63761. private _saveVersionIntoDBAsync;
  63762. /**
  63763. * Loads a file from database
  63764. * @param url defines the URL to load from
  63765. * @param sceneLoaded defines a callback to call on success
  63766. * @param progressCallBack defines a callback to call when progress changed
  63767. * @param errorCallback defines a callback to call on error
  63768. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63769. */
  63770. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63771. private _loadFileAsync;
  63772. private _saveFileAsync;
  63773. /**
  63774. * Validates if xhr data is correct
  63775. * @param xhr defines the request to validate
  63776. * @param dataType defines the expected data type
  63777. * @returns true if data is correct
  63778. */
  63779. private static _ValidateXHRData;
  63780. }
  63781. }
  63782. declare module "babylonjs/Offline/index" {
  63783. export * from "babylonjs/Offline/database";
  63784. export * from "babylonjs/Offline/IOfflineProvider";
  63785. }
  63786. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63787. /** @hidden */
  63788. export var gpuUpdateParticlesPixelShader: {
  63789. name: string;
  63790. shader: string;
  63791. };
  63792. }
  63793. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63794. /** @hidden */
  63795. export var gpuUpdateParticlesVertexShader: {
  63796. name: string;
  63797. shader: string;
  63798. };
  63799. }
  63800. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63801. /** @hidden */
  63802. export var clipPlaneFragmentDeclaration2: {
  63803. name: string;
  63804. shader: string;
  63805. };
  63806. }
  63807. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63808. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63809. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63810. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63811. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63812. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63813. /** @hidden */
  63814. export var gpuRenderParticlesPixelShader: {
  63815. name: string;
  63816. shader: string;
  63817. };
  63818. }
  63819. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63820. /** @hidden */
  63821. export var clipPlaneVertexDeclaration2: {
  63822. name: string;
  63823. shader: string;
  63824. };
  63825. }
  63826. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63827. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63829. /** @hidden */
  63830. export var gpuRenderParticlesVertexShader: {
  63831. name: string;
  63832. shader: string;
  63833. };
  63834. }
  63835. declare module "babylonjs/Particles/gpuParticleSystem" {
  63836. import { Nullable } from "babylonjs/types";
  63837. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63838. import { Observable } from "babylonjs/Misc/observable";
  63839. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63841. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63842. import { Scene, IDisposable } from "babylonjs/scene";
  63843. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63844. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63845. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63846. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63847. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63848. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63849. /**
  63850. * This represents a GPU particle system in Babylon
  63851. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63852. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63853. */
  63854. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63855. /**
  63856. * The layer mask we are rendering the particles through.
  63857. */
  63858. layerMask: number;
  63859. private _capacity;
  63860. private _activeCount;
  63861. private _currentActiveCount;
  63862. private _accumulatedCount;
  63863. private _renderEffect;
  63864. private _updateEffect;
  63865. private _buffer0;
  63866. private _buffer1;
  63867. private _spriteBuffer;
  63868. private _updateVAO;
  63869. private _renderVAO;
  63870. private _targetIndex;
  63871. private _sourceBuffer;
  63872. private _targetBuffer;
  63873. private _engine;
  63874. private _currentRenderId;
  63875. private _started;
  63876. private _stopped;
  63877. private _timeDelta;
  63878. private _randomTexture;
  63879. private _randomTexture2;
  63880. private _attributesStrideSize;
  63881. private _updateEffectOptions;
  63882. private _randomTextureSize;
  63883. private _actualFrame;
  63884. private readonly _rawTextureWidth;
  63885. /**
  63886. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63887. */
  63888. static get IsSupported(): boolean;
  63889. /**
  63890. * An event triggered when the system is disposed.
  63891. */
  63892. onDisposeObservable: Observable<GPUParticleSystem>;
  63893. /**
  63894. * Gets the maximum number of particles active at the same time.
  63895. * @returns The max number of active particles.
  63896. */
  63897. getCapacity(): number;
  63898. /**
  63899. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63900. * to override the particles.
  63901. */
  63902. forceDepthWrite: boolean;
  63903. /**
  63904. * Gets or set the number of active particles
  63905. */
  63906. get activeParticleCount(): number;
  63907. set activeParticleCount(value: number);
  63908. private _preWarmDone;
  63909. /**
  63910. * Is this system ready to be used/rendered
  63911. * @return true if the system is ready
  63912. */
  63913. isReady(): boolean;
  63914. /**
  63915. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63916. * @returns True if it has been started, otherwise false.
  63917. */
  63918. isStarted(): boolean;
  63919. /**
  63920. * Starts the particle system and begins to emit
  63921. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63922. */
  63923. start(delay?: number): void;
  63924. /**
  63925. * Stops the particle system.
  63926. */
  63927. stop(): void;
  63928. /**
  63929. * Remove all active particles
  63930. */
  63931. reset(): void;
  63932. /**
  63933. * Returns the string "GPUParticleSystem"
  63934. * @returns a string containing the class name
  63935. */
  63936. getClassName(): string;
  63937. private _colorGradientsTexture;
  63938. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63939. /**
  63940. * Adds a new color gradient
  63941. * @param gradient defines the gradient to use (between 0 and 1)
  63942. * @param color1 defines the color to affect to the specified gradient
  63943. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63944. * @returns the current particle system
  63945. */
  63946. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63947. /**
  63948. * Remove a specific color gradient
  63949. * @param gradient defines the gradient to remove
  63950. * @returns the current particle system
  63951. */
  63952. removeColorGradient(gradient: number): GPUParticleSystem;
  63953. private _angularSpeedGradientsTexture;
  63954. private _sizeGradientsTexture;
  63955. private _velocityGradientsTexture;
  63956. private _limitVelocityGradientsTexture;
  63957. private _dragGradientsTexture;
  63958. private _addFactorGradient;
  63959. /**
  63960. * Adds a new size gradient
  63961. * @param gradient defines the gradient to use (between 0 and 1)
  63962. * @param factor defines the size factor to affect to the specified gradient
  63963. * @returns the current particle system
  63964. */
  63965. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63966. /**
  63967. * Remove a specific size gradient
  63968. * @param gradient defines the gradient to remove
  63969. * @returns the current particle system
  63970. */
  63971. removeSizeGradient(gradient: number): GPUParticleSystem;
  63972. /**
  63973. * Adds a new angular speed gradient
  63974. * @param gradient defines the gradient to use (between 0 and 1)
  63975. * @param factor defines the angular speed to affect to the specified gradient
  63976. * @returns the current particle system
  63977. */
  63978. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63979. /**
  63980. * Remove a specific angular speed gradient
  63981. * @param gradient defines the gradient to remove
  63982. * @returns the current particle system
  63983. */
  63984. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63985. /**
  63986. * Adds a new velocity gradient
  63987. * @param gradient defines the gradient to use (between 0 and 1)
  63988. * @param factor defines the velocity to affect to the specified gradient
  63989. * @returns the current particle system
  63990. */
  63991. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63992. /**
  63993. * Remove a specific velocity gradient
  63994. * @param gradient defines the gradient to remove
  63995. * @returns the current particle system
  63996. */
  63997. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63998. /**
  63999. * Adds a new limit velocity gradient
  64000. * @param gradient defines the gradient to use (between 0 and 1)
  64001. * @param factor defines the limit velocity value to affect to the specified gradient
  64002. * @returns the current particle system
  64003. */
  64004. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64005. /**
  64006. * Remove a specific limit velocity gradient
  64007. * @param gradient defines the gradient to remove
  64008. * @returns the current particle system
  64009. */
  64010. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64011. /**
  64012. * Adds a new drag gradient
  64013. * @param gradient defines the gradient to use (between 0 and 1)
  64014. * @param factor defines the drag value to affect to the specified gradient
  64015. * @returns the current particle system
  64016. */
  64017. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64018. /**
  64019. * Remove a specific drag gradient
  64020. * @param gradient defines the gradient to remove
  64021. * @returns the current particle system
  64022. */
  64023. removeDragGradient(gradient: number): GPUParticleSystem;
  64024. /**
  64025. * Not supported by GPUParticleSystem
  64026. * @param gradient defines the gradient to use (between 0 and 1)
  64027. * @param factor defines the emit rate value to affect to the specified gradient
  64028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64029. * @returns the current particle system
  64030. */
  64031. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64032. /**
  64033. * Not supported by GPUParticleSystem
  64034. * @param gradient defines the gradient to remove
  64035. * @returns the current particle system
  64036. */
  64037. removeEmitRateGradient(gradient: number): IParticleSystem;
  64038. /**
  64039. * Not supported by GPUParticleSystem
  64040. * @param gradient defines the gradient to use (between 0 and 1)
  64041. * @param factor defines the start size value to affect to the specified gradient
  64042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64043. * @returns the current particle system
  64044. */
  64045. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64046. /**
  64047. * Not supported by GPUParticleSystem
  64048. * @param gradient defines the gradient to remove
  64049. * @returns the current particle system
  64050. */
  64051. removeStartSizeGradient(gradient: number): IParticleSystem;
  64052. /**
  64053. * Not supported by GPUParticleSystem
  64054. * @param gradient defines the gradient to use (between 0 and 1)
  64055. * @param min defines the color remap minimal range
  64056. * @param max defines the color remap maximal range
  64057. * @returns the current particle system
  64058. */
  64059. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64060. /**
  64061. * Not supported by GPUParticleSystem
  64062. * @param gradient defines the gradient to remove
  64063. * @returns the current particle system
  64064. */
  64065. removeColorRemapGradient(): IParticleSystem;
  64066. /**
  64067. * Not supported by GPUParticleSystem
  64068. * @param gradient defines the gradient to use (between 0 and 1)
  64069. * @param min defines the alpha remap minimal range
  64070. * @param max defines the alpha remap maximal range
  64071. * @returns the current particle system
  64072. */
  64073. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64074. /**
  64075. * Not supported by GPUParticleSystem
  64076. * @param gradient defines the gradient to remove
  64077. * @returns the current particle system
  64078. */
  64079. removeAlphaRemapGradient(): IParticleSystem;
  64080. /**
  64081. * Not supported by GPUParticleSystem
  64082. * @param gradient defines the gradient to use (between 0 and 1)
  64083. * @param color defines the color to affect to the specified gradient
  64084. * @returns the current particle system
  64085. */
  64086. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64087. /**
  64088. * Not supported by GPUParticleSystem
  64089. * @param gradient defines the gradient to remove
  64090. * @returns the current particle system
  64091. */
  64092. removeRampGradient(): IParticleSystem;
  64093. /**
  64094. * Not supported by GPUParticleSystem
  64095. * @returns the list of ramp gradients
  64096. */
  64097. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64098. /**
  64099. * Not supported by GPUParticleSystem
  64100. * Gets or sets a boolean indicating that ramp gradients must be used
  64101. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64102. */
  64103. get useRampGradients(): boolean;
  64104. set useRampGradients(value: boolean);
  64105. /**
  64106. * Not supported by GPUParticleSystem
  64107. * @param gradient defines the gradient to use (between 0 and 1)
  64108. * @param factor defines the life time factor to affect to the specified gradient
  64109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64110. * @returns the current particle system
  64111. */
  64112. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64113. /**
  64114. * Not supported by GPUParticleSystem
  64115. * @param gradient defines the gradient to remove
  64116. * @returns the current particle system
  64117. */
  64118. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64119. /**
  64120. * Instantiates a GPU particle system.
  64121. * 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.
  64122. * @param name The name of the particle system
  64123. * @param options The options used to create the system
  64124. * @param scene The scene the particle system belongs to
  64125. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64126. */
  64127. constructor(name: string, options: Partial<{
  64128. capacity: number;
  64129. randomTextureSize: number;
  64130. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64131. protected _reset(): void;
  64132. private _createUpdateVAO;
  64133. private _createRenderVAO;
  64134. private _initialize;
  64135. /** @hidden */
  64136. _recreateUpdateEffect(): void;
  64137. /** @hidden */
  64138. _recreateRenderEffect(): void;
  64139. /**
  64140. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64141. * @param preWarm defines if we are in the pre-warmimg phase
  64142. */
  64143. animate(preWarm?: boolean): void;
  64144. private _createFactorGradientTexture;
  64145. private _createSizeGradientTexture;
  64146. private _createAngularSpeedGradientTexture;
  64147. private _createVelocityGradientTexture;
  64148. private _createLimitVelocityGradientTexture;
  64149. private _createDragGradientTexture;
  64150. private _createColorGradientTexture;
  64151. /**
  64152. * Renders the particle system in its current state
  64153. * @param preWarm defines if the system should only update the particles but not render them
  64154. * @returns the current number of particles
  64155. */
  64156. render(preWarm?: boolean): number;
  64157. /**
  64158. * Rebuilds the particle system
  64159. */
  64160. rebuild(): void;
  64161. private _releaseBuffers;
  64162. private _releaseVAOs;
  64163. /**
  64164. * Disposes the particle system and free the associated resources
  64165. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64166. */
  64167. dispose(disposeTexture?: boolean): void;
  64168. /**
  64169. * Clones the particle system.
  64170. * @param name The name of the cloned object
  64171. * @param newEmitter The new emitter to use
  64172. * @returns the cloned particle system
  64173. */
  64174. clone(name: string, newEmitter: any): GPUParticleSystem;
  64175. /**
  64176. * Serializes the particle system to a JSON object.
  64177. * @returns the JSON object
  64178. */
  64179. serialize(): any;
  64180. /**
  64181. * Parses a JSON object to create a GPU particle system.
  64182. * @param parsedParticleSystem The JSON object to parse
  64183. * @param scene The scene to create the particle system in
  64184. * @param rootUrl The root url to use to load external dependencies like texture
  64185. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64186. * @returns the parsed GPU particle system
  64187. */
  64188. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64189. }
  64190. }
  64191. declare module "babylonjs/Particles/particleSystemSet" {
  64192. import { Nullable } from "babylonjs/types";
  64193. import { Color3 } from "babylonjs/Maths/math.color";
  64194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64196. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64197. import { Scene, IDisposable } from "babylonjs/scene";
  64198. /**
  64199. * Represents a set of particle systems working together to create a specific effect
  64200. */
  64201. export class ParticleSystemSet implements IDisposable {
  64202. /**
  64203. * Gets or sets base Assets URL
  64204. */
  64205. static BaseAssetsUrl: string;
  64206. private _emitterCreationOptions;
  64207. private _emitterNode;
  64208. /**
  64209. * Gets the particle system list
  64210. */
  64211. systems: IParticleSystem[];
  64212. /**
  64213. * Gets the emitter node used with this set
  64214. */
  64215. get emitterNode(): Nullable<TransformNode>;
  64216. /**
  64217. * Creates a new emitter mesh as a sphere
  64218. * @param options defines the options used to create the sphere
  64219. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64220. * @param scene defines the hosting scene
  64221. */
  64222. setEmitterAsSphere(options: {
  64223. diameter: number;
  64224. segments: number;
  64225. color: Color3;
  64226. }, renderingGroupId: number, scene: Scene): void;
  64227. /**
  64228. * Starts all particle systems of the set
  64229. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64230. */
  64231. start(emitter?: AbstractMesh): void;
  64232. /**
  64233. * Release all associated resources
  64234. */
  64235. dispose(): void;
  64236. /**
  64237. * Serialize the set into a JSON compatible object
  64238. * @returns a JSON compatible representation of the set
  64239. */
  64240. serialize(): any;
  64241. /**
  64242. * Parse a new ParticleSystemSet from a serialized source
  64243. * @param data defines a JSON compatible representation of the set
  64244. * @param scene defines the hosting scene
  64245. * @param gpu defines if we want GPU particles or CPU particles
  64246. * @returns a new ParticleSystemSet
  64247. */
  64248. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64249. }
  64250. }
  64251. declare module "babylonjs/Particles/particleHelper" {
  64252. import { Nullable } from "babylonjs/types";
  64253. import { Scene } from "babylonjs/scene";
  64254. import { Vector3 } from "babylonjs/Maths/math.vector";
  64255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64256. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64257. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64258. /**
  64259. * This class is made for on one-liner static method to help creating particle system set.
  64260. */
  64261. export class ParticleHelper {
  64262. /**
  64263. * Gets or sets base Assets URL
  64264. */
  64265. static BaseAssetsUrl: string;
  64266. /**
  64267. * Create a default particle system that you can tweak
  64268. * @param emitter defines the emitter to use
  64269. * @param capacity defines the system capacity (default is 500 particles)
  64270. * @param scene defines the hosting scene
  64271. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64272. * @returns the new Particle system
  64273. */
  64274. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64275. /**
  64276. * This is the main static method (one-liner) of this helper to create different particle systems
  64277. * @param type This string represents the type to the particle system to create
  64278. * @param scene The scene where the particle system should live
  64279. * @param gpu If the system will use gpu
  64280. * @returns the ParticleSystemSet created
  64281. */
  64282. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64283. /**
  64284. * Static function used to export a particle system to a ParticleSystemSet variable.
  64285. * Please note that the emitter shape is not exported
  64286. * @param systems defines the particle systems to export
  64287. * @returns the created particle system set
  64288. */
  64289. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64290. }
  64291. }
  64292. declare module "babylonjs/Particles/particleSystemComponent" {
  64293. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64294. import { Effect } from "babylonjs/Materials/effect";
  64295. import "babylonjs/Shaders/particles.vertex";
  64296. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64297. module "babylonjs/Engines/engine" {
  64298. interface Engine {
  64299. /**
  64300. * Create an effect to use with particle systems.
  64301. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64302. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64303. * @param uniformsNames defines a list of attribute names
  64304. * @param samplers defines an array of string used to represent textures
  64305. * @param defines defines the string containing the defines to use to compile the shaders
  64306. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64307. * @param onCompiled defines a function to call when the effect creation is successful
  64308. * @param onError defines a function to call when the effect creation has failed
  64309. * @returns the new Effect
  64310. */
  64311. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64312. }
  64313. }
  64314. module "babylonjs/Meshes/mesh" {
  64315. interface Mesh {
  64316. /**
  64317. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64318. * @returns an array of IParticleSystem
  64319. */
  64320. getEmittedParticleSystems(): IParticleSystem[];
  64321. /**
  64322. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64323. * @returns an array of IParticleSystem
  64324. */
  64325. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64326. }
  64327. }
  64328. /**
  64329. * @hidden
  64330. */
  64331. export var _IDoNeedToBeInTheBuild: number;
  64332. }
  64333. declare module "babylonjs/Particles/pointsCloudSystem" {
  64334. import { Color4 } from "babylonjs/Maths/math";
  64335. import { Mesh } from "babylonjs/Meshes/mesh";
  64336. import { Scene, IDisposable } from "babylonjs/scene";
  64337. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64338. /** Defines the 4 color options */
  64339. export enum PointColor {
  64340. /** color value */
  64341. Color = 2,
  64342. /** uv value */
  64343. UV = 1,
  64344. /** random value */
  64345. Random = 0,
  64346. /** stated value */
  64347. Stated = 3
  64348. }
  64349. /**
  64350. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64351. * 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.
  64352. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64353. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64354. *
  64355. * Full documentation here : TO BE ENTERED
  64356. */
  64357. export class PointsCloudSystem implements IDisposable {
  64358. /**
  64359. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64360. * Example : var p = SPS.particles[i];
  64361. */
  64362. particles: CloudPoint[];
  64363. /**
  64364. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64365. */
  64366. nbParticles: number;
  64367. /**
  64368. * This a counter for your own usage. It's not set by any SPS functions.
  64369. */
  64370. counter: number;
  64371. /**
  64372. * The PCS name. This name is also given to the underlying mesh.
  64373. */
  64374. name: string;
  64375. /**
  64376. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64377. */
  64378. mesh: Mesh;
  64379. /**
  64380. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64381. * Please read :
  64382. */
  64383. vars: any;
  64384. /**
  64385. * @hidden
  64386. */
  64387. _size: number;
  64388. private _scene;
  64389. private _promises;
  64390. private _positions;
  64391. private _indices;
  64392. private _normals;
  64393. private _colors;
  64394. private _uvs;
  64395. private _indices32;
  64396. private _positions32;
  64397. private _colors32;
  64398. private _uvs32;
  64399. private _updatable;
  64400. private _isVisibilityBoxLocked;
  64401. private _alwaysVisible;
  64402. private _groups;
  64403. private _groupCounter;
  64404. private _computeParticleColor;
  64405. private _computeParticleTexture;
  64406. private _computeParticleRotation;
  64407. private _computeBoundingBox;
  64408. private _isReady;
  64409. /**
  64410. * Creates a PCS (Points Cloud System) object
  64411. * @param name (String) is the PCS name, this will be the underlying mesh name
  64412. * @param pointSize (number) is the size for each point
  64413. * @param scene (Scene) is the scene in which the PCS is added
  64414. * @param options defines the options of the PCS e.g.
  64415. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64416. */
  64417. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64418. updatable?: boolean;
  64419. });
  64420. /**
  64421. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64422. * If no points were added to the PCS, the returned mesh is just a single point.
  64423. * @returns a promise for the created mesh
  64424. */
  64425. buildMeshAsync(): Promise<Mesh>;
  64426. /**
  64427. * @hidden
  64428. */
  64429. private _buildMesh;
  64430. private _addParticle;
  64431. private _randomUnitVector;
  64432. private _getColorIndicesForCoord;
  64433. private _setPointsColorOrUV;
  64434. private _colorFromTexture;
  64435. private _calculateDensity;
  64436. /**
  64437. * Adds points to the PCS in random positions within a unit sphere
  64438. * @param nb (positive integer) the number of particles to be created from this model
  64439. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64440. * @returns the number of groups in the system
  64441. */
  64442. addPoints(nb: number, pointFunction?: any): number;
  64443. /**
  64444. * Adds points to the PCS from the surface of the model shape
  64445. * @param mesh is any Mesh object that will be used as a surface model for the points
  64446. * @param nb (positive integer) the number of particles to be created from this model
  64447. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64448. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64449. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64450. * @returns the number of groups in the system
  64451. */
  64452. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64453. /**
  64454. * Adds points to the PCS inside the model shape
  64455. * @param mesh is any Mesh object that will be used as a surface model for the points
  64456. * @param nb (positive integer) the number of particles to be created from this model
  64457. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64458. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64459. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64460. * @returns the number of groups in the system
  64461. */
  64462. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64463. /**
  64464. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64465. * This method calls `updateParticle()` for each particle of the SPS.
  64466. * For an animated SPS, it is usually called within the render loop.
  64467. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64468. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64469. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64470. * @returns the PCS.
  64471. */
  64472. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64473. /**
  64474. * Disposes the PCS.
  64475. */
  64476. dispose(): void;
  64477. /**
  64478. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64479. * doc :
  64480. * @returns the PCS.
  64481. */
  64482. refreshVisibleSize(): PointsCloudSystem;
  64483. /**
  64484. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64485. * @param size the size (float) of the visibility box
  64486. * note : this doesn't lock the PCS mesh bounding box.
  64487. * doc :
  64488. */
  64489. setVisibilityBox(size: number): void;
  64490. /**
  64491. * Gets whether the PCS is always visible or not
  64492. * doc :
  64493. */
  64494. get isAlwaysVisible(): boolean;
  64495. /**
  64496. * Sets the PCS as always visible or not
  64497. * doc :
  64498. */
  64499. set isAlwaysVisible(val: boolean);
  64500. /**
  64501. * Tells to `setParticles()` to compute the particle rotations or not
  64502. * Default value : false. The PCS is faster when it's set to false
  64503. * Note : particle rotations are only applied to parent particles
  64504. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64505. */
  64506. set computeParticleRotation(val: boolean);
  64507. /**
  64508. * Tells to `setParticles()` to compute the particle colors or not.
  64509. * Default value : true. The PCS is faster when it's set to false.
  64510. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64511. */
  64512. set computeParticleColor(val: boolean);
  64513. set computeParticleTexture(val: boolean);
  64514. /**
  64515. * Gets if `setParticles()` computes the particle colors or not.
  64516. * Default value : false. The PCS is faster when it's set to false.
  64517. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64518. */
  64519. get computeParticleColor(): boolean;
  64520. /**
  64521. * Gets if `setParticles()` computes the particle textures or not.
  64522. * Default value : false. The PCS is faster when it's set to false.
  64523. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64524. */
  64525. get computeParticleTexture(): boolean;
  64526. /**
  64527. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64528. */
  64529. set computeBoundingBox(val: boolean);
  64530. /**
  64531. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64532. */
  64533. get computeBoundingBox(): boolean;
  64534. /**
  64535. * This function does nothing. It may be overwritten to set all the particle first values.
  64536. * The PCS doesn't call this function, you may have to call it by your own.
  64537. * doc :
  64538. */
  64539. initParticles(): void;
  64540. /**
  64541. * This function does nothing. It may be overwritten to recycle a particle
  64542. * The PCS doesn't call this function, you can to call it
  64543. * doc :
  64544. * @param particle The particle to recycle
  64545. * @returns the recycled particle
  64546. */
  64547. recycleParticle(particle: CloudPoint): CloudPoint;
  64548. /**
  64549. * Updates a particle : this function should be overwritten by the user.
  64550. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64551. * doc :
  64552. * @example : just set a particle position or velocity and recycle conditions
  64553. * @param particle The particle to update
  64554. * @returns the updated particle
  64555. */
  64556. updateParticle(particle: CloudPoint): CloudPoint;
  64557. /**
  64558. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64559. * This does nothing and may be overwritten by the user.
  64560. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64561. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64562. * @param update the boolean update value actually passed to setParticles()
  64563. */
  64564. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64565. /**
  64566. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64567. * This will be passed three parameters.
  64568. * This does nothing and may be overwritten by the user.
  64569. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64570. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64571. * @param update the boolean update value actually passed to setParticles()
  64572. */
  64573. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64574. }
  64575. }
  64576. declare module "babylonjs/Particles/cloudPoint" {
  64577. import { Nullable } from "babylonjs/types";
  64578. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64579. import { Mesh } from "babylonjs/Meshes/mesh";
  64580. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64581. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64582. /**
  64583. * Represents one particle of a points cloud system.
  64584. */
  64585. export class CloudPoint {
  64586. /**
  64587. * particle global index
  64588. */
  64589. idx: number;
  64590. /**
  64591. * The color of the particle
  64592. */
  64593. color: Nullable<Color4>;
  64594. /**
  64595. * The world space position of the particle.
  64596. */
  64597. position: Vector3;
  64598. /**
  64599. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64600. */
  64601. rotation: Vector3;
  64602. /**
  64603. * The world space rotation quaternion of the particle.
  64604. */
  64605. rotationQuaternion: Nullable<Quaternion>;
  64606. /**
  64607. * The uv of the particle.
  64608. */
  64609. uv: Nullable<Vector2>;
  64610. /**
  64611. * The current speed of the particle.
  64612. */
  64613. velocity: Vector3;
  64614. /**
  64615. * The pivot point in the particle local space.
  64616. */
  64617. pivot: Vector3;
  64618. /**
  64619. * Must the particle be translated from its pivot point in its local space ?
  64620. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64621. * Default : false
  64622. */
  64623. translateFromPivot: boolean;
  64624. /**
  64625. * Index of this particle in the global "positions" array (Internal use)
  64626. * @hidden
  64627. */
  64628. _pos: number;
  64629. /**
  64630. * @hidden Index of this particle in the global "indices" array (Internal use)
  64631. */
  64632. _ind: number;
  64633. /**
  64634. * Group this particle belongs to
  64635. */
  64636. _group: PointsGroup;
  64637. /**
  64638. * Group id of this particle
  64639. */
  64640. groupId: number;
  64641. /**
  64642. * Index of the particle in its group id (Internal use)
  64643. */
  64644. idxInGroup: number;
  64645. /**
  64646. * @hidden Particle BoundingInfo object (Internal use)
  64647. */
  64648. _boundingInfo: BoundingInfo;
  64649. /**
  64650. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64651. */
  64652. _pcs: PointsCloudSystem;
  64653. /**
  64654. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64655. */
  64656. _stillInvisible: boolean;
  64657. /**
  64658. * @hidden Last computed particle rotation matrix
  64659. */
  64660. _rotationMatrix: number[];
  64661. /**
  64662. * Parent particle Id, if any.
  64663. * Default null.
  64664. */
  64665. parentId: Nullable<number>;
  64666. /**
  64667. * @hidden Internal global position in the PCS.
  64668. */
  64669. _globalPosition: Vector3;
  64670. /**
  64671. * Creates a Point Cloud object.
  64672. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64673. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64674. * @param group (PointsGroup) is the group the particle belongs to
  64675. * @param groupId (integer) is the group identifier in the PCS.
  64676. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64677. * @param pcs defines the PCS it is associated to
  64678. */
  64679. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64680. /**
  64681. * get point size
  64682. */
  64683. get size(): Vector3;
  64684. /**
  64685. * Set point size
  64686. */
  64687. set size(scale: Vector3);
  64688. /**
  64689. * Legacy support, changed quaternion to rotationQuaternion
  64690. */
  64691. get quaternion(): Nullable<Quaternion>;
  64692. /**
  64693. * Legacy support, changed quaternion to rotationQuaternion
  64694. */
  64695. set quaternion(q: Nullable<Quaternion>);
  64696. /**
  64697. * Returns a boolean. True if the particle intersects a mesh, else false
  64698. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64699. * @param target is the object (point or mesh) what the intersection is computed against
  64700. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64701. * @returns true if it intersects
  64702. */
  64703. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64704. /**
  64705. * get the rotation matrix of the particle
  64706. * @hidden
  64707. */
  64708. getRotationMatrix(m: Matrix): void;
  64709. }
  64710. /**
  64711. * Represents a group of points in a points cloud system
  64712. * * PCS internal tool, don't use it manually.
  64713. */
  64714. export class PointsGroup {
  64715. /**
  64716. * The group id
  64717. * @hidden
  64718. */
  64719. groupID: number;
  64720. /**
  64721. * image data for group (internal use)
  64722. * @hidden
  64723. */
  64724. _groupImageData: Nullable<ArrayBufferView>;
  64725. /**
  64726. * Image Width (internal use)
  64727. * @hidden
  64728. */
  64729. _groupImgWidth: number;
  64730. /**
  64731. * Image Height (internal use)
  64732. * @hidden
  64733. */
  64734. _groupImgHeight: number;
  64735. /**
  64736. * Custom position function (internal use)
  64737. * @hidden
  64738. */
  64739. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64740. /**
  64741. * density per facet for surface points
  64742. * @hidden
  64743. */
  64744. _groupDensity: number[];
  64745. /**
  64746. * Only when points are colored by texture carries pointer to texture list array
  64747. * @hidden
  64748. */
  64749. _textureNb: number;
  64750. /**
  64751. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64752. * PCS internal tool, don't use it manually.
  64753. * @hidden
  64754. */
  64755. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64756. }
  64757. }
  64758. declare module "babylonjs/Particles/index" {
  64759. export * from "babylonjs/Particles/baseParticleSystem";
  64760. export * from "babylonjs/Particles/EmitterTypes/index";
  64761. export * from "babylonjs/Particles/gpuParticleSystem";
  64762. export * from "babylonjs/Particles/IParticleSystem";
  64763. export * from "babylonjs/Particles/particle";
  64764. export * from "babylonjs/Particles/particleHelper";
  64765. export * from "babylonjs/Particles/particleSystem";
  64766. export * from "babylonjs/Particles/particleSystemComponent";
  64767. export * from "babylonjs/Particles/particleSystemSet";
  64768. export * from "babylonjs/Particles/solidParticle";
  64769. export * from "babylonjs/Particles/solidParticleSystem";
  64770. export * from "babylonjs/Particles/cloudPoint";
  64771. export * from "babylonjs/Particles/pointsCloudSystem";
  64772. export * from "babylonjs/Particles/subEmitter";
  64773. }
  64774. declare module "babylonjs/Physics/physicsEngineComponent" {
  64775. import { Nullable } from "babylonjs/types";
  64776. import { Observable, Observer } from "babylonjs/Misc/observable";
  64777. import { Vector3 } from "babylonjs/Maths/math.vector";
  64778. import { Mesh } from "babylonjs/Meshes/mesh";
  64779. import { ISceneComponent } from "babylonjs/sceneComponent";
  64780. import { Scene } from "babylonjs/scene";
  64781. import { Node } from "babylonjs/node";
  64782. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64783. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64784. module "babylonjs/scene" {
  64785. interface Scene {
  64786. /** @hidden (Backing field) */
  64787. _physicsEngine: Nullable<IPhysicsEngine>;
  64788. /** @hidden */
  64789. _physicsTimeAccumulator: number;
  64790. /**
  64791. * Gets the current physics engine
  64792. * @returns a IPhysicsEngine or null if none attached
  64793. */
  64794. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64795. /**
  64796. * Enables physics to the current scene
  64797. * @param gravity defines the scene's gravity for the physics engine
  64798. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64799. * @return a boolean indicating if the physics engine was initialized
  64800. */
  64801. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64802. /**
  64803. * Disables and disposes the physics engine associated with the scene
  64804. */
  64805. disablePhysicsEngine(): void;
  64806. /**
  64807. * Gets a boolean indicating if there is an active physics engine
  64808. * @returns a boolean indicating if there is an active physics engine
  64809. */
  64810. isPhysicsEnabled(): boolean;
  64811. /**
  64812. * Deletes a physics compound impostor
  64813. * @param compound defines the compound to delete
  64814. */
  64815. deleteCompoundImpostor(compound: any): void;
  64816. /**
  64817. * An event triggered when physic simulation is about to be run
  64818. */
  64819. onBeforePhysicsObservable: Observable<Scene>;
  64820. /**
  64821. * An event triggered when physic simulation has been done
  64822. */
  64823. onAfterPhysicsObservable: Observable<Scene>;
  64824. }
  64825. }
  64826. module "babylonjs/Meshes/abstractMesh" {
  64827. interface AbstractMesh {
  64828. /** @hidden */
  64829. _physicsImpostor: Nullable<PhysicsImpostor>;
  64830. /**
  64831. * Gets or sets impostor used for physic simulation
  64832. * @see http://doc.babylonjs.com/features/physics_engine
  64833. */
  64834. physicsImpostor: Nullable<PhysicsImpostor>;
  64835. /**
  64836. * Gets the current physics impostor
  64837. * @see http://doc.babylonjs.com/features/physics_engine
  64838. * @returns a physics impostor or null
  64839. */
  64840. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64841. /** Apply a physic impulse to the mesh
  64842. * @param force defines the force to apply
  64843. * @param contactPoint defines where to apply the force
  64844. * @returns the current mesh
  64845. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64846. */
  64847. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64848. /**
  64849. * Creates a physic joint between two meshes
  64850. * @param otherMesh defines the other mesh to use
  64851. * @param pivot1 defines the pivot to use on this mesh
  64852. * @param pivot2 defines the pivot to use on the other mesh
  64853. * @param options defines additional options (can be plugin dependent)
  64854. * @returns the current mesh
  64855. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64856. */
  64857. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64858. /** @hidden */
  64859. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64860. }
  64861. }
  64862. /**
  64863. * Defines the physics engine scene component responsible to manage a physics engine
  64864. */
  64865. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64866. /**
  64867. * The component name helpful to identify the component in the list of scene components.
  64868. */
  64869. readonly name: string;
  64870. /**
  64871. * The scene the component belongs to.
  64872. */
  64873. scene: Scene;
  64874. /**
  64875. * Creates a new instance of the component for the given scene
  64876. * @param scene Defines the scene to register the component in
  64877. */
  64878. constructor(scene: Scene);
  64879. /**
  64880. * Registers the component in a given scene
  64881. */
  64882. register(): void;
  64883. /**
  64884. * Rebuilds the elements related to this component in case of
  64885. * context lost for instance.
  64886. */
  64887. rebuild(): void;
  64888. /**
  64889. * Disposes the component and the associated ressources
  64890. */
  64891. dispose(): void;
  64892. }
  64893. }
  64894. declare module "babylonjs/Physics/physicsHelper" {
  64895. import { Nullable } from "babylonjs/types";
  64896. import { Vector3 } from "babylonjs/Maths/math.vector";
  64897. import { Mesh } from "babylonjs/Meshes/mesh";
  64898. import { Scene } from "babylonjs/scene";
  64899. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64900. /**
  64901. * A helper for physics simulations
  64902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64903. */
  64904. export class PhysicsHelper {
  64905. private _scene;
  64906. private _physicsEngine;
  64907. /**
  64908. * Initializes the Physics helper
  64909. * @param scene Babylon.js scene
  64910. */
  64911. constructor(scene: Scene);
  64912. /**
  64913. * Applies a radial explosion impulse
  64914. * @param origin the origin of the explosion
  64915. * @param radiusOrEventOptions the radius or the options of radial explosion
  64916. * @param strength the explosion strength
  64917. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64918. * @returns A physics radial explosion event, or null
  64919. */
  64920. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64921. /**
  64922. * Applies a radial explosion force
  64923. * @param origin the origin of the explosion
  64924. * @param radiusOrEventOptions the radius or the options of radial explosion
  64925. * @param strength the explosion strength
  64926. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64927. * @returns A physics radial explosion event, or null
  64928. */
  64929. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64930. /**
  64931. * Creates a gravitational field
  64932. * @param origin the origin of the explosion
  64933. * @param radiusOrEventOptions the radius or the options of radial explosion
  64934. * @param strength the explosion strength
  64935. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64936. * @returns A physics gravitational field event, or null
  64937. */
  64938. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64939. /**
  64940. * Creates a physics updraft event
  64941. * @param origin the origin of the updraft
  64942. * @param radiusOrEventOptions the radius or the options of the updraft
  64943. * @param strength the strength of the updraft
  64944. * @param height the height of the updraft
  64945. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64946. * @returns A physics updraft event, or null
  64947. */
  64948. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64949. /**
  64950. * Creates a physics vortex event
  64951. * @param origin the of the vortex
  64952. * @param radiusOrEventOptions the radius or the options of the vortex
  64953. * @param strength the strength of the vortex
  64954. * @param height the height of the vortex
  64955. * @returns a Physics vortex event, or null
  64956. * A physics vortex event or null
  64957. */
  64958. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64959. }
  64960. /**
  64961. * Represents a physics radial explosion event
  64962. */
  64963. class PhysicsRadialExplosionEvent {
  64964. private _scene;
  64965. private _options;
  64966. private _sphere;
  64967. private _dataFetched;
  64968. /**
  64969. * Initializes a radial explosioin event
  64970. * @param _scene BabylonJS scene
  64971. * @param _options The options for the vortex event
  64972. */
  64973. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64974. /**
  64975. * Returns the data related to the radial explosion event (sphere).
  64976. * @returns The radial explosion event data
  64977. */
  64978. getData(): PhysicsRadialExplosionEventData;
  64979. /**
  64980. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64981. * @param impostor A physics imposter
  64982. * @param origin the origin of the explosion
  64983. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64984. */
  64985. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64986. /**
  64987. * Triggers affecterd impostors callbacks
  64988. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64989. */
  64990. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64991. /**
  64992. * Disposes the sphere.
  64993. * @param force Specifies if the sphere should be disposed by force
  64994. */
  64995. dispose(force?: boolean): void;
  64996. /*** Helpers ***/
  64997. private _prepareSphere;
  64998. private _intersectsWithSphere;
  64999. }
  65000. /**
  65001. * Represents a gravitational field event
  65002. */
  65003. class PhysicsGravitationalFieldEvent {
  65004. private _physicsHelper;
  65005. private _scene;
  65006. private _origin;
  65007. private _options;
  65008. private _tickCallback;
  65009. private _sphere;
  65010. private _dataFetched;
  65011. /**
  65012. * Initializes the physics gravitational field event
  65013. * @param _physicsHelper A physics helper
  65014. * @param _scene BabylonJS scene
  65015. * @param _origin The origin position of the gravitational field event
  65016. * @param _options The options for the vortex event
  65017. */
  65018. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65019. /**
  65020. * Returns the data related to the gravitational field event (sphere).
  65021. * @returns A gravitational field event
  65022. */
  65023. getData(): PhysicsGravitationalFieldEventData;
  65024. /**
  65025. * Enables the gravitational field.
  65026. */
  65027. enable(): void;
  65028. /**
  65029. * Disables the gravitational field.
  65030. */
  65031. disable(): void;
  65032. /**
  65033. * Disposes the sphere.
  65034. * @param force The force to dispose from the gravitational field event
  65035. */
  65036. dispose(force?: boolean): void;
  65037. private _tick;
  65038. }
  65039. /**
  65040. * Represents a physics updraft event
  65041. */
  65042. class PhysicsUpdraftEvent {
  65043. private _scene;
  65044. private _origin;
  65045. private _options;
  65046. private _physicsEngine;
  65047. private _originTop;
  65048. private _originDirection;
  65049. private _tickCallback;
  65050. private _cylinder;
  65051. private _cylinderPosition;
  65052. private _dataFetched;
  65053. /**
  65054. * Initializes the physics updraft event
  65055. * @param _scene BabylonJS scene
  65056. * @param _origin The origin position of the updraft
  65057. * @param _options The options for the updraft event
  65058. */
  65059. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65060. /**
  65061. * Returns the data related to the updraft event (cylinder).
  65062. * @returns A physics updraft event
  65063. */
  65064. getData(): PhysicsUpdraftEventData;
  65065. /**
  65066. * Enables the updraft.
  65067. */
  65068. enable(): void;
  65069. /**
  65070. * Disables the updraft.
  65071. */
  65072. disable(): void;
  65073. /**
  65074. * Disposes the cylinder.
  65075. * @param force Specifies if the updraft should be disposed by force
  65076. */
  65077. dispose(force?: boolean): void;
  65078. private getImpostorHitData;
  65079. private _tick;
  65080. /*** Helpers ***/
  65081. private _prepareCylinder;
  65082. private _intersectsWithCylinder;
  65083. }
  65084. /**
  65085. * Represents a physics vortex event
  65086. */
  65087. class PhysicsVortexEvent {
  65088. private _scene;
  65089. private _origin;
  65090. private _options;
  65091. private _physicsEngine;
  65092. private _originTop;
  65093. private _tickCallback;
  65094. private _cylinder;
  65095. private _cylinderPosition;
  65096. private _dataFetched;
  65097. /**
  65098. * Initializes the physics vortex event
  65099. * @param _scene The BabylonJS scene
  65100. * @param _origin The origin position of the vortex
  65101. * @param _options The options for the vortex event
  65102. */
  65103. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65104. /**
  65105. * Returns the data related to the vortex event (cylinder).
  65106. * @returns The physics vortex event data
  65107. */
  65108. getData(): PhysicsVortexEventData;
  65109. /**
  65110. * Enables the vortex.
  65111. */
  65112. enable(): void;
  65113. /**
  65114. * Disables the cortex.
  65115. */
  65116. disable(): void;
  65117. /**
  65118. * Disposes the sphere.
  65119. * @param force
  65120. */
  65121. dispose(force?: boolean): void;
  65122. private getImpostorHitData;
  65123. private _tick;
  65124. /*** Helpers ***/
  65125. private _prepareCylinder;
  65126. private _intersectsWithCylinder;
  65127. }
  65128. /**
  65129. * Options fot the radial explosion event
  65130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65131. */
  65132. export class PhysicsRadialExplosionEventOptions {
  65133. /**
  65134. * The radius of the sphere for the radial explosion.
  65135. */
  65136. radius: number;
  65137. /**
  65138. * The strenth of the explosion.
  65139. */
  65140. strength: number;
  65141. /**
  65142. * The strenght of the force in correspondence to the distance of the affected object
  65143. */
  65144. falloff: PhysicsRadialImpulseFalloff;
  65145. /**
  65146. * Sphere options for the radial explosion.
  65147. */
  65148. sphere: {
  65149. segments: number;
  65150. diameter: number;
  65151. };
  65152. /**
  65153. * Sphere options for the radial explosion.
  65154. */
  65155. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65156. }
  65157. /**
  65158. * Options fot the updraft event
  65159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65160. */
  65161. export class PhysicsUpdraftEventOptions {
  65162. /**
  65163. * The radius of the cylinder for the vortex
  65164. */
  65165. radius: number;
  65166. /**
  65167. * The strenth of the updraft.
  65168. */
  65169. strength: number;
  65170. /**
  65171. * The height of the cylinder for the updraft.
  65172. */
  65173. height: number;
  65174. /**
  65175. * The mode for the the updraft.
  65176. */
  65177. updraftMode: PhysicsUpdraftMode;
  65178. }
  65179. /**
  65180. * Options fot the vortex event
  65181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65182. */
  65183. export class PhysicsVortexEventOptions {
  65184. /**
  65185. * The radius of the cylinder for the vortex
  65186. */
  65187. radius: number;
  65188. /**
  65189. * The strenth of the vortex.
  65190. */
  65191. strength: number;
  65192. /**
  65193. * The height of the cylinder for the vortex.
  65194. */
  65195. height: number;
  65196. /**
  65197. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65198. */
  65199. centripetalForceThreshold: number;
  65200. /**
  65201. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65202. */
  65203. centripetalForceMultiplier: number;
  65204. /**
  65205. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65206. */
  65207. centrifugalForceMultiplier: number;
  65208. /**
  65209. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65210. */
  65211. updraftForceMultiplier: number;
  65212. }
  65213. /**
  65214. * The strenght of the force in correspondence to the distance of the affected object
  65215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65216. */
  65217. export enum PhysicsRadialImpulseFalloff {
  65218. /** Defines that impulse is constant in strength across it's whole radius */
  65219. Constant = 0,
  65220. /** Defines that impulse gets weaker if it's further from the origin */
  65221. Linear = 1
  65222. }
  65223. /**
  65224. * The strength of the force in correspondence to the distance of the affected object
  65225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65226. */
  65227. export enum PhysicsUpdraftMode {
  65228. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65229. Center = 0,
  65230. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65231. Perpendicular = 1
  65232. }
  65233. /**
  65234. * Interface for a physics hit data
  65235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65236. */
  65237. export interface PhysicsHitData {
  65238. /**
  65239. * The force applied at the contact point
  65240. */
  65241. force: Vector3;
  65242. /**
  65243. * The contact point
  65244. */
  65245. contactPoint: Vector3;
  65246. /**
  65247. * The distance from the origin to the contact point
  65248. */
  65249. distanceFromOrigin: number;
  65250. }
  65251. /**
  65252. * Interface for radial explosion event data
  65253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65254. */
  65255. export interface PhysicsRadialExplosionEventData {
  65256. /**
  65257. * A sphere used for the radial explosion event
  65258. */
  65259. sphere: Mesh;
  65260. }
  65261. /**
  65262. * Interface for gravitational field event data
  65263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65264. */
  65265. export interface PhysicsGravitationalFieldEventData {
  65266. /**
  65267. * A sphere mesh used for the gravitational field event
  65268. */
  65269. sphere: Mesh;
  65270. }
  65271. /**
  65272. * Interface for updraft event data
  65273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65274. */
  65275. export interface PhysicsUpdraftEventData {
  65276. /**
  65277. * A cylinder used for the updraft event
  65278. */
  65279. cylinder: Mesh;
  65280. }
  65281. /**
  65282. * Interface for vortex event data
  65283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65284. */
  65285. export interface PhysicsVortexEventData {
  65286. /**
  65287. * A cylinder used for the vortex event
  65288. */
  65289. cylinder: Mesh;
  65290. }
  65291. /**
  65292. * Interface for an affected physics impostor
  65293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65294. */
  65295. export interface PhysicsAffectedImpostorWithData {
  65296. /**
  65297. * The impostor affected by the effect
  65298. */
  65299. impostor: PhysicsImpostor;
  65300. /**
  65301. * The data about the hit/horce from the explosion
  65302. */
  65303. hitData: PhysicsHitData;
  65304. }
  65305. }
  65306. declare module "babylonjs/Physics/Plugins/index" {
  65307. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65308. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65309. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65310. }
  65311. declare module "babylonjs/Physics/index" {
  65312. export * from "babylonjs/Physics/IPhysicsEngine";
  65313. export * from "babylonjs/Physics/physicsEngine";
  65314. export * from "babylonjs/Physics/physicsEngineComponent";
  65315. export * from "babylonjs/Physics/physicsHelper";
  65316. export * from "babylonjs/Physics/physicsImpostor";
  65317. export * from "babylonjs/Physics/physicsJoint";
  65318. export * from "babylonjs/Physics/Plugins/index";
  65319. }
  65320. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65321. /** @hidden */
  65322. export var blackAndWhitePixelShader: {
  65323. name: string;
  65324. shader: string;
  65325. };
  65326. }
  65327. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65328. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65329. import { Camera } from "babylonjs/Cameras/camera";
  65330. import { Engine } from "babylonjs/Engines/engine";
  65331. import "babylonjs/Shaders/blackAndWhite.fragment";
  65332. /**
  65333. * Post process used to render in black and white
  65334. */
  65335. export class BlackAndWhitePostProcess extends PostProcess {
  65336. /**
  65337. * Linear about to convert he result to black and white (default: 1)
  65338. */
  65339. degree: number;
  65340. /**
  65341. * Creates a black and white post process
  65342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65343. * @param name The name of the effect.
  65344. * @param options The required width/height ratio to downsize to before computing the render pass.
  65345. * @param camera The camera to apply the render pass to.
  65346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65347. * @param engine The engine which the post process will be applied. (default: current engine)
  65348. * @param reusable If the post process can be reused on the same frame. (default: false)
  65349. */
  65350. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65351. }
  65352. }
  65353. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65354. import { Nullable } from "babylonjs/types";
  65355. import { Camera } from "babylonjs/Cameras/camera";
  65356. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65357. import { Engine } from "babylonjs/Engines/engine";
  65358. /**
  65359. * This represents a set of one or more post processes in Babylon.
  65360. * A post process can be used to apply a shader to a texture after it is rendered.
  65361. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65362. */
  65363. export class PostProcessRenderEffect {
  65364. private _postProcesses;
  65365. private _getPostProcesses;
  65366. private _singleInstance;
  65367. private _cameras;
  65368. private _indicesForCamera;
  65369. /**
  65370. * Name of the effect
  65371. * @hidden
  65372. */
  65373. _name: string;
  65374. /**
  65375. * Instantiates a post process render effect.
  65376. * A post process can be used to apply a shader to a texture after it is rendered.
  65377. * @param engine The engine the effect is tied to
  65378. * @param name The name of the effect
  65379. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65380. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65381. */
  65382. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65383. /**
  65384. * Checks if all the post processes in the effect are supported.
  65385. */
  65386. get isSupported(): boolean;
  65387. /**
  65388. * Updates the current state of the effect
  65389. * @hidden
  65390. */
  65391. _update(): void;
  65392. /**
  65393. * Attaches the effect on cameras
  65394. * @param cameras The camera to attach to.
  65395. * @hidden
  65396. */
  65397. _attachCameras(cameras: Camera): void;
  65398. /**
  65399. * Attaches the effect on cameras
  65400. * @param cameras The camera to attach to.
  65401. * @hidden
  65402. */
  65403. _attachCameras(cameras: Camera[]): void;
  65404. /**
  65405. * Detaches the effect on cameras
  65406. * @param cameras The camera to detatch from.
  65407. * @hidden
  65408. */
  65409. _detachCameras(cameras: Camera): void;
  65410. /**
  65411. * Detatches the effect on cameras
  65412. * @param cameras The camera to detatch from.
  65413. * @hidden
  65414. */
  65415. _detachCameras(cameras: Camera[]): void;
  65416. /**
  65417. * Enables the effect on given cameras
  65418. * @param cameras The camera to enable.
  65419. * @hidden
  65420. */
  65421. _enable(cameras: Camera): void;
  65422. /**
  65423. * Enables the effect on given cameras
  65424. * @param cameras The camera to enable.
  65425. * @hidden
  65426. */
  65427. _enable(cameras: Nullable<Camera[]>): void;
  65428. /**
  65429. * Disables the effect on the given cameras
  65430. * @param cameras The camera to disable.
  65431. * @hidden
  65432. */
  65433. _disable(cameras: Camera): void;
  65434. /**
  65435. * Disables the effect on the given cameras
  65436. * @param cameras The camera to disable.
  65437. * @hidden
  65438. */
  65439. _disable(cameras: Nullable<Camera[]>): void;
  65440. /**
  65441. * Gets a list of the post processes contained in the effect.
  65442. * @param camera The camera to get the post processes on.
  65443. * @returns The list of the post processes in the effect.
  65444. */
  65445. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65446. }
  65447. }
  65448. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65449. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65450. /** @hidden */
  65451. export var extractHighlightsPixelShader: {
  65452. name: string;
  65453. shader: string;
  65454. };
  65455. }
  65456. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65457. import { Nullable } from "babylonjs/types";
  65458. import { Camera } from "babylonjs/Cameras/camera";
  65459. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65460. import { Engine } from "babylonjs/Engines/engine";
  65461. import "babylonjs/Shaders/extractHighlights.fragment";
  65462. /**
  65463. * 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.
  65464. */
  65465. export class ExtractHighlightsPostProcess extends PostProcess {
  65466. /**
  65467. * The luminance threshold, pixels below this value will be set to black.
  65468. */
  65469. threshold: number;
  65470. /** @hidden */
  65471. _exposure: number;
  65472. /**
  65473. * Post process which has the input texture to be used when performing highlight extraction
  65474. * @hidden
  65475. */
  65476. _inputPostProcess: Nullable<PostProcess>;
  65477. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65478. }
  65479. }
  65480. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65481. /** @hidden */
  65482. export var bloomMergePixelShader: {
  65483. name: string;
  65484. shader: string;
  65485. };
  65486. }
  65487. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65488. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65489. import { Nullable } from "babylonjs/types";
  65490. import { Engine } from "babylonjs/Engines/engine";
  65491. import { Camera } from "babylonjs/Cameras/camera";
  65492. import "babylonjs/Shaders/bloomMerge.fragment";
  65493. /**
  65494. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65495. */
  65496. export class BloomMergePostProcess extends PostProcess {
  65497. /** Weight of the bloom to be added to the original input. */
  65498. weight: number;
  65499. /**
  65500. * Creates a new instance of @see BloomMergePostProcess
  65501. * @param name The name of the effect.
  65502. * @param originalFromInput Post process which's input will be used for the merge.
  65503. * @param blurred Blurred highlights post process which's output will be used.
  65504. * @param weight Weight of the bloom to be added to the original input.
  65505. * @param options The required width/height ratio to downsize to before computing the render pass.
  65506. * @param camera The camera to apply the render pass to.
  65507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65508. * @param engine The engine which the post process will be applied. (default: current engine)
  65509. * @param reusable If the post process can be reused on the same frame. (default: false)
  65510. * @param textureType Type of textures used when performing the post process. (default: 0)
  65511. * @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)
  65512. */
  65513. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65514. /** Weight of the bloom to be added to the original input. */
  65515. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65516. }
  65517. }
  65518. declare module "babylonjs/PostProcesses/bloomEffect" {
  65519. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65520. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65521. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65522. import { Camera } from "babylonjs/Cameras/camera";
  65523. import { Scene } from "babylonjs/scene";
  65524. /**
  65525. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65526. */
  65527. export class BloomEffect extends PostProcessRenderEffect {
  65528. private bloomScale;
  65529. /**
  65530. * @hidden Internal
  65531. */
  65532. _effects: Array<PostProcess>;
  65533. /**
  65534. * @hidden Internal
  65535. */
  65536. _downscale: ExtractHighlightsPostProcess;
  65537. private _blurX;
  65538. private _blurY;
  65539. private _merge;
  65540. /**
  65541. * The luminance threshold to find bright areas of the image to bloom.
  65542. */
  65543. get threshold(): number;
  65544. set threshold(value: number);
  65545. /**
  65546. * The strength of the bloom.
  65547. */
  65548. get weight(): number;
  65549. set weight(value: number);
  65550. /**
  65551. * Specifies the size of the bloom blur kernel, relative to the final output size
  65552. */
  65553. get kernel(): number;
  65554. set kernel(value: number);
  65555. /**
  65556. * Creates a new instance of @see BloomEffect
  65557. * @param scene The scene the effect belongs to.
  65558. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65559. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65560. * @param bloomWeight The the strength of bloom.
  65561. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65562. * @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)
  65563. */
  65564. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65565. /**
  65566. * Disposes each of the internal effects for a given camera.
  65567. * @param camera The camera to dispose the effect on.
  65568. */
  65569. disposeEffects(camera: Camera): void;
  65570. /**
  65571. * @hidden Internal
  65572. */
  65573. _updateEffects(): void;
  65574. /**
  65575. * Internal
  65576. * @returns if all the contained post processes are ready.
  65577. * @hidden
  65578. */
  65579. _isReady(): boolean;
  65580. }
  65581. }
  65582. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65583. /** @hidden */
  65584. export var chromaticAberrationPixelShader: {
  65585. name: string;
  65586. shader: string;
  65587. };
  65588. }
  65589. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65590. import { Vector2 } from "babylonjs/Maths/math.vector";
  65591. import { Nullable } from "babylonjs/types";
  65592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65593. import { Camera } from "babylonjs/Cameras/camera";
  65594. import { Engine } from "babylonjs/Engines/engine";
  65595. import "babylonjs/Shaders/chromaticAberration.fragment";
  65596. /**
  65597. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65598. */
  65599. export class ChromaticAberrationPostProcess extends PostProcess {
  65600. /**
  65601. * The amount of seperation of rgb channels (default: 30)
  65602. */
  65603. aberrationAmount: number;
  65604. /**
  65605. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65606. */
  65607. radialIntensity: number;
  65608. /**
  65609. * 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))
  65610. */
  65611. direction: Vector2;
  65612. /**
  65613. * 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))
  65614. */
  65615. centerPosition: Vector2;
  65616. /**
  65617. * Creates a new instance ChromaticAberrationPostProcess
  65618. * @param name The name of the effect.
  65619. * @param screenWidth The width of the screen to apply the effect on.
  65620. * @param screenHeight The height of the screen to apply the effect on.
  65621. * @param options The required width/height ratio to downsize to before computing the render pass.
  65622. * @param camera The camera to apply the render pass to.
  65623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65624. * @param engine The engine which the post process will be applied. (default: current engine)
  65625. * @param reusable If the post process can be reused on the same frame. (default: false)
  65626. * @param textureType Type of textures used when performing the post process. (default: 0)
  65627. * @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)
  65628. */
  65629. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65630. }
  65631. }
  65632. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65633. /** @hidden */
  65634. export var circleOfConfusionPixelShader: {
  65635. name: string;
  65636. shader: string;
  65637. };
  65638. }
  65639. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65640. import { Nullable } from "babylonjs/types";
  65641. import { Engine } from "babylonjs/Engines/engine";
  65642. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65643. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65644. import { Camera } from "babylonjs/Cameras/camera";
  65645. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65646. /**
  65647. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65648. */
  65649. export class CircleOfConfusionPostProcess extends PostProcess {
  65650. /**
  65651. * 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.
  65652. */
  65653. lensSize: number;
  65654. /**
  65655. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65656. */
  65657. fStop: number;
  65658. /**
  65659. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65660. */
  65661. focusDistance: number;
  65662. /**
  65663. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65664. */
  65665. focalLength: number;
  65666. private _depthTexture;
  65667. /**
  65668. * Creates a new instance CircleOfConfusionPostProcess
  65669. * @param name The name of the effect.
  65670. * @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.
  65671. * @param options The required width/height ratio to downsize to before computing the render pass.
  65672. * @param camera The camera to apply the render pass to.
  65673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65674. * @param engine The engine which the post process will be applied. (default: current engine)
  65675. * @param reusable If the post process can be reused on the same frame. (default: false)
  65676. * @param textureType Type of textures used when performing the post process. (default: 0)
  65677. * @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)
  65678. */
  65679. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65680. /**
  65681. * 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.
  65682. */
  65683. set depthTexture(value: RenderTargetTexture);
  65684. }
  65685. }
  65686. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65687. /** @hidden */
  65688. export var colorCorrectionPixelShader: {
  65689. name: string;
  65690. shader: string;
  65691. };
  65692. }
  65693. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65695. import { Engine } from "babylonjs/Engines/engine";
  65696. import { Camera } from "babylonjs/Cameras/camera";
  65697. import "babylonjs/Shaders/colorCorrection.fragment";
  65698. /**
  65699. *
  65700. * This post-process allows the modification of rendered colors by using
  65701. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65702. *
  65703. * The object needs to be provided an url to a texture containing the color
  65704. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65705. * Use an image editing software to tweak the LUT to match your needs.
  65706. *
  65707. * For an example of a color LUT, see here:
  65708. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65709. * For explanations on color grading, see here:
  65710. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65711. *
  65712. */
  65713. export class ColorCorrectionPostProcess extends PostProcess {
  65714. private _colorTableTexture;
  65715. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65716. }
  65717. }
  65718. declare module "babylonjs/Shaders/convolution.fragment" {
  65719. /** @hidden */
  65720. export var convolutionPixelShader: {
  65721. name: string;
  65722. shader: string;
  65723. };
  65724. }
  65725. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65726. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65727. import { Nullable } from "babylonjs/types";
  65728. import { Camera } from "babylonjs/Cameras/camera";
  65729. import { Engine } from "babylonjs/Engines/engine";
  65730. import "babylonjs/Shaders/convolution.fragment";
  65731. /**
  65732. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65733. * input texture to perform effects such as edge detection or sharpening
  65734. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65735. */
  65736. export class ConvolutionPostProcess extends PostProcess {
  65737. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65738. kernel: number[];
  65739. /**
  65740. * Creates a new instance ConvolutionPostProcess
  65741. * @param name The name of the effect.
  65742. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65743. * @param options The required width/height ratio to downsize to before computing the render pass.
  65744. * @param camera The camera to apply the render pass to.
  65745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65746. * @param engine The engine which the post process will be applied. (default: current engine)
  65747. * @param reusable If the post process can be reused on the same frame. (default: false)
  65748. * @param textureType Type of textures used when performing the post process. (default: 0)
  65749. */
  65750. constructor(name: string,
  65751. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65752. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65753. /**
  65754. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65755. */
  65756. static EdgeDetect0Kernel: number[];
  65757. /**
  65758. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65759. */
  65760. static EdgeDetect1Kernel: number[];
  65761. /**
  65762. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65763. */
  65764. static EdgeDetect2Kernel: number[];
  65765. /**
  65766. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65767. */
  65768. static SharpenKernel: number[];
  65769. /**
  65770. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65771. */
  65772. static EmbossKernel: number[];
  65773. /**
  65774. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65775. */
  65776. static GaussianKernel: number[];
  65777. }
  65778. }
  65779. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65780. import { Nullable } from "babylonjs/types";
  65781. import { Vector2 } from "babylonjs/Maths/math.vector";
  65782. import { Camera } from "babylonjs/Cameras/camera";
  65783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65784. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65785. import { Engine } from "babylonjs/Engines/engine";
  65786. import { Scene } from "babylonjs/scene";
  65787. /**
  65788. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65789. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65790. * based on samples that have a large difference in distance than the center pixel.
  65791. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65792. */
  65793. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65794. direction: Vector2;
  65795. /**
  65796. * Creates a new instance CircleOfConfusionPostProcess
  65797. * @param name The name of the effect.
  65798. * @param scene The scene the effect belongs to.
  65799. * @param direction The direction the blur should be applied.
  65800. * @param kernel The size of the kernel used to blur.
  65801. * @param options The required width/height ratio to downsize to before computing the render pass.
  65802. * @param camera The camera to apply the render pass to.
  65803. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65804. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65806. * @param engine The engine which the post process will be applied. (default: current engine)
  65807. * @param reusable If the post process can be reused on the same frame. (default: false)
  65808. * @param textureType Type of textures used when performing the post process. (default: 0)
  65809. * @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)
  65810. */
  65811. 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);
  65812. }
  65813. }
  65814. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65815. /** @hidden */
  65816. export var depthOfFieldMergePixelShader: {
  65817. name: string;
  65818. shader: string;
  65819. };
  65820. }
  65821. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65822. import { Nullable } from "babylonjs/types";
  65823. import { Camera } from "babylonjs/Cameras/camera";
  65824. import { Effect } from "babylonjs/Materials/effect";
  65825. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65826. import { Engine } from "babylonjs/Engines/engine";
  65827. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65828. /**
  65829. * Options to be set when merging outputs from the default pipeline.
  65830. */
  65831. export class DepthOfFieldMergePostProcessOptions {
  65832. /**
  65833. * The original image to merge on top of
  65834. */
  65835. originalFromInput: PostProcess;
  65836. /**
  65837. * Parameters to perform the merge of the depth of field effect
  65838. */
  65839. depthOfField?: {
  65840. circleOfConfusion: PostProcess;
  65841. blurSteps: Array<PostProcess>;
  65842. };
  65843. /**
  65844. * Parameters to perform the merge of bloom effect
  65845. */
  65846. bloom?: {
  65847. blurred: PostProcess;
  65848. weight: number;
  65849. };
  65850. }
  65851. /**
  65852. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65853. */
  65854. export class DepthOfFieldMergePostProcess extends PostProcess {
  65855. private blurSteps;
  65856. /**
  65857. * Creates a new instance of DepthOfFieldMergePostProcess
  65858. * @param name The name of the effect.
  65859. * @param originalFromInput Post process which's input will be used for the merge.
  65860. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65861. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65862. * @param options The required width/height ratio to downsize to before computing the render pass.
  65863. * @param camera The camera to apply the render pass to.
  65864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65865. * @param engine The engine which the post process will be applied. (default: current engine)
  65866. * @param reusable If the post process can be reused on the same frame. (default: false)
  65867. * @param textureType Type of textures used when performing the post process. (default: 0)
  65868. * @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)
  65869. */
  65870. 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);
  65871. /**
  65872. * Updates the effect with the current post process compile time values and recompiles the shader.
  65873. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65874. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65875. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65876. * @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
  65877. * @param onCompiled Called when the shader has been compiled.
  65878. * @param onError Called if there is an error when compiling a shader.
  65879. */
  65880. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65881. }
  65882. }
  65883. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65884. import { Nullable } from "babylonjs/types";
  65885. import { Camera } from "babylonjs/Cameras/camera";
  65886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65888. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65889. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65890. import { Scene } from "babylonjs/scene";
  65891. /**
  65892. * Specifies the level of max blur that should be applied when using the depth of field effect
  65893. */
  65894. export enum DepthOfFieldEffectBlurLevel {
  65895. /**
  65896. * Subtle blur
  65897. */
  65898. Low = 0,
  65899. /**
  65900. * Medium blur
  65901. */
  65902. Medium = 1,
  65903. /**
  65904. * Large blur
  65905. */
  65906. High = 2
  65907. }
  65908. /**
  65909. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65910. */
  65911. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65912. private _circleOfConfusion;
  65913. /**
  65914. * @hidden Internal, blurs from high to low
  65915. */
  65916. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65917. private _depthOfFieldBlurY;
  65918. private _dofMerge;
  65919. /**
  65920. * @hidden Internal post processes in depth of field effect
  65921. */
  65922. _effects: Array<PostProcess>;
  65923. /**
  65924. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65925. */
  65926. set focalLength(value: number);
  65927. get focalLength(): number;
  65928. /**
  65929. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65930. */
  65931. set fStop(value: number);
  65932. get fStop(): number;
  65933. /**
  65934. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65935. */
  65936. set focusDistance(value: number);
  65937. get focusDistance(): number;
  65938. /**
  65939. * 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.
  65940. */
  65941. set lensSize(value: number);
  65942. get lensSize(): number;
  65943. /**
  65944. * Creates a new instance DepthOfFieldEffect
  65945. * @param scene The scene the effect belongs to.
  65946. * @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.
  65947. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65948. * @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)
  65949. */
  65950. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65951. /**
  65952. * Get the current class name of the current effet
  65953. * @returns "DepthOfFieldEffect"
  65954. */
  65955. getClassName(): string;
  65956. /**
  65957. * 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.
  65958. */
  65959. set depthTexture(value: RenderTargetTexture);
  65960. /**
  65961. * Disposes each of the internal effects for a given camera.
  65962. * @param camera The camera to dispose the effect on.
  65963. */
  65964. disposeEffects(camera: Camera): void;
  65965. /**
  65966. * @hidden Internal
  65967. */
  65968. _updateEffects(): void;
  65969. /**
  65970. * Internal
  65971. * @returns if all the contained post processes are ready.
  65972. * @hidden
  65973. */
  65974. _isReady(): boolean;
  65975. }
  65976. }
  65977. declare module "babylonjs/Shaders/displayPass.fragment" {
  65978. /** @hidden */
  65979. export var displayPassPixelShader: {
  65980. name: string;
  65981. shader: string;
  65982. };
  65983. }
  65984. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65985. import { Nullable } from "babylonjs/types";
  65986. import { Camera } from "babylonjs/Cameras/camera";
  65987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65988. import { Engine } from "babylonjs/Engines/engine";
  65989. import "babylonjs/Shaders/displayPass.fragment";
  65990. /**
  65991. * DisplayPassPostProcess which produces an output the same as it's input
  65992. */
  65993. export class DisplayPassPostProcess extends PostProcess {
  65994. /**
  65995. * Creates the DisplayPassPostProcess
  65996. * @param name The name of the effect.
  65997. * @param options The required width/height ratio to downsize to before computing the render pass.
  65998. * @param camera The camera to apply the render pass to.
  65999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66000. * @param engine The engine which the post process will be applied. (default: current engine)
  66001. * @param reusable If the post process can be reused on the same frame. (default: false)
  66002. */
  66003. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66004. }
  66005. }
  66006. declare module "babylonjs/Shaders/filter.fragment" {
  66007. /** @hidden */
  66008. export var filterPixelShader: {
  66009. name: string;
  66010. shader: string;
  66011. };
  66012. }
  66013. declare module "babylonjs/PostProcesses/filterPostProcess" {
  66014. import { Nullable } from "babylonjs/types";
  66015. import { Matrix } from "babylonjs/Maths/math.vector";
  66016. import { Camera } from "babylonjs/Cameras/camera";
  66017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66018. import { Engine } from "babylonjs/Engines/engine";
  66019. import "babylonjs/Shaders/filter.fragment";
  66020. /**
  66021. * Applies a kernel filter to the image
  66022. */
  66023. export class FilterPostProcess extends PostProcess {
  66024. /** The matrix to be applied to the image */
  66025. kernelMatrix: Matrix;
  66026. /**
  66027. *
  66028. * @param name The name of the effect.
  66029. * @param kernelMatrix The matrix to be applied to the image
  66030. * @param options The required width/height ratio to downsize to before computing the render pass.
  66031. * @param camera The camera to apply the render pass to.
  66032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66033. * @param engine The engine which the post process will be applied. (default: current engine)
  66034. * @param reusable If the post process can be reused on the same frame. (default: false)
  66035. */
  66036. constructor(name: string,
  66037. /** The matrix to be applied to the image */
  66038. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66039. }
  66040. }
  66041. declare module "babylonjs/Shaders/fxaa.fragment" {
  66042. /** @hidden */
  66043. export var fxaaPixelShader: {
  66044. name: string;
  66045. shader: string;
  66046. };
  66047. }
  66048. declare module "babylonjs/Shaders/fxaa.vertex" {
  66049. /** @hidden */
  66050. export var fxaaVertexShader: {
  66051. name: string;
  66052. shader: string;
  66053. };
  66054. }
  66055. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66056. import { Nullable } from "babylonjs/types";
  66057. import { Camera } from "babylonjs/Cameras/camera";
  66058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66059. import { Engine } from "babylonjs/Engines/engine";
  66060. import "babylonjs/Shaders/fxaa.fragment";
  66061. import "babylonjs/Shaders/fxaa.vertex";
  66062. /**
  66063. * Fxaa post process
  66064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66065. */
  66066. export class FxaaPostProcess extends PostProcess {
  66067. /** @hidden */
  66068. texelWidth: number;
  66069. /** @hidden */
  66070. texelHeight: number;
  66071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66072. private _getDefines;
  66073. }
  66074. }
  66075. declare module "babylonjs/Shaders/grain.fragment" {
  66076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66077. /** @hidden */
  66078. export var grainPixelShader: {
  66079. name: string;
  66080. shader: string;
  66081. };
  66082. }
  66083. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66084. import { Nullable } from "babylonjs/types";
  66085. import { Camera } from "babylonjs/Cameras/camera";
  66086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66087. import { Engine } from "babylonjs/Engines/engine";
  66088. import "babylonjs/Shaders/grain.fragment";
  66089. /**
  66090. * The GrainPostProcess adds noise to the image at mid luminance levels
  66091. */
  66092. export class GrainPostProcess extends PostProcess {
  66093. /**
  66094. * The intensity of the grain added (default: 30)
  66095. */
  66096. intensity: number;
  66097. /**
  66098. * If the grain should be randomized on every frame
  66099. */
  66100. animated: boolean;
  66101. /**
  66102. * Creates a new instance of @see GrainPostProcess
  66103. * @param name The name of the effect.
  66104. * @param options The required width/height ratio to downsize to before computing the render pass.
  66105. * @param camera The camera to apply the render pass to.
  66106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66107. * @param engine The engine which the post process will be applied. (default: current engine)
  66108. * @param reusable If the post process can be reused on the same frame. (default: false)
  66109. * @param textureType Type of textures used when performing the post process. (default: 0)
  66110. * @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)
  66111. */
  66112. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66113. }
  66114. }
  66115. declare module "babylonjs/Shaders/highlights.fragment" {
  66116. /** @hidden */
  66117. export var highlightsPixelShader: {
  66118. name: string;
  66119. shader: string;
  66120. };
  66121. }
  66122. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66123. import { Nullable } from "babylonjs/types";
  66124. import { Camera } from "babylonjs/Cameras/camera";
  66125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66126. import { Engine } from "babylonjs/Engines/engine";
  66127. import "babylonjs/Shaders/highlights.fragment";
  66128. /**
  66129. * Extracts highlights from the image
  66130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66131. */
  66132. export class HighlightsPostProcess extends PostProcess {
  66133. /**
  66134. * Extracts highlights from the image
  66135. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66136. * @param name The name of the effect.
  66137. * @param options The required width/height ratio to downsize to before computing the render pass.
  66138. * @param camera The camera to apply the render pass to.
  66139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66140. * @param engine The engine which the post process will be applied. (default: current engine)
  66141. * @param reusable If the post process can be reused on the same frame. (default: false)
  66142. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66143. */
  66144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66145. }
  66146. }
  66147. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66148. /** @hidden */
  66149. export var mrtFragmentDeclaration: {
  66150. name: string;
  66151. shader: string;
  66152. };
  66153. }
  66154. declare module "babylonjs/Shaders/geometry.fragment" {
  66155. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66156. /** @hidden */
  66157. export var geometryPixelShader: {
  66158. name: string;
  66159. shader: string;
  66160. };
  66161. }
  66162. declare module "babylonjs/Shaders/geometry.vertex" {
  66163. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66164. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66165. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66166. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66167. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66168. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66169. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66170. /** @hidden */
  66171. export var geometryVertexShader: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66177. import { Matrix } from "babylonjs/Maths/math.vector";
  66178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66179. import { Mesh } from "babylonjs/Meshes/mesh";
  66180. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66181. import { Effect } from "babylonjs/Materials/effect";
  66182. import { Scene } from "babylonjs/scene";
  66183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66184. import "babylonjs/Shaders/geometry.fragment";
  66185. import "babylonjs/Shaders/geometry.vertex";
  66186. /** @hidden */
  66187. interface ISavedTransformationMatrix {
  66188. world: Matrix;
  66189. viewProjection: Matrix;
  66190. }
  66191. /**
  66192. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66193. */
  66194. export class GeometryBufferRenderer {
  66195. /**
  66196. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66197. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66198. */
  66199. static readonly POSITION_TEXTURE_TYPE: number;
  66200. /**
  66201. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66202. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66203. */
  66204. static readonly VELOCITY_TEXTURE_TYPE: number;
  66205. /**
  66206. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66207. * in order to compute objects velocities when enableVelocity is set to "true"
  66208. * @hidden
  66209. */
  66210. _previousTransformationMatrices: {
  66211. [index: number]: ISavedTransformationMatrix;
  66212. };
  66213. /**
  66214. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66215. * in order to compute objects velocities when enableVelocity is set to "true"
  66216. * @hidden
  66217. */
  66218. _previousBonesTransformationMatrices: {
  66219. [index: number]: Float32Array;
  66220. };
  66221. /**
  66222. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66223. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66224. */
  66225. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66226. private _scene;
  66227. private _multiRenderTarget;
  66228. private _ratio;
  66229. private _enablePosition;
  66230. private _enableVelocity;
  66231. private _positionIndex;
  66232. private _velocityIndex;
  66233. protected _effect: Effect;
  66234. protected _cachedDefines: string;
  66235. /**
  66236. * Set the render list (meshes to be rendered) used in the G buffer.
  66237. */
  66238. set renderList(meshes: Mesh[]);
  66239. /**
  66240. * Gets wether or not G buffer are supported by the running hardware.
  66241. * This requires draw buffer supports
  66242. */
  66243. get isSupported(): boolean;
  66244. /**
  66245. * Returns the index of the given texture type in the G-Buffer textures array
  66246. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66247. * @returns the index of the given texture type in the G-Buffer textures array
  66248. */
  66249. getTextureIndex(textureType: number): number;
  66250. /**
  66251. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66252. */
  66253. get enablePosition(): boolean;
  66254. /**
  66255. * Sets whether or not objects positions are enabled for the G buffer.
  66256. */
  66257. set enablePosition(enable: boolean);
  66258. /**
  66259. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66260. */
  66261. get enableVelocity(): boolean;
  66262. /**
  66263. * Sets wether or not objects velocities are enabled for the G buffer.
  66264. */
  66265. set enableVelocity(enable: boolean);
  66266. /**
  66267. * Gets the scene associated with the buffer.
  66268. */
  66269. get scene(): Scene;
  66270. /**
  66271. * Gets the ratio used by the buffer during its creation.
  66272. * How big is the buffer related to the main canvas.
  66273. */
  66274. get ratio(): number;
  66275. /** @hidden */
  66276. static _SceneComponentInitialization: (scene: Scene) => void;
  66277. /**
  66278. * Creates a new G Buffer for the scene
  66279. * @param scene The scene the buffer belongs to
  66280. * @param ratio How big is the buffer related to the main canvas.
  66281. */
  66282. constructor(scene: Scene, ratio?: number);
  66283. /**
  66284. * Checks wether everything is ready to render a submesh to the G buffer.
  66285. * @param subMesh the submesh to check readiness for
  66286. * @param useInstances is the mesh drawn using instance or not
  66287. * @returns true if ready otherwise false
  66288. */
  66289. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66290. /**
  66291. * Gets the current underlying G Buffer.
  66292. * @returns the buffer
  66293. */
  66294. getGBuffer(): MultiRenderTarget;
  66295. /**
  66296. * Gets the number of samples used to render the buffer (anti aliasing).
  66297. */
  66298. get samples(): number;
  66299. /**
  66300. * Sets the number of samples used to render the buffer (anti aliasing).
  66301. */
  66302. set samples(value: number);
  66303. /**
  66304. * Disposes the renderer and frees up associated resources.
  66305. */
  66306. dispose(): void;
  66307. protected _createRenderTargets(): void;
  66308. private _copyBonesTransformationMatrices;
  66309. }
  66310. }
  66311. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66312. import { Nullable } from "babylonjs/types";
  66313. import { Scene } from "babylonjs/scene";
  66314. import { ISceneComponent } from "babylonjs/sceneComponent";
  66315. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66316. module "babylonjs/scene" {
  66317. interface Scene {
  66318. /** @hidden (Backing field) */
  66319. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66320. /**
  66321. * Gets or Sets the current geometry buffer associated to the scene.
  66322. */
  66323. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66324. /**
  66325. * Enables a GeometryBufferRender and associates it with the scene
  66326. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66327. * @returns the GeometryBufferRenderer
  66328. */
  66329. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66330. /**
  66331. * Disables the GeometryBufferRender associated with the scene
  66332. */
  66333. disableGeometryBufferRenderer(): void;
  66334. }
  66335. }
  66336. /**
  66337. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66338. * in several rendering techniques.
  66339. */
  66340. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66341. /**
  66342. * The component name helpful to identify the component in the list of scene components.
  66343. */
  66344. readonly name: string;
  66345. /**
  66346. * The scene the component belongs to.
  66347. */
  66348. scene: Scene;
  66349. /**
  66350. * Creates a new instance of the component for the given scene
  66351. * @param scene Defines the scene to register the component in
  66352. */
  66353. constructor(scene: Scene);
  66354. /**
  66355. * Registers the component in a given scene
  66356. */
  66357. register(): void;
  66358. /**
  66359. * Rebuilds the elements related to this component in case of
  66360. * context lost for instance.
  66361. */
  66362. rebuild(): void;
  66363. /**
  66364. * Disposes the component and the associated ressources
  66365. */
  66366. dispose(): void;
  66367. private _gatherRenderTargets;
  66368. }
  66369. }
  66370. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66371. /** @hidden */
  66372. export var motionBlurPixelShader: {
  66373. name: string;
  66374. shader: string;
  66375. };
  66376. }
  66377. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66378. import { Nullable } from "babylonjs/types";
  66379. import { Camera } from "babylonjs/Cameras/camera";
  66380. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66381. import { Scene } from "babylonjs/scene";
  66382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66383. import "babylonjs/Animations/animatable";
  66384. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66385. import "babylonjs/Shaders/motionBlur.fragment";
  66386. import { Engine } from "babylonjs/Engines/engine";
  66387. /**
  66388. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66389. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66390. * As an example, all you have to do is to create the post-process:
  66391. * var mb = new BABYLON.MotionBlurPostProcess(
  66392. * 'mb', // The name of the effect.
  66393. * scene, // The scene containing the objects to blur according to their velocity.
  66394. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66395. * camera // The camera to apply the render pass to.
  66396. * );
  66397. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66398. */
  66399. export class MotionBlurPostProcess extends PostProcess {
  66400. /**
  66401. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66402. */
  66403. motionStrength: number;
  66404. /**
  66405. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66406. */
  66407. get motionBlurSamples(): number;
  66408. /**
  66409. * Sets the number of iterations to be used for motion blur quality
  66410. */
  66411. set motionBlurSamples(samples: number);
  66412. private _motionBlurSamples;
  66413. private _geometryBufferRenderer;
  66414. /**
  66415. * Creates a new instance MotionBlurPostProcess
  66416. * @param name The name of the effect.
  66417. * @param scene The scene containing the objects to blur according to their velocity.
  66418. * @param options The required width/height ratio to downsize to before computing the render pass.
  66419. * @param camera The camera to apply the render pass to.
  66420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66421. * @param engine The engine which the post process will be applied. (default: current engine)
  66422. * @param reusable If the post process can be reused on the same frame. (default: false)
  66423. * @param textureType Type of textures used when performing the post process. (default: 0)
  66424. * @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)
  66425. */
  66426. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66427. /**
  66428. * Excludes the given skinned mesh from computing bones velocities.
  66429. * 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.
  66430. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66431. */
  66432. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66433. /**
  66434. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66435. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66436. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66437. */
  66438. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66439. /**
  66440. * Disposes the post process.
  66441. * @param camera The camera to dispose the post process on.
  66442. */
  66443. dispose(camera?: Camera): void;
  66444. }
  66445. }
  66446. declare module "babylonjs/Shaders/refraction.fragment" {
  66447. /** @hidden */
  66448. export var refractionPixelShader: {
  66449. name: string;
  66450. shader: string;
  66451. };
  66452. }
  66453. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66454. import { Color3 } from "babylonjs/Maths/math.color";
  66455. import { Camera } from "babylonjs/Cameras/camera";
  66456. import { Texture } from "babylonjs/Materials/Textures/texture";
  66457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66458. import { Engine } from "babylonjs/Engines/engine";
  66459. import "babylonjs/Shaders/refraction.fragment";
  66460. /**
  66461. * Post process which applies a refractin texture
  66462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66463. */
  66464. export class RefractionPostProcess extends PostProcess {
  66465. /** the base color of the refraction (used to taint the rendering) */
  66466. color: Color3;
  66467. /** simulated refraction depth */
  66468. depth: number;
  66469. /** the coefficient of the base color (0 to remove base color tainting) */
  66470. colorLevel: number;
  66471. private _refTexture;
  66472. private _ownRefractionTexture;
  66473. /**
  66474. * Gets or sets the refraction texture
  66475. * Please note that you are responsible for disposing the texture if you set it manually
  66476. */
  66477. get refractionTexture(): Texture;
  66478. set refractionTexture(value: Texture);
  66479. /**
  66480. * Initializes the RefractionPostProcess
  66481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66482. * @param name The name of the effect.
  66483. * @param refractionTextureUrl Url of the refraction texture to use
  66484. * @param color the base color of the refraction (used to taint the rendering)
  66485. * @param depth simulated refraction depth
  66486. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66487. * @param camera The camera to apply the render pass to.
  66488. * @param options The required width/height ratio to downsize to before computing the render pass.
  66489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66490. * @param engine The engine which the post process will be applied. (default: current engine)
  66491. * @param reusable If the post process can be reused on the same frame. (default: false)
  66492. */
  66493. constructor(name: string, refractionTextureUrl: string,
  66494. /** the base color of the refraction (used to taint the rendering) */
  66495. color: Color3,
  66496. /** simulated refraction depth */
  66497. depth: number,
  66498. /** the coefficient of the base color (0 to remove base color tainting) */
  66499. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66500. /**
  66501. * Disposes of the post process
  66502. * @param camera Camera to dispose post process on
  66503. */
  66504. dispose(camera: Camera): void;
  66505. }
  66506. }
  66507. declare module "babylonjs/Shaders/sharpen.fragment" {
  66508. /** @hidden */
  66509. export var sharpenPixelShader: {
  66510. name: string;
  66511. shader: string;
  66512. };
  66513. }
  66514. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66515. import { Nullable } from "babylonjs/types";
  66516. import { Camera } from "babylonjs/Cameras/camera";
  66517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66518. import "babylonjs/Shaders/sharpen.fragment";
  66519. import { Engine } from "babylonjs/Engines/engine";
  66520. /**
  66521. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66522. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66523. */
  66524. export class SharpenPostProcess extends PostProcess {
  66525. /**
  66526. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66527. */
  66528. colorAmount: number;
  66529. /**
  66530. * How much sharpness should be applied (default: 0.3)
  66531. */
  66532. edgeAmount: number;
  66533. /**
  66534. * Creates a new instance ConvolutionPostProcess
  66535. * @param name The name of the effect.
  66536. * @param options The required width/height ratio to downsize to before computing the render pass.
  66537. * @param camera The camera to apply the render pass to.
  66538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66539. * @param engine The engine which the post process will be applied. (default: current engine)
  66540. * @param reusable If the post process can be reused on the same frame. (default: false)
  66541. * @param textureType Type of textures used when performing the post process. (default: 0)
  66542. * @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)
  66543. */
  66544. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66545. }
  66546. }
  66547. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66548. import { Nullable } from "babylonjs/types";
  66549. import { Camera } from "babylonjs/Cameras/camera";
  66550. import { Engine } from "babylonjs/Engines/engine";
  66551. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66552. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66553. /**
  66554. * PostProcessRenderPipeline
  66555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66556. */
  66557. export class PostProcessRenderPipeline {
  66558. private engine;
  66559. private _renderEffects;
  66560. private _renderEffectsForIsolatedPass;
  66561. /**
  66562. * List of inspectable custom properties (used by the Inspector)
  66563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66564. */
  66565. inspectableCustomProperties: IInspectable[];
  66566. /**
  66567. * @hidden
  66568. */
  66569. protected _cameras: Camera[];
  66570. /** @hidden */
  66571. _name: string;
  66572. /**
  66573. * Gets pipeline name
  66574. */
  66575. get name(): string;
  66576. /** Gets the list of attached cameras */
  66577. get cameras(): Camera[];
  66578. /**
  66579. * Initializes a PostProcessRenderPipeline
  66580. * @param engine engine to add the pipeline to
  66581. * @param name name of the pipeline
  66582. */
  66583. constructor(engine: Engine, name: string);
  66584. /**
  66585. * Gets the class name
  66586. * @returns "PostProcessRenderPipeline"
  66587. */
  66588. getClassName(): string;
  66589. /**
  66590. * If all the render effects in the pipeline are supported
  66591. */
  66592. get isSupported(): boolean;
  66593. /**
  66594. * Adds an effect to the pipeline
  66595. * @param renderEffect the effect to add
  66596. */
  66597. addEffect(renderEffect: PostProcessRenderEffect): void;
  66598. /** @hidden */
  66599. _rebuild(): void;
  66600. /** @hidden */
  66601. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66602. /** @hidden */
  66603. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66604. /** @hidden */
  66605. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66606. /** @hidden */
  66607. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66608. /** @hidden */
  66609. _attachCameras(cameras: Camera, unique: boolean): void;
  66610. /** @hidden */
  66611. _attachCameras(cameras: Camera[], unique: boolean): void;
  66612. /** @hidden */
  66613. _detachCameras(cameras: Camera): void;
  66614. /** @hidden */
  66615. _detachCameras(cameras: Nullable<Camera[]>): void;
  66616. /** @hidden */
  66617. _update(): void;
  66618. /** @hidden */
  66619. _reset(): void;
  66620. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66621. /**
  66622. * Disposes of the pipeline
  66623. */
  66624. dispose(): void;
  66625. }
  66626. }
  66627. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66628. import { Camera } from "babylonjs/Cameras/camera";
  66629. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66630. /**
  66631. * PostProcessRenderPipelineManager class
  66632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66633. */
  66634. export class PostProcessRenderPipelineManager {
  66635. private _renderPipelines;
  66636. /**
  66637. * Initializes a PostProcessRenderPipelineManager
  66638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66639. */
  66640. constructor();
  66641. /**
  66642. * Gets the list of supported render pipelines
  66643. */
  66644. get supportedPipelines(): PostProcessRenderPipeline[];
  66645. /**
  66646. * Adds a pipeline to the manager
  66647. * @param renderPipeline The pipeline to add
  66648. */
  66649. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66650. /**
  66651. * Attaches a camera to the pipeline
  66652. * @param renderPipelineName The name of the pipeline to attach to
  66653. * @param cameras the camera to attach
  66654. * @param unique if the camera can be attached multiple times to the pipeline
  66655. */
  66656. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66657. /**
  66658. * Detaches a camera from the pipeline
  66659. * @param renderPipelineName The name of the pipeline to detach from
  66660. * @param cameras the camera to detach
  66661. */
  66662. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66663. /**
  66664. * Enables an effect by name on a pipeline
  66665. * @param renderPipelineName the name of the pipeline to enable the effect in
  66666. * @param renderEffectName the name of the effect to enable
  66667. * @param cameras the cameras that the effect should be enabled on
  66668. */
  66669. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66670. /**
  66671. * Disables an effect by name on a pipeline
  66672. * @param renderPipelineName the name of the pipeline to disable the effect in
  66673. * @param renderEffectName the name of the effect to disable
  66674. * @param cameras the cameras that the effect should be disabled on
  66675. */
  66676. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66677. /**
  66678. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66679. */
  66680. update(): void;
  66681. /** @hidden */
  66682. _rebuild(): void;
  66683. /**
  66684. * Disposes of the manager and pipelines
  66685. */
  66686. dispose(): void;
  66687. }
  66688. }
  66689. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66690. import { ISceneComponent } from "babylonjs/sceneComponent";
  66691. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66692. import { Scene } from "babylonjs/scene";
  66693. module "babylonjs/scene" {
  66694. interface Scene {
  66695. /** @hidden (Backing field) */
  66696. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66697. /**
  66698. * Gets the postprocess render pipeline manager
  66699. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66700. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66701. */
  66702. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66703. }
  66704. }
  66705. /**
  66706. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66707. */
  66708. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66709. /**
  66710. * The component name helpfull to identify the component in the list of scene components.
  66711. */
  66712. readonly name: string;
  66713. /**
  66714. * The scene the component belongs to.
  66715. */
  66716. scene: Scene;
  66717. /**
  66718. * Creates a new instance of the component for the given scene
  66719. * @param scene Defines the scene to register the component in
  66720. */
  66721. constructor(scene: Scene);
  66722. /**
  66723. * Registers the component in a given scene
  66724. */
  66725. register(): void;
  66726. /**
  66727. * Rebuilds the elements related to this component in case of
  66728. * context lost for instance.
  66729. */
  66730. rebuild(): void;
  66731. /**
  66732. * Disposes the component and the associated ressources
  66733. */
  66734. dispose(): void;
  66735. private _gatherRenderTargets;
  66736. }
  66737. }
  66738. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66739. import { Nullable } from "babylonjs/types";
  66740. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66741. import { Camera } from "babylonjs/Cameras/camera";
  66742. import { IDisposable } from "babylonjs/scene";
  66743. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66744. import { Scene } from "babylonjs/scene";
  66745. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66746. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66747. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66748. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66749. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66750. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66751. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66752. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66753. import { Animation } from "babylonjs/Animations/animation";
  66754. /**
  66755. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66756. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66757. */
  66758. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66759. private _scene;
  66760. private _camerasToBeAttached;
  66761. /**
  66762. * ID of the sharpen post process,
  66763. */
  66764. private readonly SharpenPostProcessId;
  66765. /**
  66766. * @ignore
  66767. * ID of the image processing post process;
  66768. */
  66769. readonly ImageProcessingPostProcessId: string;
  66770. /**
  66771. * @ignore
  66772. * ID of the Fast Approximate Anti-Aliasing post process;
  66773. */
  66774. readonly FxaaPostProcessId: string;
  66775. /**
  66776. * ID of the chromatic aberration post process,
  66777. */
  66778. private readonly ChromaticAberrationPostProcessId;
  66779. /**
  66780. * ID of the grain post process
  66781. */
  66782. private readonly GrainPostProcessId;
  66783. /**
  66784. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66785. */
  66786. sharpen: SharpenPostProcess;
  66787. private _sharpenEffect;
  66788. private bloom;
  66789. /**
  66790. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66791. */
  66792. depthOfField: DepthOfFieldEffect;
  66793. /**
  66794. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66795. */
  66796. fxaa: FxaaPostProcess;
  66797. /**
  66798. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66799. */
  66800. imageProcessing: ImageProcessingPostProcess;
  66801. /**
  66802. * Chromatic aberration post process which will shift rgb colors in the image
  66803. */
  66804. chromaticAberration: ChromaticAberrationPostProcess;
  66805. private _chromaticAberrationEffect;
  66806. /**
  66807. * Grain post process which add noise to the image
  66808. */
  66809. grain: GrainPostProcess;
  66810. private _grainEffect;
  66811. /**
  66812. * Glow post process which adds a glow to emissive areas of the image
  66813. */
  66814. private _glowLayer;
  66815. /**
  66816. * Animations which can be used to tweak settings over a period of time
  66817. */
  66818. animations: Animation[];
  66819. private _imageProcessingConfigurationObserver;
  66820. private _sharpenEnabled;
  66821. private _bloomEnabled;
  66822. private _depthOfFieldEnabled;
  66823. private _depthOfFieldBlurLevel;
  66824. private _fxaaEnabled;
  66825. private _imageProcessingEnabled;
  66826. private _defaultPipelineTextureType;
  66827. private _bloomScale;
  66828. private _chromaticAberrationEnabled;
  66829. private _grainEnabled;
  66830. private _buildAllowed;
  66831. /**
  66832. * Gets active scene
  66833. */
  66834. get scene(): Scene;
  66835. /**
  66836. * Enable or disable the sharpen process from the pipeline
  66837. */
  66838. set sharpenEnabled(enabled: boolean);
  66839. get sharpenEnabled(): boolean;
  66840. private _resizeObserver;
  66841. private _hardwareScaleLevel;
  66842. private _bloomKernel;
  66843. /**
  66844. * Specifies the size of the bloom blur kernel, relative to the final output size
  66845. */
  66846. get bloomKernel(): number;
  66847. set bloomKernel(value: number);
  66848. /**
  66849. * Specifies the weight of the bloom in the final rendering
  66850. */
  66851. private _bloomWeight;
  66852. /**
  66853. * Specifies the luma threshold for the area that will be blurred by the bloom
  66854. */
  66855. private _bloomThreshold;
  66856. private _hdr;
  66857. /**
  66858. * The strength of the bloom.
  66859. */
  66860. set bloomWeight(value: number);
  66861. get bloomWeight(): number;
  66862. /**
  66863. * The strength of the bloom.
  66864. */
  66865. set bloomThreshold(value: number);
  66866. get bloomThreshold(): number;
  66867. /**
  66868. * The scale of the bloom, lower value will provide better performance.
  66869. */
  66870. set bloomScale(value: number);
  66871. get bloomScale(): number;
  66872. /**
  66873. * Enable or disable the bloom from the pipeline
  66874. */
  66875. set bloomEnabled(enabled: boolean);
  66876. get bloomEnabled(): boolean;
  66877. private _rebuildBloom;
  66878. /**
  66879. * If the depth of field is enabled.
  66880. */
  66881. get depthOfFieldEnabled(): boolean;
  66882. set depthOfFieldEnabled(enabled: boolean);
  66883. /**
  66884. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66885. */
  66886. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66887. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66888. /**
  66889. * If the anti aliasing is enabled.
  66890. */
  66891. set fxaaEnabled(enabled: boolean);
  66892. get fxaaEnabled(): boolean;
  66893. private _samples;
  66894. /**
  66895. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66896. */
  66897. set samples(sampleCount: number);
  66898. get samples(): number;
  66899. /**
  66900. * If image processing is enabled.
  66901. */
  66902. set imageProcessingEnabled(enabled: boolean);
  66903. get imageProcessingEnabled(): boolean;
  66904. /**
  66905. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66906. */
  66907. set glowLayerEnabled(enabled: boolean);
  66908. get glowLayerEnabled(): boolean;
  66909. /**
  66910. * Gets the glow layer (or null if not defined)
  66911. */
  66912. get glowLayer(): Nullable<GlowLayer>;
  66913. /**
  66914. * Enable or disable the chromaticAberration process from the pipeline
  66915. */
  66916. set chromaticAberrationEnabled(enabled: boolean);
  66917. get chromaticAberrationEnabled(): boolean;
  66918. /**
  66919. * Enable or disable the grain process from the pipeline
  66920. */
  66921. set grainEnabled(enabled: boolean);
  66922. get grainEnabled(): boolean;
  66923. /**
  66924. * @constructor
  66925. * @param name - The rendering pipeline name (default: "")
  66926. * @param hdr - If high dynamic range textures should be used (default: true)
  66927. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66928. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66929. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66930. */
  66931. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66932. /**
  66933. * Get the class name
  66934. * @returns "DefaultRenderingPipeline"
  66935. */
  66936. getClassName(): string;
  66937. /**
  66938. * Force the compilation of the entire pipeline.
  66939. */
  66940. prepare(): void;
  66941. private _hasCleared;
  66942. private _prevPostProcess;
  66943. private _prevPrevPostProcess;
  66944. private _setAutoClearAndTextureSharing;
  66945. private _depthOfFieldSceneObserver;
  66946. private _buildPipeline;
  66947. private _disposePostProcesses;
  66948. /**
  66949. * Adds a camera to the pipeline
  66950. * @param camera the camera to be added
  66951. */
  66952. addCamera(camera: Camera): void;
  66953. /**
  66954. * Removes a camera from the pipeline
  66955. * @param camera the camera to remove
  66956. */
  66957. removeCamera(camera: Camera): void;
  66958. /**
  66959. * Dispose of the pipeline and stop all post processes
  66960. */
  66961. dispose(): void;
  66962. /**
  66963. * Serialize the rendering pipeline (Used when exporting)
  66964. * @returns the serialized object
  66965. */
  66966. serialize(): any;
  66967. /**
  66968. * Parse the serialized pipeline
  66969. * @param source Source pipeline.
  66970. * @param scene The scene to load the pipeline to.
  66971. * @param rootUrl The URL of the serialized pipeline.
  66972. * @returns An instantiated pipeline from the serialized object.
  66973. */
  66974. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66975. }
  66976. }
  66977. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66978. /** @hidden */
  66979. export var lensHighlightsPixelShader: {
  66980. name: string;
  66981. shader: string;
  66982. };
  66983. }
  66984. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66985. /** @hidden */
  66986. export var depthOfFieldPixelShader: {
  66987. name: string;
  66988. shader: string;
  66989. };
  66990. }
  66991. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66992. import { Camera } from "babylonjs/Cameras/camera";
  66993. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66994. import { Scene } from "babylonjs/scene";
  66995. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66996. import "babylonjs/Shaders/chromaticAberration.fragment";
  66997. import "babylonjs/Shaders/lensHighlights.fragment";
  66998. import "babylonjs/Shaders/depthOfField.fragment";
  66999. /**
  67000. * BABYLON.JS Chromatic Aberration GLSL Shader
  67001. * Author: Olivier Guyot
  67002. * Separates very slightly R, G and B colors on the edges of the screen
  67003. * Inspired by Francois Tarlier & Martins Upitis
  67004. */
  67005. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67006. /**
  67007. * @ignore
  67008. * The chromatic aberration PostProcess id in the pipeline
  67009. */
  67010. LensChromaticAberrationEffect: string;
  67011. /**
  67012. * @ignore
  67013. * The highlights enhancing PostProcess id in the pipeline
  67014. */
  67015. HighlightsEnhancingEffect: string;
  67016. /**
  67017. * @ignore
  67018. * The depth-of-field PostProcess id in the pipeline
  67019. */
  67020. LensDepthOfFieldEffect: string;
  67021. private _scene;
  67022. private _depthTexture;
  67023. private _grainTexture;
  67024. private _chromaticAberrationPostProcess;
  67025. private _highlightsPostProcess;
  67026. private _depthOfFieldPostProcess;
  67027. private _edgeBlur;
  67028. private _grainAmount;
  67029. private _chromaticAberration;
  67030. private _distortion;
  67031. private _highlightsGain;
  67032. private _highlightsThreshold;
  67033. private _dofDistance;
  67034. private _dofAperture;
  67035. private _dofDarken;
  67036. private _dofPentagon;
  67037. private _blurNoise;
  67038. /**
  67039. * @constructor
  67040. *
  67041. * Effect parameters are as follow:
  67042. * {
  67043. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67044. * edge_blur: number; // from 0 to x (1 for realism)
  67045. * distortion: number; // from 0 to x (1 for realism)
  67046. * grain_amount: number; // from 0 to 1
  67047. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67048. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67049. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67050. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67051. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67052. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67053. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67054. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67055. * }
  67056. * Note: if an effect parameter is unset, effect is disabled
  67057. *
  67058. * @param name The rendering pipeline name
  67059. * @param parameters - An object containing all parameters (see above)
  67060. * @param scene The scene linked to this pipeline
  67061. * @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)
  67062. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67063. */
  67064. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67065. /**
  67066. * Get the class name
  67067. * @returns "LensRenderingPipeline"
  67068. */
  67069. getClassName(): string;
  67070. /**
  67071. * Gets associated scene
  67072. */
  67073. get scene(): Scene;
  67074. /**
  67075. * Gets or sets the edge blur
  67076. */
  67077. get edgeBlur(): number;
  67078. set edgeBlur(value: number);
  67079. /**
  67080. * Gets or sets the grain amount
  67081. */
  67082. get grainAmount(): number;
  67083. set grainAmount(value: number);
  67084. /**
  67085. * Gets or sets the chromatic aberration amount
  67086. */
  67087. get chromaticAberration(): number;
  67088. set chromaticAberration(value: number);
  67089. /**
  67090. * Gets or sets the depth of field aperture
  67091. */
  67092. get dofAperture(): number;
  67093. set dofAperture(value: number);
  67094. /**
  67095. * Gets or sets the edge distortion
  67096. */
  67097. get edgeDistortion(): number;
  67098. set edgeDistortion(value: number);
  67099. /**
  67100. * Gets or sets the depth of field distortion
  67101. */
  67102. get dofDistortion(): number;
  67103. set dofDistortion(value: number);
  67104. /**
  67105. * Gets or sets the darken out of focus amount
  67106. */
  67107. get darkenOutOfFocus(): number;
  67108. set darkenOutOfFocus(value: number);
  67109. /**
  67110. * Gets or sets a boolean indicating if blur noise is enabled
  67111. */
  67112. get blurNoise(): boolean;
  67113. set blurNoise(value: boolean);
  67114. /**
  67115. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67116. */
  67117. get pentagonBokeh(): boolean;
  67118. set pentagonBokeh(value: boolean);
  67119. /**
  67120. * Gets or sets the highlight grain amount
  67121. */
  67122. get highlightsGain(): number;
  67123. set highlightsGain(value: number);
  67124. /**
  67125. * Gets or sets the highlight threshold
  67126. */
  67127. get highlightsThreshold(): number;
  67128. set highlightsThreshold(value: number);
  67129. /**
  67130. * Sets the amount of blur at the edges
  67131. * @param amount blur amount
  67132. */
  67133. setEdgeBlur(amount: number): void;
  67134. /**
  67135. * Sets edge blur to 0
  67136. */
  67137. disableEdgeBlur(): void;
  67138. /**
  67139. * Sets the amout of grain
  67140. * @param amount Amount of grain
  67141. */
  67142. setGrainAmount(amount: number): void;
  67143. /**
  67144. * Set grain amount to 0
  67145. */
  67146. disableGrain(): void;
  67147. /**
  67148. * Sets the chromatic aberration amount
  67149. * @param amount amount of chromatic aberration
  67150. */
  67151. setChromaticAberration(amount: number): void;
  67152. /**
  67153. * Sets chromatic aberration amount to 0
  67154. */
  67155. disableChromaticAberration(): void;
  67156. /**
  67157. * Sets the EdgeDistortion amount
  67158. * @param amount amount of EdgeDistortion
  67159. */
  67160. setEdgeDistortion(amount: number): void;
  67161. /**
  67162. * Sets edge distortion to 0
  67163. */
  67164. disableEdgeDistortion(): void;
  67165. /**
  67166. * Sets the FocusDistance amount
  67167. * @param amount amount of FocusDistance
  67168. */
  67169. setFocusDistance(amount: number): void;
  67170. /**
  67171. * Disables depth of field
  67172. */
  67173. disableDepthOfField(): void;
  67174. /**
  67175. * Sets the Aperture amount
  67176. * @param amount amount of Aperture
  67177. */
  67178. setAperture(amount: number): void;
  67179. /**
  67180. * Sets the DarkenOutOfFocus amount
  67181. * @param amount amount of DarkenOutOfFocus
  67182. */
  67183. setDarkenOutOfFocus(amount: number): void;
  67184. private _pentagonBokehIsEnabled;
  67185. /**
  67186. * Creates a pentagon bokeh effect
  67187. */
  67188. enablePentagonBokeh(): void;
  67189. /**
  67190. * Disables the pentagon bokeh effect
  67191. */
  67192. disablePentagonBokeh(): void;
  67193. /**
  67194. * Enables noise blur
  67195. */
  67196. enableNoiseBlur(): void;
  67197. /**
  67198. * Disables noise blur
  67199. */
  67200. disableNoiseBlur(): void;
  67201. /**
  67202. * Sets the HighlightsGain amount
  67203. * @param amount amount of HighlightsGain
  67204. */
  67205. setHighlightsGain(amount: number): void;
  67206. /**
  67207. * Sets the HighlightsThreshold amount
  67208. * @param amount amount of HighlightsThreshold
  67209. */
  67210. setHighlightsThreshold(amount: number): void;
  67211. /**
  67212. * Disables highlights
  67213. */
  67214. disableHighlights(): void;
  67215. /**
  67216. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67217. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67218. */
  67219. dispose(disableDepthRender?: boolean): void;
  67220. private _createChromaticAberrationPostProcess;
  67221. private _createHighlightsPostProcess;
  67222. private _createDepthOfFieldPostProcess;
  67223. private _createGrainTexture;
  67224. }
  67225. }
  67226. declare module "babylonjs/Shaders/ssao2.fragment" {
  67227. /** @hidden */
  67228. export var ssao2PixelShader: {
  67229. name: string;
  67230. shader: string;
  67231. };
  67232. }
  67233. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67234. /** @hidden */
  67235. export var ssaoCombinePixelShader: {
  67236. name: string;
  67237. shader: string;
  67238. };
  67239. }
  67240. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67241. import { Camera } from "babylonjs/Cameras/camera";
  67242. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67243. import { Scene } from "babylonjs/scene";
  67244. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67245. import "babylonjs/Shaders/ssao2.fragment";
  67246. import "babylonjs/Shaders/ssaoCombine.fragment";
  67247. /**
  67248. * Render pipeline to produce ssao effect
  67249. */
  67250. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67251. /**
  67252. * @ignore
  67253. * The PassPostProcess id in the pipeline that contains the original scene color
  67254. */
  67255. SSAOOriginalSceneColorEffect: string;
  67256. /**
  67257. * @ignore
  67258. * The SSAO PostProcess id in the pipeline
  67259. */
  67260. SSAORenderEffect: string;
  67261. /**
  67262. * @ignore
  67263. * The horizontal blur PostProcess id in the pipeline
  67264. */
  67265. SSAOBlurHRenderEffect: string;
  67266. /**
  67267. * @ignore
  67268. * The vertical blur PostProcess id in the pipeline
  67269. */
  67270. SSAOBlurVRenderEffect: string;
  67271. /**
  67272. * @ignore
  67273. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67274. */
  67275. SSAOCombineRenderEffect: string;
  67276. /**
  67277. * The output strength of the SSAO post-process. Default value is 1.0.
  67278. */
  67279. totalStrength: number;
  67280. /**
  67281. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67282. */
  67283. maxZ: number;
  67284. /**
  67285. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67286. */
  67287. minZAspect: number;
  67288. private _samples;
  67289. /**
  67290. * Number of samples used for the SSAO calculations. Default value is 8
  67291. */
  67292. set samples(n: number);
  67293. get samples(): number;
  67294. private _textureSamples;
  67295. /**
  67296. * Number of samples to use for antialiasing
  67297. */
  67298. set textureSamples(n: number);
  67299. get textureSamples(): number;
  67300. /**
  67301. * Ratio object used for SSAO ratio and blur ratio
  67302. */
  67303. private _ratio;
  67304. /**
  67305. * Dynamically generated sphere sampler.
  67306. */
  67307. private _sampleSphere;
  67308. /**
  67309. * Blur filter offsets
  67310. */
  67311. private _samplerOffsets;
  67312. private _expensiveBlur;
  67313. /**
  67314. * If bilateral blur should be used
  67315. */
  67316. set expensiveBlur(b: boolean);
  67317. get expensiveBlur(): boolean;
  67318. /**
  67319. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67320. */
  67321. radius: number;
  67322. /**
  67323. * The base color of the SSAO post-process
  67324. * The final result is "base + ssao" between [0, 1]
  67325. */
  67326. base: number;
  67327. /**
  67328. * Support test.
  67329. */
  67330. static get IsSupported(): boolean;
  67331. private _scene;
  67332. private _depthTexture;
  67333. private _normalTexture;
  67334. private _randomTexture;
  67335. private _originalColorPostProcess;
  67336. private _ssaoPostProcess;
  67337. private _blurHPostProcess;
  67338. private _blurVPostProcess;
  67339. private _ssaoCombinePostProcess;
  67340. /**
  67341. * Gets active scene
  67342. */
  67343. get scene(): Scene;
  67344. /**
  67345. * @constructor
  67346. * @param name The rendering pipeline name
  67347. * @param scene The scene linked to this pipeline
  67348. * @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 }
  67349. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67350. */
  67351. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67352. /**
  67353. * Get the class name
  67354. * @returns "SSAO2RenderingPipeline"
  67355. */
  67356. getClassName(): string;
  67357. /**
  67358. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67359. */
  67360. dispose(disableGeometryBufferRenderer?: boolean): void;
  67361. private _createBlurPostProcess;
  67362. /** @hidden */
  67363. _rebuild(): void;
  67364. private _bits;
  67365. private _radicalInverse_VdC;
  67366. private _hammersley;
  67367. private _hemisphereSample_uniform;
  67368. private _generateHemisphere;
  67369. private _createSSAOPostProcess;
  67370. private _createSSAOCombinePostProcess;
  67371. private _createRandomTexture;
  67372. /**
  67373. * Serialize the rendering pipeline (Used when exporting)
  67374. * @returns the serialized object
  67375. */
  67376. serialize(): any;
  67377. /**
  67378. * Parse the serialized pipeline
  67379. * @param source Source pipeline.
  67380. * @param scene The scene to load the pipeline to.
  67381. * @param rootUrl The URL of the serialized pipeline.
  67382. * @returns An instantiated pipeline from the serialized object.
  67383. */
  67384. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67385. }
  67386. }
  67387. declare module "babylonjs/Shaders/ssao.fragment" {
  67388. /** @hidden */
  67389. export var ssaoPixelShader: {
  67390. name: string;
  67391. shader: string;
  67392. };
  67393. }
  67394. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67395. import { Camera } from "babylonjs/Cameras/camera";
  67396. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67397. import { Scene } from "babylonjs/scene";
  67398. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67399. import "babylonjs/Shaders/ssao.fragment";
  67400. import "babylonjs/Shaders/ssaoCombine.fragment";
  67401. /**
  67402. * Render pipeline to produce ssao effect
  67403. */
  67404. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67405. /**
  67406. * @ignore
  67407. * The PassPostProcess id in the pipeline that contains the original scene color
  67408. */
  67409. SSAOOriginalSceneColorEffect: string;
  67410. /**
  67411. * @ignore
  67412. * The SSAO PostProcess id in the pipeline
  67413. */
  67414. SSAORenderEffect: string;
  67415. /**
  67416. * @ignore
  67417. * The horizontal blur PostProcess id in the pipeline
  67418. */
  67419. SSAOBlurHRenderEffect: string;
  67420. /**
  67421. * @ignore
  67422. * The vertical blur PostProcess id in the pipeline
  67423. */
  67424. SSAOBlurVRenderEffect: string;
  67425. /**
  67426. * @ignore
  67427. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67428. */
  67429. SSAOCombineRenderEffect: string;
  67430. /**
  67431. * The output strength of the SSAO post-process. Default value is 1.0.
  67432. */
  67433. totalStrength: number;
  67434. /**
  67435. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67436. */
  67437. radius: number;
  67438. /**
  67439. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67440. * Must not be equal to fallOff and superior to fallOff.
  67441. * Default value is 0.0075
  67442. */
  67443. area: number;
  67444. /**
  67445. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67446. * Must not be equal to area and inferior to area.
  67447. * Default value is 0.000001
  67448. */
  67449. fallOff: number;
  67450. /**
  67451. * The base color of the SSAO post-process
  67452. * The final result is "base + ssao" between [0, 1]
  67453. */
  67454. base: number;
  67455. private _scene;
  67456. private _depthTexture;
  67457. private _randomTexture;
  67458. private _originalColorPostProcess;
  67459. private _ssaoPostProcess;
  67460. private _blurHPostProcess;
  67461. private _blurVPostProcess;
  67462. private _ssaoCombinePostProcess;
  67463. private _firstUpdate;
  67464. /**
  67465. * Gets active scene
  67466. */
  67467. get scene(): Scene;
  67468. /**
  67469. * @constructor
  67470. * @param name - The rendering pipeline name
  67471. * @param scene - The scene linked to this pipeline
  67472. * @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 }
  67473. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67474. */
  67475. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67476. /**
  67477. * Get the class name
  67478. * @returns "SSAORenderingPipeline"
  67479. */
  67480. getClassName(): string;
  67481. /**
  67482. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67483. */
  67484. dispose(disableDepthRender?: boolean): void;
  67485. private _createBlurPostProcess;
  67486. /** @hidden */
  67487. _rebuild(): void;
  67488. private _createSSAOPostProcess;
  67489. private _createSSAOCombinePostProcess;
  67490. private _createRandomTexture;
  67491. }
  67492. }
  67493. declare module "babylonjs/Shaders/standard.fragment" {
  67494. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67495. /** @hidden */
  67496. export var standardPixelShader: {
  67497. name: string;
  67498. shader: string;
  67499. };
  67500. }
  67501. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67502. import { Nullable } from "babylonjs/types";
  67503. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67504. import { Camera } from "babylonjs/Cameras/camera";
  67505. import { Texture } from "babylonjs/Materials/Textures/texture";
  67506. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67508. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67509. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67510. import { IDisposable } from "babylonjs/scene";
  67511. import { SpotLight } from "babylonjs/Lights/spotLight";
  67512. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67513. import { Scene } from "babylonjs/scene";
  67514. import { Animation } from "babylonjs/Animations/animation";
  67515. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67516. import "babylonjs/Shaders/standard.fragment";
  67517. /**
  67518. * Standard rendering pipeline
  67519. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67520. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67521. */
  67522. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67523. /**
  67524. * Public members
  67525. */
  67526. /**
  67527. * Post-process which contains the original scene color before the pipeline applies all the effects
  67528. */
  67529. originalPostProcess: Nullable<PostProcess>;
  67530. /**
  67531. * Post-process used to down scale an image x4
  67532. */
  67533. downSampleX4PostProcess: Nullable<PostProcess>;
  67534. /**
  67535. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67536. */
  67537. brightPassPostProcess: Nullable<PostProcess>;
  67538. /**
  67539. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67540. */
  67541. blurHPostProcesses: PostProcess[];
  67542. /**
  67543. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67544. */
  67545. blurVPostProcesses: PostProcess[];
  67546. /**
  67547. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67548. */
  67549. textureAdderPostProcess: Nullable<PostProcess>;
  67550. /**
  67551. * Post-process used to create volumetric lighting effect
  67552. */
  67553. volumetricLightPostProcess: Nullable<PostProcess>;
  67554. /**
  67555. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67556. */
  67557. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67558. /**
  67559. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67560. */
  67561. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67562. /**
  67563. * Post-process used to merge the volumetric light effect and the real scene color
  67564. */
  67565. volumetricLightMergePostProces: Nullable<PostProcess>;
  67566. /**
  67567. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67568. */
  67569. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67570. /**
  67571. * Base post-process used to calculate the average luminance of the final image for HDR
  67572. */
  67573. luminancePostProcess: Nullable<PostProcess>;
  67574. /**
  67575. * Post-processes used to create down sample post-processes in order to get
  67576. * the average luminance of the final image for HDR
  67577. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67578. */
  67579. luminanceDownSamplePostProcesses: PostProcess[];
  67580. /**
  67581. * Post-process used to create a HDR effect (light adaptation)
  67582. */
  67583. hdrPostProcess: Nullable<PostProcess>;
  67584. /**
  67585. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67586. */
  67587. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67588. /**
  67589. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67590. */
  67591. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67592. /**
  67593. * Post-process used to merge the final HDR post-process and the real scene color
  67594. */
  67595. hdrFinalPostProcess: Nullable<PostProcess>;
  67596. /**
  67597. * Post-process used to create a lens flare effect
  67598. */
  67599. lensFlarePostProcess: Nullable<PostProcess>;
  67600. /**
  67601. * Post-process that merges the result of the lens flare post-process and the real scene color
  67602. */
  67603. lensFlareComposePostProcess: Nullable<PostProcess>;
  67604. /**
  67605. * Post-process used to create a motion blur effect
  67606. */
  67607. motionBlurPostProcess: Nullable<PostProcess>;
  67608. /**
  67609. * Post-process used to create a depth of field effect
  67610. */
  67611. depthOfFieldPostProcess: Nullable<PostProcess>;
  67612. /**
  67613. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67614. */
  67615. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67616. /**
  67617. * Represents the brightness threshold in order to configure the illuminated surfaces
  67618. */
  67619. brightThreshold: number;
  67620. /**
  67621. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67622. */
  67623. blurWidth: number;
  67624. /**
  67625. * Sets if the blur for highlighted surfaces must be only horizontal
  67626. */
  67627. horizontalBlur: boolean;
  67628. /**
  67629. * Gets the overall exposure used by the pipeline
  67630. */
  67631. get exposure(): number;
  67632. /**
  67633. * Sets the overall exposure used by the pipeline
  67634. */
  67635. set exposure(value: number);
  67636. /**
  67637. * Texture used typically to simulate "dirty" on camera lens
  67638. */
  67639. lensTexture: Nullable<Texture>;
  67640. /**
  67641. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67642. */
  67643. volumetricLightCoefficient: number;
  67644. /**
  67645. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67646. */
  67647. volumetricLightPower: number;
  67648. /**
  67649. * Used the set the blur intensity to smooth the volumetric lights
  67650. */
  67651. volumetricLightBlurScale: number;
  67652. /**
  67653. * Light (spot or directional) used to generate the volumetric lights rays
  67654. * The source light must have a shadow generate so the pipeline can get its
  67655. * depth map
  67656. */
  67657. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67658. /**
  67659. * For eye adaptation, represents the minimum luminance the eye can see
  67660. */
  67661. hdrMinimumLuminance: number;
  67662. /**
  67663. * For eye adaptation, represents the decrease luminance speed
  67664. */
  67665. hdrDecreaseRate: number;
  67666. /**
  67667. * For eye adaptation, represents the increase luminance speed
  67668. */
  67669. hdrIncreaseRate: number;
  67670. /**
  67671. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67672. */
  67673. get hdrAutoExposure(): boolean;
  67674. /**
  67675. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67676. */
  67677. set hdrAutoExposure(value: boolean);
  67678. /**
  67679. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67680. */
  67681. lensColorTexture: Nullable<Texture>;
  67682. /**
  67683. * The overall strengh for the lens flare effect
  67684. */
  67685. lensFlareStrength: number;
  67686. /**
  67687. * Dispersion coefficient for lens flare ghosts
  67688. */
  67689. lensFlareGhostDispersal: number;
  67690. /**
  67691. * Main lens flare halo width
  67692. */
  67693. lensFlareHaloWidth: number;
  67694. /**
  67695. * Based on the lens distortion effect, defines how much the lens flare result
  67696. * is distorted
  67697. */
  67698. lensFlareDistortionStrength: number;
  67699. /**
  67700. * Configures the blur intensity used for for lens flare (halo)
  67701. */
  67702. lensFlareBlurWidth: number;
  67703. /**
  67704. * Lens star texture must be used to simulate rays on the flares and is available
  67705. * in the documentation
  67706. */
  67707. lensStarTexture: Nullable<Texture>;
  67708. /**
  67709. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67710. * flare effect by taking account of the dirt texture
  67711. */
  67712. lensFlareDirtTexture: Nullable<Texture>;
  67713. /**
  67714. * Represents the focal length for the depth of field effect
  67715. */
  67716. depthOfFieldDistance: number;
  67717. /**
  67718. * Represents the blur intensity for the blurred part of the depth of field effect
  67719. */
  67720. depthOfFieldBlurWidth: number;
  67721. /**
  67722. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67723. */
  67724. get motionStrength(): number;
  67725. /**
  67726. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67727. */
  67728. set motionStrength(strength: number);
  67729. /**
  67730. * Gets wether or not the motion blur post-process is object based or screen based.
  67731. */
  67732. get objectBasedMotionBlur(): boolean;
  67733. /**
  67734. * Sets wether or not the motion blur post-process should be object based or screen based
  67735. */
  67736. set objectBasedMotionBlur(value: boolean);
  67737. /**
  67738. * List of animations for the pipeline (IAnimatable implementation)
  67739. */
  67740. animations: Animation[];
  67741. /**
  67742. * Private members
  67743. */
  67744. private _scene;
  67745. private _currentDepthOfFieldSource;
  67746. private _basePostProcess;
  67747. private _fixedExposure;
  67748. private _currentExposure;
  67749. private _hdrAutoExposure;
  67750. private _hdrCurrentLuminance;
  67751. private _motionStrength;
  67752. private _isObjectBasedMotionBlur;
  67753. private _floatTextureType;
  67754. private _camerasToBeAttached;
  67755. private _ratio;
  67756. private _bloomEnabled;
  67757. private _depthOfFieldEnabled;
  67758. private _vlsEnabled;
  67759. private _lensFlareEnabled;
  67760. private _hdrEnabled;
  67761. private _motionBlurEnabled;
  67762. private _fxaaEnabled;
  67763. private _motionBlurSamples;
  67764. private _volumetricLightStepsCount;
  67765. private _samples;
  67766. /**
  67767. * @ignore
  67768. * Specifies if the bloom pipeline is enabled
  67769. */
  67770. get BloomEnabled(): boolean;
  67771. set BloomEnabled(enabled: boolean);
  67772. /**
  67773. * @ignore
  67774. * Specifies if the depth of field pipeline is enabed
  67775. */
  67776. get DepthOfFieldEnabled(): boolean;
  67777. set DepthOfFieldEnabled(enabled: boolean);
  67778. /**
  67779. * @ignore
  67780. * Specifies if the lens flare pipeline is enabed
  67781. */
  67782. get LensFlareEnabled(): boolean;
  67783. set LensFlareEnabled(enabled: boolean);
  67784. /**
  67785. * @ignore
  67786. * Specifies if the HDR pipeline is enabled
  67787. */
  67788. get HDREnabled(): boolean;
  67789. set HDREnabled(enabled: boolean);
  67790. /**
  67791. * @ignore
  67792. * Specifies if the volumetric lights scattering effect is enabled
  67793. */
  67794. get VLSEnabled(): boolean;
  67795. set VLSEnabled(enabled: boolean);
  67796. /**
  67797. * @ignore
  67798. * Specifies if the motion blur effect is enabled
  67799. */
  67800. get MotionBlurEnabled(): boolean;
  67801. set MotionBlurEnabled(enabled: boolean);
  67802. /**
  67803. * Specifies if anti-aliasing is enabled
  67804. */
  67805. get fxaaEnabled(): boolean;
  67806. set fxaaEnabled(enabled: boolean);
  67807. /**
  67808. * Specifies the number of steps used to calculate the volumetric lights
  67809. * Typically in interval [50, 200]
  67810. */
  67811. get volumetricLightStepsCount(): number;
  67812. set volumetricLightStepsCount(count: number);
  67813. /**
  67814. * Specifies the number of samples used for the motion blur effect
  67815. * Typically in interval [16, 64]
  67816. */
  67817. get motionBlurSamples(): number;
  67818. set motionBlurSamples(samples: number);
  67819. /**
  67820. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67821. */
  67822. get samples(): number;
  67823. set samples(sampleCount: number);
  67824. /**
  67825. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67826. * @constructor
  67827. * @param name The rendering pipeline name
  67828. * @param scene The scene linked to this pipeline
  67829. * @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)
  67830. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67831. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67832. */
  67833. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67834. private _buildPipeline;
  67835. private _createDownSampleX4PostProcess;
  67836. private _createBrightPassPostProcess;
  67837. private _createBlurPostProcesses;
  67838. private _createTextureAdderPostProcess;
  67839. private _createVolumetricLightPostProcess;
  67840. private _createLuminancePostProcesses;
  67841. private _createHdrPostProcess;
  67842. private _createLensFlarePostProcess;
  67843. private _createDepthOfFieldPostProcess;
  67844. private _createMotionBlurPostProcess;
  67845. private _getDepthTexture;
  67846. private _disposePostProcesses;
  67847. /**
  67848. * Dispose of the pipeline and stop all post processes
  67849. */
  67850. dispose(): void;
  67851. /**
  67852. * Serialize the rendering pipeline (Used when exporting)
  67853. * @returns the serialized object
  67854. */
  67855. serialize(): any;
  67856. /**
  67857. * Parse the serialized pipeline
  67858. * @param source Source pipeline.
  67859. * @param scene The scene to load the pipeline to.
  67860. * @param rootUrl The URL of the serialized pipeline.
  67861. * @returns An instantiated pipeline from the serialized object.
  67862. */
  67863. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67864. /**
  67865. * Luminance steps
  67866. */
  67867. static LuminanceSteps: number;
  67868. }
  67869. }
  67870. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67871. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67872. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67873. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67874. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67875. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67876. }
  67877. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67878. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67879. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67880. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67881. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67882. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67883. }
  67884. declare module "babylonjs/Shaders/tonemap.fragment" {
  67885. /** @hidden */
  67886. export var tonemapPixelShader: {
  67887. name: string;
  67888. shader: string;
  67889. };
  67890. }
  67891. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67892. import { Camera } from "babylonjs/Cameras/camera";
  67893. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67894. import "babylonjs/Shaders/tonemap.fragment";
  67895. import { Engine } from "babylonjs/Engines/engine";
  67896. /** Defines operator used for tonemapping */
  67897. export enum TonemappingOperator {
  67898. /** Hable */
  67899. Hable = 0,
  67900. /** Reinhard */
  67901. Reinhard = 1,
  67902. /** HejiDawson */
  67903. HejiDawson = 2,
  67904. /** Photographic */
  67905. Photographic = 3
  67906. }
  67907. /**
  67908. * Defines a post process to apply tone mapping
  67909. */
  67910. export class TonemapPostProcess extends PostProcess {
  67911. private _operator;
  67912. /** Defines the required exposure adjustement */
  67913. exposureAdjustment: number;
  67914. /**
  67915. * Creates a new TonemapPostProcess
  67916. * @param name defines the name of the postprocess
  67917. * @param _operator defines the operator to use
  67918. * @param exposureAdjustment defines the required exposure adjustement
  67919. * @param camera defines the camera to use (can be null)
  67920. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67921. * @param engine defines the hosting engine (can be ignore if camera is set)
  67922. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67923. */
  67924. constructor(name: string, _operator: TonemappingOperator,
  67925. /** Defines the required exposure adjustement */
  67926. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67927. }
  67928. }
  67929. declare module "babylonjs/Shaders/depth.vertex" {
  67930. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67931. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67932. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67933. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67934. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67935. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67936. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67937. /** @hidden */
  67938. export var depthVertexShader: {
  67939. name: string;
  67940. shader: string;
  67941. };
  67942. }
  67943. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67944. /** @hidden */
  67945. export var volumetricLightScatteringPixelShader: {
  67946. name: string;
  67947. shader: string;
  67948. };
  67949. }
  67950. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67951. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67952. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67953. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67954. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67956. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67957. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67958. /** @hidden */
  67959. export var volumetricLightScatteringPassVertexShader: {
  67960. name: string;
  67961. shader: string;
  67962. };
  67963. }
  67964. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67965. /** @hidden */
  67966. export var volumetricLightScatteringPassPixelShader: {
  67967. name: string;
  67968. shader: string;
  67969. };
  67970. }
  67971. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67972. import { Vector3 } from "babylonjs/Maths/math.vector";
  67973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67974. import { Mesh } from "babylonjs/Meshes/mesh";
  67975. import { Camera } from "babylonjs/Cameras/camera";
  67976. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67977. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67978. import { Scene } from "babylonjs/scene";
  67979. import "babylonjs/Meshes/Builders/planeBuilder";
  67980. import "babylonjs/Shaders/depth.vertex";
  67981. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67982. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67983. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67984. import { Engine } from "babylonjs/Engines/engine";
  67985. /**
  67986. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67987. */
  67988. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67989. private _volumetricLightScatteringPass;
  67990. private _volumetricLightScatteringRTT;
  67991. private _viewPort;
  67992. private _screenCoordinates;
  67993. private _cachedDefines;
  67994. /**
  67995. * If not undefined, the mesh position is computed from the attached node position
  67996. */
  67997. attachedNode: {
  67998. position: Vector3;
  67999. };
  68000. /**
  68001. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68002. */
  68003. customMeshPosition: Vector3;
  68004. /**
  68005. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68006. */
  68007. useCustomMeshPosition: boolean;
  68008. /**
  68009. * If the post-process should inverse the light scattering direction
  68010. */
  68011. invert: boolean;
  68012. /**
  68013. * The internal mesh used by the post-process
  68014. */
  68015. mesh: Mesh;
  68016. /**
  68017. * @hidden
  68018. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68019. */
  68020. get useDiffuseColor(): boolean;
  68021. set useDiffuseColor(useDiffuseColor: boolean);
  68022. /**
  68023. * Array containing the excluded meshes not rendered in the internal pass
  68024. */
  68025. excludedMeshes: AbstractMesh[];
  68026. /**
  68027. * Controls the overall intensity of the post-process
  68028. */
  68029. exposure: number;
  68030. /**
  68031. * Dissipates each sample's contribution in range [0, 1]
  68032. */
  68033. decay: number;
  68034. /**
  68035. * Controls the overall intensity of each sample
  68036. */
  68037. weight: number;
  68038. /**
  68039. * Controls the density of each sample
  68040. */
  68041. density: number;
  68042. /**
  68043. * @constructor
  68044. * @param name The post-process name
  68045. * @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)
  68046. * @param camera The camera that the post-process will be attached to
  68047. * @param mesh The mesh used to create the light scattering
  68048. * @param samples The post-process quality, default 100
  68049. * @param samplingModeThe post-process filtering mode
  68050. * @param engine The babylon engine
  68051. * @param reusable If the post-process is reusable
  68052. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68053. */
  68054. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68055. /**
  68056. * Returns the string "VolumetricLightScatteringPostProcess"
  68057. * @returns "VolumetricLightScatteringPostProcess"
  68058. */
  68059. getClassName(): string;
  68060. private _isReady;
  68061. /**
  68062. * Sets the new light position for light scattering effect
  68063. * @param position The new custom light position
  68064. */
  68065. setCustomMeshPosition(position: Vector3): void;
  68066. /**
  68067. * Returns the light position for light scattering effect
  68068. * @return Vector3 The custom light position
  68069. */
  68070. getCustomMeshPosition(): Vector3;
  68071. /**
  68072. * Disposes the internal assets and detaches the post-process from the camera
  68073. */
  68074. dispose(camera: Camera): void;
  68075. /**
  68076. * Returns the render target texture used by the post-process
  68077. * @return the render target texture used by the post-process
  68078. */
  68079. getPass(): RenderTargetTexture;
  68080. private _meshExcluded;
  68081. private _createPass;
  68082. private _updateMeshScreenCoordinates;
  68083. /**
  68084. * Creates a default mesh for the Volumeric Light Scattering post-process
  68085. * @param name The mesh name
  68086. * @param scene The scene where to create the mesh
  68087. * @return the default mesh
  68088. */
  68089. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68090. }
  68091. }
  68092. declare module "babylonjs/PostProcesses/index" {
  68093. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68094. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68095. export * from "babylonjs/PostProcesses/bloomEffect";
  68096. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68097. export * from "babylonjs/PostProcesses/blurPostProcess";
  68098. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68099. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68100. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68101. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68102. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68103. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68104. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68105. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68106. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68107. export * from "babylonjs/PostProcesses/filterPostProcess";
  68108. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68109. export * from "babylonjs/PostProcesses/grainPostProcess";
  68110. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68111. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68112. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68113. export * from "babylonjs/PostProcesses/passPostProcess";
  68114. export * from "babylonjs/PostProcesses/postProcess";
  68115. export * from "babylonjs/PostProcesses/postProcessManager";
  68116. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68117. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68118. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68119. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68120. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68121. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68122. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68123. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68124. }
  68125. declare module "babylonjs/Probes/index" {
  68126. export * from "babylonjs/Probes/reflectionProbe";
  68127. }
  68128. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68129. import { Scene } from "babylonjs/scene";
  68130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68131. import { SmartArray } from "babylonjs/Misc/smartArray";
  68132. import { ISceneComponent } from "babylonjs/sceneComponent";
  68133. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68134. import "babylonjs/Meshes/Builders/boxBuilder";
  68135. import "babylonjs/Shaders/color.fragment";
  68136. import "babylonjs/Shaders/color.vertex";
  68137. import { Color3 } from "babylonjs/Maths/math.color";
  68138. module "babylonjs/scene" {
  68139. interface Scene {
  68140. /** @hidden (Backing field) */
  68141. _boundingBoxRenderer: BoundingBoxRenderer;
  68142. /** @hidden (Backing field) */
  68143. _forceShowBoundingBoxes: boolean;
  68144. /**
  68145. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68146. */
  68147. forceShowBoundingBoxes: boolean;
  68148. /**
  68149. * Gets the bounding box renderer associated with the scene
  68150. * @returns a BoundingBoxRenderer
  68151. */
  68152. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68153. }
  68154. }
  68155. module "babylonjs/Meshes/abstractMesh" {
  68156. interface AbstractMesh {
  68157. /** @hidden (Backing field) */
  68158. _showBoundingBox: boolean;
  68159. /**
  68160. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68161. */
  68162. showBoundingBox: boolean;
  68163. }
  68164. }
  68165. /**
  68166. * Component responsible of rendering the bounding box of the meshes in a scene.
  68167. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68168. */
  68169. export class BoundingBoxRenderer implements ISceneComponent {
  68170. /**
  68171. * The component name helpfull to identify the component in the list of scene components.
  68172. */
  68173. readonly name: string;
  68174. /**
  68175. * The scene the component belongs to.
  68176. */
  68177. scene: Scene;
  68178. /**
  68179. * Color of the bounding box lines placed in front of an object
  68180. */
  68181. frontColor: Color3;
  68182. /**
  68183. * Color of the bounding box lines placed behind an object
  68184. */
  68185. backColor: Color3;
  68186. /**
  68187. * Defines if the renderer should show the back lines or not
  68188. */
  68189. showBackLines: boolean;
  68190. /**
  68191. * @hidden
  68192. */
  68193. renderList: SmartArray<BoundingBox>;
  68194. private _colorShader;
  68195. private _vertexBuffers;
  68196. private _indexBuffer;
  68197. private _fillIndexBuffer;
  68198. private _fillIndexData;
  68199. /**
  68200. * Instantiates a new bounding box renderer in a scene.
  68201. * @param scene the scene the renderer renders in
  68202. */
  68203. constructor(scene: Scene);
  68204. /**
  68205. * Registers the component in a given scene
  68206. */
  68207. register(): void;
  68208. private _evaluateSubMesh;
  68209. private _activeMesh;
  68210. private _prepareRessources;
  68211. private _createIndexBuffer;
  68212. /**
  68213. * Rebuilds the elements related to this component in case of
  68214. * context lost for instance.
  68215. */
  68216. rebuild(): void;
  68217. /**
  68218. * @hidden
  68219. */
  68220. reset(): void;
  68221. /**
  68222. * Render the bounding boxes of a specific rendering group
  68223. * @param renderingGroupId defines the rendering group to render
  68224. */
  68225. render(renderingGroupId: number): void;
  68226. /**
  68227. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68228. * @param mesh Define the mesh to render the occlusion bounding box for
  68229. */
  68230. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68231. /**
  68232. * Dispose and release the resources attached to this renderer.
  68233. */
  68234. dispose(): void;
  68235. }
  68236. }
  68237. declare module "babylonjs/Shaders/depth.fragment" {
  68238. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68239. /** @hidden */
  68240. export var depthPixelShader: {
  68241. name: string;
  68242. shader: string;
  68243. };
  68244. }
  68245. declare module "babylonjs/Rendering/depthRenderer" {
  68246. import { Nullable } from "babylonjs/types";
  68247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68248. import { Scene } from "babylonjs/scene";
  68249. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68250. import { Camera } from "babylonjs/Cameras/camera";
  68251. import "babylonjs/Shaders/depth.fragment";
  68252. import "babylonjs/Shaders/depth.vertex";
  68253. /**
  68254. * This represents a depth renderer in Babylon.
  68255. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68256. */
  68257. export class DepthRenderer {
  68258. private _scene;
  68259. private _depthMap;
  68260. private _effect;
  68261. private readonly _storeNonLinearDepth;
  68262. private readonly _clearColor;
  68263. /** Get if the depth renderer is using packed depth or not */
  68264. readonly isPacked: boolean;
  68265. private _cachedDefines;
  68266. private _camera;
  68267. /**
  68268. * Specifiess that the depth renderer will only be used within
  68269. * the camera it is created for.
  68270. * This can help forcing its rendering during the camera processing.
  68271. */
  68272. useOnlyInActiveCamera: boolean;
  68273. /** @hidden */
  68274. static _SceneComponentInitialization: (scene: Scene) => void;
  68275. /**
  68276. * Instantiates a depth renderer
  68277. * @param scene The scene the renderer belongs to
  68278. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68279. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68280. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68281. */
  68282. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68283. /**
  68284. * Creates the depth rendering effect and checks if the effect is ready.
  68285. * @param subMesh The submesh to be used to render the depth map of
  68286. * @param useInstances If multiple world instances should be used
  68287. * @returns if the depth renderer is ready to render the depth map
  68288. */
  68289. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68290. /**
  68291. * Gets the texture which the depth map will be written to.
  68292. * @returns The depth map texture
  68293. */
  68294. getDepthMap(): RenderTargetTexture;
  68295. /**
  68296. * Disposes of the depth renderer.
  68297. */
  68298. dispose(): void;
  68299. }
  68300. }
  68301. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68302. import { Nullable } from "babylonjs/types";
  68303. import { Scene } from "babylonjs/scene";
  68304. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68305. import { Camera } from "babylonjs/Cameras/camera";
  68306. import { ISceneComponent } from "babylonjs/sceneComponent";
  68307. module "babylonjs/scene" {
  68308. interface Scene {
  68309. /** @hidden (Backing field) */
  68310. _depthRenderer: {
  68311. [id: string]: DepthRenderer;
  68312. };
  68313. /**
  68314. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68315. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68316. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68317. * @returns the created depth renderer
  68318. */
  68319. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68320. /**
  68321. * Disables a depth renderer for a given camera
  68322. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68323. */
  68324. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68325. }
  68326. }
  68327. /**
  68328. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68329. * in several rendering techniques.
  68330. */
  68331. export class DepthRendererSceneComponent implements ISceneComponent {
  68332. /**
  68333. * The component name helpfull to identify the component in the list of scene components.
  68334. */
  68335. readonly name: string;
  68336. /**
  68337. * The scene the component belongs to.
  68338. */
  68339. scene: Scene;
  68340. /**
  68341. * Creates a new instance of the component for the given scene
  68342. * @param scene Defines the scene to register the component in
  68343. */
  68344. constructor(scene: Scene);
  68345. /**
  68346. * Registers the component in a given scene
  68347. */
  68348. register(): void;
  68349. /**
  68350. * Rebuilds the elements related to this component in case of
  68351. * context lost for instance.
  68352. */
  68353. rebuild(): void;
  68354. /**
  68355. * Disposes the component and the associated ressources
  68356. */
  68357. dispose(): void;
  68358. private _gatherRenderTargets;
  68359. private _gatherActiveCameraRenderTargets;
  68360. }
  68361. }
  68362. declare module "babylonjs/Shaders/outline.fragment" {
  68363. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68364. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68365. /** @hidden */
  68366. export var outlinePixelShader: {
  68367. name: string;
  68368. shader: string;
  68369. };
  68370. }
  68371. declare module "babylonjs/Shaders/outline.vertex" {
  68372. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68373. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68375. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68376. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68378. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68379. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68380. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68381. /** @hidden */
  68382. export var outlineVertexShader: {
  68383. name: string;
  68384. shader: string;
  68385. };
  68386. }
  68387. declare module "babylonjs/Rendering/outlineRenderer" {
  68388. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68389. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68390. import { Scene } from "babylonjs/scene";
  68391. import { ISceneComponent } from "babylonjs/sceneComponent";
  68392. import "babylonjs/Shaders/outline.fragment";
  68393. import "babylonjs/Shaders/outline.vertex";
  68394. module "babylonjs/scene" {
  68395. interface Scene {
  68396. /** @hidden */
  68397. _outlineRenderer: OutlineRenderer;
  68398. /**
  68399. * Gets the outline renderer associated with the scene
  68400. * @returns a OutlineRenderer
  68401. */
  68402. getOutlineRenderer(): OutlineRenderer;
  68403. }
  68404. }
  68405. module "babylonjs/Meshes/abstractMesh" {
  68406. interface AbstractMesh {
  68407. /** @hidden (Backing field) */
  68408. _renderOutline: boolean;
  68409. /**
  68410. * Gets or sets a boolean indicating if the outline must be rendered as well
  68411. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68412. */
  68413. renderOutline: boolean;
  68414. /** @hidden (Backing field) */
  68415. _renderOverlay: boolean;
  68416. /**
  68417. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68418. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68419. */
  68420. renderOverlay: boolean;
  68421. }
  68422. }
  68423. /**
  68424. * This class is responsible to draw bothe outline/overlay of meshes.
  68425. * It should not be used directly but through the available method on mesh.
  68426. */
  68427. export class OutlineRenderer implements ISceneComponent {
  68428. /**
  68429. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68430. */
  68431. private static _StencilReference;
  68432. /**
  68433. * The name of the component. Each component must have a unique name.
  68434. */
  68435. name: string;
  68436. /**
  68437. * The scene the component belongs to.
  68438. */
  68439. scene: Scene;
  68440. /**
  68441. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68442. */
  68443. zOffset: number;
  68444. private _engine;
  68445. private _effect;
  68446. private _cachedDefines;
  68447. private _savedDepthWrite;
  68448. /**
  68449. * Instantiates a new outline renderer. (There could be only one per scene).
  68450. * @param scene Defines the scene it belongs to
  68451. */
  68452. constructor(scene: Scene);
  68453. /**
  68454. * Register the component to one instance of a scene.
  68455. */
  68456. register(): void;
  68457. /**
  68458. * Rebuilds the elements related to this component in case of
  68459. * context lost for instance.
  68460. */
  68461. rebuild(): void;
  68462. /**
  68463. * Disposes the component and the associated ressources.
  68464. */
  68465. dispose(): void;
  68466. /**
  68467. * Renders the outline in the canvas.
  68468. * @param subMesh Defines the sumesh to render
  68469. * @param batch Defines the batch of meshes in case of instances
  68470. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68471. */
  68472. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68473. /**
  68474. * Returns whether or not the outline renderer is ready for a given submesh.
  68475. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68476. * @param subMesh Defines the submesh to check readyness for
  68477. * @param useInstances Defines wheter wee are trying to render instances or not
  68478. * @returns true if ready otherwise false
  68479. */
  68480. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68481. private _beforeRenderingMesh;
  68482. private _afterRenderingMesh;
  68483. }
  68484. }
  68485. declare module "babylonjs/Rendering/index" {
  68486. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68487. export * from "babylonjs/Rendering/depthRenderer";
  68488. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68489. export * from "babylonjs/Rendering/edgesRenderer";
  68490. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68491. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68492. export * from "babylonjs/Rendering/outlineRenderer";
  68493. export * from "babylonjs/Rendering/renderingGroup";
  68494. export * from "babylonjs/Rendering/renderingManager";
  68495. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68496. }
  68497. declare module "babylonjs/Sprites/ISprites" {
  68498. /**
  68499. * Defines the basic options interface of a Sprite Frame Source Size.
  68500. */
  68501. export interface ISpriteJSONSpriteSourceSize {
  68502. /**
  68503. * number of the original width of the Frame
  68504. */
  68505. w: number;
  68506. /**
  68507. * number of the original height of the Frame
  68508. */
  68509. h: number;
  68510. }
  68511. /**
  68512. * Defines the basic options interface of a Sprite Frame Data.
  68513. */
  68514. export interface ISpriteJSONSpriteFrameData {
  68515. /**
  68516. * number of the x offset of the Frame
  68517. */
  68518. x: number;
  68519. /**
  68520. * number of the y offset of the Frame
  68521. */
  68522. y: number;
  68523. /**
  68524. * number of the width of the Frame
  68525. */
  68526. w: number;
  68527. /**
  68528. * number of the height of the Frame
  68529. */
  68530. h: number;
  68531. }
  68532. /**
  68533. * Defines the basic options interface of a JSON Sprite.
  68534. */
  68535. export interface ISpriteJSONSprite {
  68536. /**
  68537. * string name of the Frame
  68538. */
  68539. filename: string;
  68540. /**
  68541. * ISpriteJSONSpriteFrame basic object of the frame data
  68542. */
  68543. frame: ISpriteJSONSpriteFrameData;
  68544. /**
  68545. * boolean to flag is the frame was rotated.
  68546. */
  68547. rotated: boolean;
  68548. /**
  68549. * boolean to flag is the frame was trimmed.
  68550. */
  68551. trimmed: boolean;
  68552. /**
  68553. * ISpriteJSONSpriteFrame basic object of the source data
  68554. */
  68555. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68556. /**
  68557. * ISpriteJSONSpriteFrame basic object of the source data
  68558. */
  68559. sourceSize: ISpriteJSONSpriteSourceSize;
  68560. }
  68561. /**
  68562. * Defines the basic options interface of a JSON atlas.
  68563. */
  68564. export interface ISpriteJSONAtlas {
  68565. /**
  68566. * Array of objects that contain the frame data.
  68567. */
  68568. frames: Array<ISpriteJSONSprite>;
  68569. /**
  68570. * object basic object containing the sprite meta data.
  68571. */
  68572. meta?: object;
  68573. }
  68574. }
  68575. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68576. /** @hidden */
  68577. export var spriteMapPixelShader: {
  68578. name: string;
  68579. shader: string;
  68580. };
  68581. }
  68582. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68583. /** @hidden */
  68584. export var spriteMapVertexShader: {
  68585. name: string;
  68586. shader: string;
  68587. };
  68588. }
  68589. declare module "babylonjs/Sprites/spriteMap" {
  68590. import { IDisposable, Scene } from "babylonjs/scene";
  68591. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68592. import { Texture } from "babylonjs/Materials/Textures/texture";
  68593. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68594. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68595. import "babylonjs/Meshes/Builders/planeBuilder";
  68596. import "babylonjs/Shaders/spriteMap.fragment";
  68597. import "babylonjs/Shaders/spriteMap.vertex";
  68598. /**
  68599. * Defines the basic options interface of a SpriteMap
  68600. */
  68601. export interface ISpriteMapOptions {
  68602. /**
  68603. * Vector2 of the number of cells in the grid.
  68604. */
  68605. stageSize?: Vector2;
  68606. /**
  68607. * Vector2 of the size of the output plane in World Units.
  68608. */
  68609. outputSize?: Vector2;
  68610. /**
  68611. * Vector3 of the position of the output plane in World Units.
  68612. */
  68613. outputPosition?: Vector3;
  68614. /**
  68615. * Vector3 of the rotation of the output plane.
  68616. */
  68617. outputRotation?: Vector3;
  68618. /**
  68619. * number of layers that the system will reserve in resources.
  68620. */
  68621. layerCount?: number;
  68622. /**
  68623. * number of max animation frames a single cell will reserve in resources.
  68624. */
  68625. maxAnimationFrames?: number;
  68626. /**
  68627. * number cell index of the base tile when the system compiles.
  68628. */
  68629. baseTile?: number;
  68630. /**
  68631. * boolean flip the sprite after its been repositioned by the framing data.
  68632. */
  68633. flipU?: boolean;
  68634. /**
  68635. * Vector3 scalar of the global RGB values of the SpriteMap.
  68636. */
  68637. colorMultiply?: Vector3;
  68638. }
  68639. /**
  68640. * Defines the IDisposable interface in order to be cleanable from resources.
  68641. */
  68642. export interface ISpriteMap extends IDisposable {
  68643. /**
  68644. * String name of the SpriteMap.
  68645. */
  68646. name: string;
  68647. /**
  68648. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68649. */
  68650. atlasJSON: ISpriteJSONAtlas;
  68651. /**
  68652. * Texture of the SpriteMap.
  68653. */
  68654. spriteSheet: Texture;
  68655. /**
  68656. * The parameters to initialize the SpriteMap with.
  68657. */
  68658. options: ISpriteMapOptions;
  68659. }
  68660. /**
  68661. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68662. */
  68663. export class SpriteMap implements ISpriteMap {
  68664. /** The Name of the spriteMap */
  68665. name: string;
  68666. /** The JSON file with the frame and meta data */
  68667. atlasJSON: ISpriteJSONAtlas;
  68668. /** The systems Sprite Sheet Texture */
  68669. spriteSheet: Texture;
  68670. /** Arguments passed with the Constructor */
  68671. options: ISpriteMapOptions;
  68672. /** Public Sprite Storage array, parsed from atlasJSON */
  68673. sprites: Array<ISpriteJSONSprite>;
  68674. /** Returns the Number of Sprites in the System */
  68675. get spriteCount(): number;
  68676. /** Returns the Position of Output Plane*/
  68677. get position(): Vector3;
  68678. /** Returns the Position of Output Plane*/
  68679. set position(v: Vector3);
  68680. /** Returns the Rotation of Output Plane*/
  68681. get rotation(): Vector3;
  68682. /** Returns the Rotation of Output Plane*/
  68683. set rotation(v: Vector3);
  68684. /** Sets the AnimationMap*/
  68685. get animationMap(): RawTexture;
  68686. /** Sets the AnimationMap*/
  68687. set animationMap(v: RawTexture);
  68688. /** Scene that the SpriteMap was created in */
  68689. private _scene;
  68690. /** Texture Buffer of Float32 that holds tile frame data*/
  68691. private _frameMap;
  68692. /** Texture Buffers of Float32 that holds tileMap data*/
  68693. private _tileMaps;
  68694. /** Texture Buffer of Float32 that holds Animation Data*/
  68695. private _animationMap;
  68696. /** Custom ShaderMaterial Central to the System*/
  68697. private _material;
  68698. /** Custom ShaderMaterial Central to the System*/
  68699. private _output;
  68700. /** Systems Time Ticker*/
  68701. private _time;
  68702. /**
  68703. * Creates a new SpriteMap
  68704. * @param name defines the SpriteMaps Name
  68705. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68706. * @param spriteSheet is the Texture that the Sprites are on.
  68707. * @param options a basic deployment configuration
  68708. * @param scene The Scene that the map is deployed on
  68709. */
  68710. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68711. /**
  68712. * Returns tileID location
  68713. * @returns Vector2 the cell position ID
  68714. */
  68715. getTileID(): Vector2;
  68716. /**
  68717. * Gets the UV location of the mouse over the SpriteMap.
  68718. * @returns Vector2 the UV position of the mouse interaction
  68719. */
  68720. getMousePosition(): Vector2;
  68721. /**
  68722. * Creates the "frame" texture Buffer
  68723. * -------------------------------------
  68724. * Structure of frames
  68725. * "filename": "Falling-Water-2.png",
  68726. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68727. * "rotated": true,
  68728. * "trimmed": true,
  68729. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68730. * "sourceSize": {"w":32,"h":32}
  68731. * @returns RawTexture of the frameMap
  68732. */
  68733. private _createFrameBuffer;
  68734. /**
  68735. * Creates the tileMap texture Buffer
  68736. * @param buffer normally and array of numbers, or a false to generate from scratch
  68737. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68738. * @returns RawTexture of the tileMap
  68739. */
  68740. private _createTileBuffer;
  68741. /**
  68742. * Modifies the data of the tileMaps
  68743. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68744. * @param pos is the iVector2 Coordinates of the Tile
  68745. * @param tile The SpriteIndex of the new Tile
  68746. */
  68747. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68748. /**
  68749. * Creates the animationMap texture Buffer
  68750. * @param buffer normally and array of numbers, or a false to generate from scratch
  68751. * @returns RawTexture of the animationMap
  68752. */
  68753. private _createTileAnimationBuffer;
  68754. /**
  68755. * Modifies the data of the animationMap
  68756. * @param cellID is the Index of the Sprite
  68757. * @param _frame is the target Animation frame
  68758. * @param toCell is the Target Index of the next frame of the animation
  68759. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68760. * @param speed is a global scalar of the time variable on the map.
  68761. */
  68762. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68763. /**
  68764. * Exports the .tilemaps file
  68765. */
  68766. saveTileMaps(): void;
  68767. /**
  68768. * Imports the .tilemaps file
  68769. * @param url of the .tilemaps file
  68770. */
  68771. loadTileMaps(url: string): void;
  68772. /**
  68773. * Release associated resources
  68774. */
  68775. dispose(): void;
  68776. }
  68777. }
  68778. declare module "babylonjs/Sprites/spritePackedManager" {
  68779. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68780. import { Scene } from "babylonjs/scene";
  68781. /**
  68782. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68783. * @see http://doc.babylonjs.com/babylon101/sprites
  68784. */
  68785. export class SpritePackedManager extends SpriteManager {
  68786. /** defines the packed manager's name */
  68787. name: string;
  68788. /**
  68789. * Creates a new sprite manager from a packed sprite sheet
  68790. * @param name defines the manager's name
  68791. * @param imgUrl defines the sprite sheet url
  68792. * @param capacity defines the maximum allowed number of sprites
  68793. * @param scene defines the hosting scene
  68794. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68795. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68796. * @param samplingMode defines the smapling mode to use with spritesheet
  68797. * @param fromPacked set to true; do not alter
  68798. */
  68799. constructor(
  68800. /** defines the packed manager's name */
  68801. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68802. }
  68803. }
  68804. declare module "babylonjs/Sprites/index" {
  68805. export * from "babylonjs/Sprites/sprite";
  68806. export * from "babylonjs/Sprites/ISprites";
  68807. export * from "babylonjs/Sprites/spriteManager";
  68808. export * from "babylonjs/Sprites/spriteMap";
  68809. export * from "babylonjs/Sprites/spritePackedManager";
  68810. export * from "babylonjs/Sprites/spriteSceneComponent";
  68811. }
  68812. declare module "babylonjs/States/index" {
  68813. export * from "babylonjs/States/alphaCullingState";
  68814. export * from "babylonjs/States/depthCullingState";
  68815. export * from "babylonjs/States/stencilState";
  68816. }
  68817. declare module "babylonjs/Misc/assetsManager" {
  68818. import { Scene } from "babylonjs/scene";
  68819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68820. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68821. import { Skeleton } from "babylonjs/Bones/skeleton";
  68822. import { Observable } from "babylonjs/Misc/observable";
  68823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68824. import { Texture } from "babylonjs/Materials/Textures/texture";
  68825. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68826. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68827. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68828. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68829. /**
  68830. * Defines the list of states available for a task inside a AssetsManager
  68831. */
  68832. export enum AssetTaskState {
  68833. /**
  68834. * Initialization
  68835. */
  68836. INIT = 0,
  68837. /**
  68838. * Running
  68839. */
  68840. RUNNING = 1,
  68841. /**
  68842. * Done
  68843. */
  68844. DONE = 2,
  68845. /**
  68846. * Error
  68847. */
  68848. ERROR = 3
  68849. }
  68850. /**
  68851. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68852. */
  68853. export abstract class AbstractAssetTask {
  68854. /**
  68855. * Task name
  68856. */ name: string;
  68857. /**
  68858. * Callback called when the task is successful
  68859. */
  68860. onSuccess: (task: any) => void;
  68861. /**
  68862. * Callback called when the task is not successful
  68863. */
  68864. onError: (task: any, message?: string, exception?: any) => void;
  68865. /**
  68866. * Creates a new AssetsManager
  68867. * @param name defines the name of the task
  68868. */
  68869. constructor(
  68870. /**
  68871. * Task name
  68872. */ name: string);
  68873. private _isCompleted;
  68874. private _taskState;
  68875. private _errorObject;
  68876. /**
  68877. * Get if the task is completed
  68878. */
  68879. get isCompleted(): boolean;
  68880. /**
  68881. * Gets the current state of the task
  68882. */
  68883. get taskState(): AssetTaskState;
  68884. /**
  68885. * Gets the current error object (if task is in error)
  68886. */
  68887. get errorObject(): {
  68888. message?: string;
  68889. exception?: any;
  68890. };
  68891. /**
  68892. * Internal only
  68893. * @hidden
  68894. */
  68895. _setErrorObject(message?: string, exception?: any): void;
  68896. /**
  68897. * Execute the current task
  68898. * @param scene defines the scene where you want your assets to be loaded
  68899. * @param onSuccess is a callback called when the task is successfully executed
  68900. * @param onError is a callback called if an error occurs
  68901. */
  68902. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68903. /**
  68904. * Execute the current task
  68905. * @param scene defines the scene where you want your assets to be loaded
  68906. * @param onSuccess is a callback called when the task is successfully executed
  68907. * @param onError is a callback called if an error occurs
  68908. */
  68909. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68910. /**
  68911. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68912. * This can be used with failed tasks that have the reason for failure fixed.
  68913. */
  68914. reset(): void;
  68915. private onErrorCallback;
  68916. private onDoneCallback;
  68917. }
  68918. /**
  68919. * Define the interface used by progress events raised during assets loading
  68920. */
  68921. export interface IAssetsProgressEvent {
  68922. /**
  68923. * Defines the number of remaining tasks to process
  68924. */
  68925. remainingCount: number;
  68926. /**
  68927. * Defines the total number of tasks
  68928. */
  68929. totalCount: number;
  68930. /**
  68931. * Defines the task that was just processed
  68932. */
  68933. task: AbstractAssetTask;
  68934. }
  68935. /**
  68936. * Class used to share progress information about assets loading
  68937. */
  68938. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68939. /**
  68940. * Defines the number of remaining tasks to process
  68941. */
  68942. remainingCount: number;
  68943. /**
  68944. * Defines the total number of tasks
  68945. */
  68946. totalCount: number;
  68947. /**
  68948. * Defines the task that was just processed
  68949. */
  68950. task: AbstractAssetTask;
  68951. /**
  68952. * Creates a AssetsProgressEvent
  68953. * @param remainingCount defines the number of remaining tasks to process
  68954. * @param totalCount defines the total number of tasks
  68955. * @param task defines the task that was just processed
  68956. */
  68957. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68958. }
  68959. /**
  68960. * Define a task used by AssetsManager to load meshes
  68961. */
  68962. export class MeshAssetTask extends AbstractAssetTask {
  68963. /**
  68964. * Defines the name of the task
  68965. */
  68966. name: string;
  68967. /**
  68968. * Defines the list of mesh's names you want to load
  68969. */
  68970. meshesNames: any;
  68971. /**
  68972. * Defines the root url to use as a base to load your meshes and associated resources
  68973. */
  68974. rootUrl: string;
  68975. /**
  68976. * Defines the filename of the scene to load from
  68977. */
  68978. sceneFilename: string;
  68979. /**
  68980. * Gets the list of loaded meshes
  68981. */
  68982. loadedMeshes: Array<AbstractMesh>;
  68983. /**
  68984. * Gets the list of loaded particle systems
  68985. */
  68986. loadedParticleSystems: Array<IParticleSystem>;
  68987. /**
  68988. * Gets the list of loaded skeletons
  68989. */
  68990. loadedSkeletons: Array<Skeleton>;
  68991. /**
  68992. * Gets the list of loaded animation groups
  68993. */
  68994. loadedAnimationGroups: Array<AnimationGroup>;
  68995. /**
  68996. * Callback called when the task is successful
  68997. */
  68998. onSuccess: (task: MeshAssetTask) => void;
  68999. /**
  69000. * Callback called when the task is successful
  69001. */
  69002. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69003. /**
  69004. * Creates a new MeshAssetTask
  69005. * @param name defines the name of the task
  69006. * @param meshesNames defines the list of mesh's names you want to load
  69007. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69008. * @param sceneFilename defines the filename of the scene to load from
  69009. */
  69010. constructor(
  69011. /**
  69012. * Defines the name of the task
  69013. */
  69014. name: string,
  69015. /**
  69016. * Defines the list of mesh's names you want to load
  69017. */
  69018. meshesNames: any,
  69019. /**
  69020. * Defines the root url to use as a base to load your meshes and associated resources
  69021. */
  69022. rootUrl: string,
  69023. /**
  69024. * Defines the filename of the scene to load from
  69025. */
  69026. sceneFilename: string);
  69027. /**
  69028. * Execute the current task
  69029. * @param scene defines the scene where you want your assets to be loaded
  69030. * @param onSuccess is a callback called when the task is successfully executed
  69031. * @param onError is a callback called if an error occurs
  69032. */
  69033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69034. }
  69035. /**
  69036. * Define a task used by AssetsManager to load text content
  69037. */
  69038. export class TextFileAssetTask extends AbstractAssetTask {
  69039. /**
  69040. * Defines the name of the task
  69041. */
  69042. name: string;
  69043. /**
  69044. * Defines the location of the file to load
  69045. */
  69046. url: string;
  69047. /**
  69048. * Gets the loaded text string
  69049. */
  69050. text: string;
  69051. /**
  69052. * Callback called when the task is successful
  69053. */
  69054. onSuccess: (task: TextFileAssetTask) => void;
  69055. /**
  69056. * Callback called when the task is successful
  69057. */
  69058. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69059. /**
  69060. * Creates a new TextFileAssetTask object
  69061. * @param name defines the name of the task
  69062. * @param url defines the location of the file to load
  69063. */
  69064. constructor(
  69065. /**
  69066. * Defines the name of the task
  69067. */
  69068. name: string,
  69069. /**
  69070. * Defines the location of the file to load
  69071. */
  69072. url: string);
  69073. /**
  69074. * Execute the current task
  69075. * @param scene defines the scene where you want your assets to be loaded
  69076. * @param onSuccess is a callback called when the task is successfully executed
  69077. * @param onError is a callback called if an error occurs
  69078. */
  69079. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69080. }
  69081. /**
  69082. * Define a task used by AssetsManager to load binary data
  69083. */
  69084. export class BinaryFileAssetTask extends AbstractAssetTask {
  69085. /**
  69086. * Defines the name of the task
  69087. */
  69088. name: string;
  69089. /**
  69090. * Defines the location of the file to load
  69091. */
  69092. url: string;
  69093. /**
  69094. * Gets the lodaded data (as an array buffer)
  69095. */
  69096. data: ArrayBuffer;
  69097. /**
  69098. * Callback called when the task is successful
  69099. */
  69100. onSuccess: (task: BinaryFileAssetTask) => void;
  69101. /**
  69102. * Callback called when the task is successful
  69103. */
  69104. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69105. /**
  69106. * Creates a new BinaryFileAssetTask object
  69107. * @param name defines the name of the new task
  69108. * @param url defines the location of the file to load
  69109. */
  69110. constructor(
  69111. /**
  69112. * Defines the name of the task
  69113. */
  69114. name: string,
  69115. /**
  69116. * Defines the location of the file to load
  69117. */
  69118. url: string);
  69119. /**
  69120. * Execute the current task
  69121. * @param scene defines the scene where you want your assets to be loaded
  69122. * @param onSuccess is a callback called when the task is successfully executed
  69123. * @param onError is a callback called if an error occurs
  69124. */
  69125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69126. }
  69127. /**
  69128. * Define a task used by AssetsManager to load images
  69129. */
  69130. export class ImageAssetTask extends AbstractAssetTask {
  69131. /**
  69132. * Defines the name of the task
  69133. */
  69134. name: string;
  69135. /**
  69136. * Defines the location of the image to load
  69137. */
  69138. url: string;
  69139. /**
  69140. * Gets the loaded images
  69141. */
  69142. image: HTMLImageElement;
  69143. /**
  69144. * Callback called when the task is successful
  69145. */
  69146. onSuccess: (task: ImageAssetTask) => void;
  69147. /**
  69148. * Callback called when the task is successful
  69149. */
  69150. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69151. /**
  69152. * Creates a new ImageAssetTask
  69153. * @param name defines the name of the task
  69154. * @param url defines the location of the image to load
  69155. */
  69156. constructor(
  69157. /**
  69158. * Defines the name of the task
  69159. */
  69160. name: string,
  69161. /**
  69162. * Defines the location of the image to load
  69163. */
  69164. url: string);
  69165. /**
  69166. * Execute the current task
  69167. * @param scene defines the scene where you want your assets to be loaded
  69168. * @param onSuccess is a callback called when the task is successfully executed
  69169. * @param onError is a callback called if an error occurs
  69170. */
  69171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69172. }
  69173. /**
  69174. * Defines the interface used by texture loading tasks
  69175. */
  69176. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69177. /**
  69178. * Gets the loaded texture
  69179. */
  69180. texture: TEX;
  69181. }
  69182. /**
  69183. * Define a task used by AssetsManager to load 2D textures
  69184. */
  69185. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69186. /**
  69187. * Defines the name of the task
  69188. */
  69189. name: string;
  69190. /**
  69191. * Defines the location of the file to load
  69192. */
  69193. url: string;
  69194. /**
  69195. * Defines if mipmap should not be generated (default is false)
  69196. */
  69197. noMipmap?: boolean | undefined;
  69198. /**
  69199. * Defines if texture must be inverted on Y axis (default is false)
  69200. */
  69201. invertY?: boolean | undefined;
  69202. /**
  69203. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69204. */
  69205. samplingMode: number;
  69206. /**
  69207. * Gets the loaded texture
  69208. */
  69209. texture: Texture;
  69210. /**
  69211. * Callback called when the task is successful
  69212. */
  69213. onSuccess: (task: TextureAssetTask) => void;
  69214. /**
  69215. * Callback called when the task is successful
  69216. */
  69217. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69218. /**
  69219. * Creates a new TextureAssetTask object
  69220. * @param name defines the name of the task
  69221. * @param url defines the location of the file to load
  69222. * @param noMipmap defines if mipmap should not be generated (default is false)
  69223. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69224. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69225. */
  69226. constructor(
  69227. /**
  69228. * Defines the name of the task
  69229. */
  69230. name: string,
  69231. /**
  69232. * Defines the location of the file to load
  69233. */
  69234. url: string,
  69235. /**
  69236. * Defines if mipmap should not be generated (default is false)
  69237. */
  69238. noMipmap?: boolean | undefined,
  69239. /**
  69240. * Defines if texture must be inverted on Y axis (default is false)
  69241. */
  69242. invertY?: boolean | undefined,
  69243. /**
  69244. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69245. */
  69246. samplingMode?: number);
  69247. /**
  69248. * Execute the current task
  69249. * @param scene defines the scene where you want your assets to be loaded
  69250. * @param onSuccess is a callback called when the task is successfully executed
  69251. * @param onError is a callback called if an error occurs
  69252. */
  69253. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69254. }
  69255. /**
  69256. * Define a task used by AssetsManager to load cube textures
  69257. */
  69258. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69259. /**
  69260. * Defines the name of the task
  69261. */
  69262. name: string;
  69263. /**
  69264. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69265. */
  69266. url: string;
  69267. /**
  69268. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69269. */
  69270. extensions?: string[] | undefined;
  69271. /**
  69272. * Defines if mipmaps should not be generated (default is false)
  69273. */
  69274. noMipmap?: boolean | undefined;
  69275. /**
  69276. * Defines the explicit list of files (undefined by default)
  69277. */
  69278. files?: string[] | undefined;
  69279. /**
  69280. * Gets the loaded texture
  69281. */
  69282. texture: CubeTexture;
  69283. /**
  69284. * Callback called when the task is successful
  69285. */
  69286. onSuccess: (task: CubeTextureAssetTask) => void;
  69287. /**
  69288. * Callback called when the task is successful
  69289. */
  69290. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69291. /**
  69292. * Creates a new CubeTextureAssetTask
  69293. * @param name defines the name of the task
  69294. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69295. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69296. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69297. * @param files defines the explicit list of files (undefined by default)
  69298. */
  69299. constructor(
  69300. /**
  69301. * Defines the name of the task
  69302. */
  69303. name: string,
  69304. /**
  69305. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69306. */
  69307. url: string,
  69308. /**
  69309. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69310. */
  69311. extensions?: string[] | undefined,
  69312. /**
  69313. * Defines if mipmaps should not be generated (default is false)
  69314. */
  69315. noMipmap?: boolean | undefined,
  69316. /**
  69317. * Defines the explicit list of files (undefined by default)
  69318. */
  69319. files?: string[] | undefined);
  69320. /**
  69321. * Execute the current task
  69322. * @param scene defines the scene where you want your assets to be loaded
  69323. * @param onSuccess is a callback called when the task is successfully executed
  69324. * @param onError is a callback called if an error occurs
  69325. */
  69326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69327. }
  69328. /**
  69329. * Define a task used by AssetsManager to load HDR cube textures
  69330. */
  69331. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69332. /**
  69333. * Defines the name of the task
  69334. */
  69335. name: string;
  69336. /**
  69337. * Defines the location of the file to load
  69338. */
  69339. url: string;
  69340. /**
  69341. * Defines the desired size (the more it increases the longer the generation will be)
  69342. */
  69343. size: number;
  69344. /**
  69345. * Defines if mipmaps should not be generated (default is false)
  69346. */
  69347. noMipmap: boolean;
  69348. /**
  69349. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69350. */
  69351. generateHarmonics: boolean;
  69352. /**
  69353. * 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)
  69354. */
  69355. gammaSpace: boolean;
  69356. /**
  69357. * Internal Use Only
  69358. */
  69359. reserved: boolean;
  69360. /**
  69361. * Gets the loaded texture
  69362. */
  69363. texture: HDRCubeTexture;
  69364. /**
  69365. * Callback called when the task is successful
  69366. */
  69367. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69368. /**
  69369. * Callback called when the task is successful
  69370. */
  69371. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69372. /**
  69373. * Creates a new HDRCubeTextureAssetTask object
  69374. * @param name defines the name of the task
  69375. * @param url defines the location of the file to load
  69376. * @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.
  69377. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69378. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69379. * @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)
  69380. * @param reserved Internal use only
  69381. */
  69382. constructor(
  69383. /**
  69384. * Defines the name of the task
  69385. */
  69386. name: string,
  69387. /**
  69388. * Defines the location of the file to load
  69389. */
  69390. url: string,
  69391. /**
  69392. * Defines the desired size (the more it increases the longer the generation will be)
  69393. */
  69394. size: number,
  69395. /**
  69396. * Defines if mipmaps should not be generated (default is false)
  69397. */
  69398. noMipmap?: boolean,
  69399. /**
  69400. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69401. */
  69402. generateHarmonics?: boolean,
  69403. /**
  69404. * 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)
  69405. */
  69406. gammaSpace?: boolean,
  69407. /**
  69408. * Internal Use Only
  69409. */
  69410. reserved?: boolean);
  69411. /**
  69412. * Execute the current task
  69413. * @param scene defines the scene where you want your assets to be loaded
  69414. * @param onSuccess is a callback called when the task is successfully executed
  69415. * @param onError is a callback called if an error occurs
  69416. */
  69417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69418. }
  69419. /**
  69420. * Define a task used by AssetsManager to load Equirectangular cube textures
  69421. */
  69422. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69423. /**
  69424. * Defines the name of the task
  69425. */
  69426. name: string;
  69427. /**
  69428. * Defines the location of the file to load
  69429. */
  69430. url: string;
  69431. /**
  69432. * Defines the desired size (the more it increases the longer the generation will be)
  69433. */
  69434. size: number;
  69435. /**
  69436. * Defines if mipmaps should not be generated (default is false)
  69437. */
  69438. noMipmap: boolean;
  69439. /**
  69440. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69441. * but the standard material would require them in Gamma space) (default is true)
  69442. */
  69443. gammaSpace: boolean;
  69444. /**
  69445. * Gets the loaded texture
  69446. */
  69447. texture: EquiRectangularCubeTexture;
  69448. /**
  69449. * Callback called when the task is successful
  69450. */
  69451. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69452. /**
  69453. * Callback called when the task is successful
  69454. */
  69455. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69456. /**
  69457. * Creates a new EquiRectangularCubeTextureAssetTask object
  69458. * @param name defines the name of the task
  69459. * @param url defines the location of the file to load
  69460. * @param size defines the desired size (the more it increases the longer the generation will be)
  69461. * If the size is omitted this implies you are using a preprocessed cubemap.
  69462. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69463. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69464. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69465. * (default is true)
  69466. */
  69467. constructor(
  69468. /**
  69469. * Defines the name of the task
  69470. */
  69471. name: string,
  69472. /**
  69473. * Defines the location of the file to load
  69474. */
  69475. url: string,
  69476. /**
  69477. * Defines the desired size (the more it increases the longer the generation will be)
  69478. */
  69479. size: number,
  69480. /**
  69481. * Defines if mipmaps should not be generated (default is false)
  69482. */
  69483. noMipmap?: boolean,
  69484. /**
  69485. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69486. * but the standard material would require them in Gamma space) (default is true)
  69487. */
  69488. gammaSpace?: boolean);
  69489. /**
  69490. * Execute the current task
  69491. * @param scene defines the scene where you want your assets to be loaded
  69492. * @param onSuccess is a callback called when the task is successfully executed
  69493. * @param onError is a callback called if an error occurs
  69494. */
  69495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69496. }
  69497. /**
  69498. * This class can be used to easily import assets into a scene
  69499. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69500. */
  69501. export class AssetsManager {
  69502. private _scene;
  69503. private _isLoading;
  69504. protected _tasks: AbstractAssetTask[];
  69505. protected _waitingTasksCount: number;
  69506. protected _totalTasksCount: number;
  69507. /**
  69508. * Callback called when all tasks are processed
  69509. */
  69510. onFinish: (tasks: AbstractAssetTask[]) => void;
  69511. /**
  69512. * Callback called when a task is successful
  69513. */
  69514. onTaskSuccess: (task: AbstractAssetTask) => void;
  69515. /**
  69516. * Callback called when a task had an error
  69517. */
  69518. onTaskError: (task: AbstractAssetTask) => void;
  69519. /**
  69520. * Callback called when a task is done (whatever the result is)
  69521. */
  69522. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69523. /**
  69524. * Observable called when all tasks are processed
  69525. */
  69526. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69527. /**
  69528. * Observable called when a task had an error
  69529. */
  69530. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69531. /**
  69532. * Observable called when all tasks were executed
  69533. */
  69534. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69535. /**
  69536. * Observable called when a task is done (whatever the result is)
  69537. */
  69538. onProgressObservable: Observable<IAssetsProgressEvent>;
  69539. /**
  69540. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69541. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69542. */
  69543. useDefaultLoadingScreen: boolean;
  69544. /**
  69545. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69546. * when all assets have been downloaded.
  69547. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69548. */
  69549. autoHideLoadingUI: boolean;
  69550. /**
  69551. * Creates a new AssetsManager
  69552. * @param scene defines the scene to work on
  69553. */
  69554. constructor(scene: Scene);
  69555. /**
  69556. * Add a MeshAssetTask to the list of active tasks
  69557. * @param taskName defines the name of the new task
  69558. * @param meshesNames defines the name of meshes to load
  69559. * @param rootUrl defines the root url to use to locate files
  69560. * @param sceneFilename defines the filename of the scene file
  69561. * @returns a new MeshAssetTask object
  69562. */
  69563. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69564. /**
  69565. * Add a TextFileAssetTask to the list of active tasks
  69566. * @param taskName defines the name of the new task
  69567. * @param url defines the url of the file to load
  69568. * @returns a new TextFileAssetTask object
  69569. */
  69570. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69571. /**
  69572. * Add a BinaryFileAssetTask to the list of active tasks
  69573. * @param taskName defines the name of the new task
  69574. * @param url defines the url of the file to load
  69575. * @returns a new BinaryFileAssetTask object
  69576. */
  69577. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69578. /**
  69579. * Add a ImageAssetTask to the list of active tasks
  69580. * @param taskName defines the name of the new task
  69581. * @param url defines the url of the file to load
  69582. * @returns a new ImageAssetTask object
  69583. */
  69584. addImageTask(taskName: string, url: string): ImageAssetTask;
  69585. /**
  69586. * Add a TextureAssetTask to the list of active tasks
  69587. * @param taskName defines the name of the new task
  69588. * @param url defines the url of the file to load
  69589. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69590. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69591. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69592. * @returns a new TextureAssetTask object
  69593. */
  69594. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69595. /**
  69596. * Add a CubeTextureAssetTask to the list of active tasks
  69597. * @param taskName defines the name of the new task
  69598. * @param url defines the url of the file to load
  69599. * @param extensions defines the extension to use to load the cube map (can be null)
  69600. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69601. * @param files defines the list of files to load (can be null)
  69602. * @returns a new CubeTextureAssetTask object
  69603. */
  69604. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69605. /**
  69606. *
  69607. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69608. * @param taskName defines the name of the new task
  69609. * @param url defines the url of the file to load
  69610. * @param size defines the size you want for the cubemap (can be null)
  69611. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69612. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69613. * @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)
  69614. * @param reserved Internal use only
  69615. * @returns a new HDRCubeTextureAssetTask object
  69616. */
  69617. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69618. /**
  69619. *
  69620. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69621. * @param taskName defines the name of the new task
  69622. * @param url defines the url of the file to load
  69623. * @param size defines the size you want for the cubemap (can be null)
  69624. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69625. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69626. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69627. * @returns a new EquiRectangularCubeTextureAssetTask object
  69628. */
  69629. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69630. /**
  69631. * Remove a task from the assets manager.
  69632. * @param task the task to remove
  69633. */
  69634. removeTask(task: AbstractAssetTask): void;
  69635. private _decreaseWaitingTasksCount;
  69636. private _runTask;
  69637. /**
  69638. * Reset the AssetsManager and remove all tasks
  69639. * @return the current instance of the AssetsManager
  69640. */
  69641. reset(): AssetsManager;
  69642. /**
  69643. * Start the loading process
  69644. * @return the current instance of the AssetsManager
  69645. */
  69646. load(): AssetsManager;
  69647. /**
  69648. * Start the loading process as an async operation
  69649. * @return a promise returning the list of failed tasks
  69650. */
  69651. loadAsync(): Promise<void>;
  69652. }
  69653. }
  69654. declare module "babylonjs/Misc/deferred" {
  69655. /**
  69656. * Wrapper class for promise with external resolve and reject.
  69657. */
  69658. export class Deferred<T> {
  69659. /**
  69660. * The promise associated with this deferred object.
  69661. */
  69662. readonly promise: Promise<T>;
  69663. private _resolve;
  69664. private _reject;
  69665. /**
  69666. * The resolve method of the promise associated with this deferred object.
  69667. */
  69668. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69669. /**
  69670. * The reject method of the promise associated with this deferred object.
  69671. */
  69672. get reject(): (reason?: any) => void;
  69673. /**
  69674. * Constructor for this deferred object.
  69675. */
  69676. constructor();
  69677. }
  69678. }
  69679. declare module "babylonjs/Misc/meshExploder" {
  69680. import { Mesh } from "babylonjs/Meshes/mesh";
  69681. /**
  69682. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69683. */
  69684. export class MeshExploder {
  69685. private _centerMesh;
  69686. private _meshes;
  69687. private _meshesOrigins;
  69688. private _toCenterVectors;
  69689. private _scaledDirection;
  69690. private _newPosition;
  69691. private _centerPosition;
  69692. /**
  69693. * Explodes meshes from a center mesh.
  69694. * @param meshes The meshes to explode.
  69695. * @param centerMesh The mesh to be center of explosion.
  69696. */
  69697. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69698. private _setCenterMesh;
  69699. /**
  69700. * Get class name
  69701. * @returns "MeshExploder"
  69702. */
  69703. getClassName(): string;
  69704. /**
  69705. * "Exploded meshes"
  69706. * @returns Array of meshes with the centerMesh at index 0.
  69707. */
  69708. getMeshes(): Array<Mesh>;
  69709. /**
  69710. * Explodes meshes giving a specific direction
  69711. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69712. */
  69713. explode(direction?: number): void;
  69714. }
  69715. }
  69716. declare module "babylonjs/Misc/filesInput" {
  69717. import { Engine } from "babylonjs/Engines/engine";
  69718. import { Scene } from "babylonjs/scene";
  69719. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69720. /**
  69721. * Class used to help managing file picking and drag'n'drop
  69722. */
  69723. export class FilesInput {
  69724. /**
  69725. * List of files ready to be loaded
  69726. */
  69727. static get FilesToLoad(): {
  69728. [key: string]: File;
  69729. };
  69730. /**
  69731. * Callback called when a file is processed
  69732. */
  69733. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69734. private _engine;
  69735. private _currentScene;
  69736. private _sceneLoadedCallback;
  69737. private _progressCallback;
  69738. private _additionalRenderLoopLogicCallback;
  69739. private _textureLoadingCallback;
  69740. private _startingProcessingFilesCallback;
  69741. private _onReloadCallback;
  69742. private _errorCallback;
  69743. private _elementToMonitor;
  69744. private _sceneFileToLoad;
  69745. private _filesToLoad;
  69746. /**
  69747. * Creates a new FilesInput
  69748. * @param engine defines the rendering engine
  69749. * @param scene defines the hosting scene
  69750. * @param sceneLoadedCallback callback called when scene is loaded
  69751. * @param progressCallback callback called to track progress
  69752. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69753. * @param textureLoadingCallback callback called when a texture is loading
  69754. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69755. * @param onReloadCallback callback called when a reload is requested
  69756. * @param errorCallback callback call if an error occurs
  69757. */
  69758. 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);
  69759. private _dragEnterHandler;
  69760. private _dragOverHandler;
  69761. private _dropHandler;
  69762. /**
  69763. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69764. * @param elementToMonitor defines the DOM element to track
  69765. */
  69766. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69767. /**
  69768. * Release all associated resources
  69769. */
  69770. dispose(): void;
  69771. private renderFunction;
  69772. private drag;
  69773. private drop;
  69774. private _traverseFolder;
  69775. private _processFiles;
  69776. /**
  69777. * Load files from a drop event
  69778. * @param event defines the drop event to use as source
  69779. */
  69780. loadFiles(event: any): void;
  69781. private _processReload;
  69782. /**
  69783. * Reload the current scene from the loaded files
  69784. */
  69785. reload(): void;
  69786. }
  69787. }
  69788. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69789. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69790. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69791. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69792. }
  69793. declare module "babylonjs/Misc/sceneOptimizer" {
  69794. import { Scene, IDisposable } from "babylonjs/scene";
  69795. import { Observable } from "babylonjs/Misc/observable";
  69796. /**
  69797. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69799. */
  69800. export class SceneOptimization {
  69801. /**
  69802. * Defines the priority of this optimization (0 by default which means first in the list)
  69803. */
  69804. priority: number;
  69805. /**
  69806. * Gets a string describing the action executed by the current optimization
  69807. * @returns description string
  69808. */
  69809. getDescription(): string;
  69810. /**
  69811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69812. * @param scene defines the current scene where to apply this optimization
  69813. * @param optimizer defines the current optimizer
  69814. * @returns true if everything that can be done was applied
  69815. */
  69816. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69817. /**
  69818. * Creates the SceneOptimization object
  69819. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69820. * @param desc defines the description associated with the optimization
  69821. */
  69822. constructor(
  69823. /**
  69824. * Defines the priority of this optimization (0 by default which means first in the list)
  69825. */
  69826. priority?: number);
  69827. }
  69828. /**
  69829. * Defines an optimization used to reduce the size of render target textures
  69830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69831. */
  69832. export class TextureOptimization extends SceneOptimization {
  69833. /**
  69834. * Defines the priority of this optimization (0 by default which means first in the list)
  69835. */
  69836. priority: number;
  69837. /**
  69838. * 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
  69839. */
  69840. maximumSize: number;
  69841. /**
  69842. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69843. */
  69844. step: number;
  69845. /**
  69846. * Gets a string describing the action executed by the current optimization
  69847. * @returns description string
  69848. */
  69849. getDescription(): string;
  69850. /**
  69851. * Creates the TextureOptimization object
  69852. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69853. * @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
  69854. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69855. */
  69856. constructor(
  69857. /**
  69858. * Defines the priority of this optimization (0 by default which means first in the list)
  69859. */
  69860. priority?: number,
  69861. /**
  69862. * 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
  69863. */
  69864. maximumSize?: number,
  69865. /**
  69866. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69867. */
  69868. step?: number);
  69869. /**
  69870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69871. * @param scene defines the current scene where to apply this optimization
  69872. * @param optimizer defines the current optimizer
  69873. * @returns true if everything that can be done was applied
  69874. */
  69875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69876. }
  69877. /**
  69878. * Defines an optimization used to increase or decrease the rendering resolution
  69879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69880. */
  69881. export class HardwareScalingOptimization extends SceneOptimization {
  69882. /**
  69883. * Defines the priority of this optimization (0 by default which means first in the list)
  69884. */
  69885. priority: number;
  69886. /**
  69887. * Defines the maximum scale to use (2 by default)
  69888. */
  69889. maximumScale: number;
  69890. /**
  69891. * Defines the step to use between two passes (0.5 by default)
  69892. */
  69893. step: number;
  69894. private _currentScale;
  69895. private _directionOffset;
  69896. /**
  69897. * Gets a string describing the action executed by the current optimization
  69898. * @return description string
  69899. */
  69900. getDescription(): string;
  69901. /**
  69902. * Creates the HardwareScalingOptimization object
  69903. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69904. * @param maximumScale defines the maximum scale to use (2 by default)
  69905. * @param step defines the step to use between two passes (0.5 by default)
  69906. */
  69907. constructor(
  69908. /**
  69909. * Defines the priority of this optimization (0 by default which means first in the list)
  69910. */
  69911. priority?: number,
  69912. /**
  69913. * Defines the maximum scale to use (2 by default)
  69914. */
  69915. maximumScale?: number,
  69916. /**
  69917. * Defines the step to use between two passes (0.5 by default)
  69918. */
  69919. step?: number);
  69920. /**
  69921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69922. * @param scene defines the current scene where to apply this optimization
  69923. * @param optimizer defines the current optimizer
  69924. * @returns true if everything that can be done was applied
  69925. */
  69926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69927. }
  69928. /**
  69929. * Defines an optimization used to remove shadows
  69930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69931. */
  69932. export class ShadowsOptimization extends SceneOptimization {
  69933. /**
  69934. * Gets a string describing the action executed by the current optimization
  69935. * @return description string
  69936. */
  69937. getDescription(): string;
  69938. /**
  69939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69940. * @param scene defines the current scene where to apply this optimization
  69941. * @param optimizer defines the current optimizer
  69942. * @returns true if everything that can be done was applied
  69943. */
  69944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69945. }
  69946. /**
  69947. * Defines an optimization used to turn post-processes off
  69948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69949. */
  69950. export class PostProcessesOptimization extends SceneOptimization {
  69951. /**
  69952. * Gets a string describing the action executed by the current optimization
  69953. * @return description string
  69954. */
  69955. getDescription(): string;
  69956. /**
  69957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69958. * @param scene defines the current scene where to apply this optimization
  69959. * @param optimizer defines the current optimizer
  69960. * @returns true if everything that can be done was applied
  69961. */
  69962. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69963. }
  69964. /**
  69965. * Defines an optimization used to turn lens flares off
  69966. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69967. */
  69968. export class LensFlaresOptimization extends SceneOptimization {
  69969. /**
  69970. * Gets a string describing the action executed by the current optimization
  69971. * @return description string
  69972. */
  69973. getDescription(): string;
  69974. /**
  69975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69976. * @param scene defines the current scene where to apply this optimization
  69977. * @param optimizer defines the current optimizer
  69978. * @returns true if everything that can be done was applied
  69979. */
  69980. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69981. }
  69982. /**
  69983. * Defines an optimization based on user defined callback.
  69984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69985. */
  69986. export class CustomOptimization extends SceneOptimization {
  69987. /**
  69988. * Callback called to apply the custom optimization.
  69989. */
  69990. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69991. /**
  69992. * Callback called to get custom description
  69993. */
  69994. onGetDescription: () => string;
  69995. /**
  69996. * Gets a string describing the action executed by the current optimization
  69997. * @returns description string
  69998. */
  69999. getDescription(): string;
  70000. /**
  70001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70002. * @param scene defines the current scene where to apply this optimization
  70003. * @param optimizer defines the current optimizer
  70004. * @returns true if everything that can be done was applied
  70005. */
  70006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70007. }
  70008. /**
  70009. * Defines an optimization used to turn particles off
  70010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70011. */
  70012. export class ParticlesOptimization extends SceneOptimization {
  70013. /**
  70014. * Gets a string describing the action executed by the current optimization
  70015. * @return description string
  70016. */
  70017. getDescription(): string;
  70018. /**
  70019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70020. * @param scene defines the current scene where to apply this optimization
  70021. * @param optimizer defines the current optimizer
  70022. * @returns true if everything that can be done was applied
  70023. */
  70024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70025. }
  70026. /**
  70027. * Defines an optimization used to turn render targets off
  70028. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70029. */
  70030. export class RenderTargetsOptimization extends SceneOptimization {
  70031. /**
  70032. * Gets a string describing the action executed by the current optimization
  70033. * @return description string
  70034. */
  70035. getDescription(): string;
  70036. /**
  70037. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70038. * @param scene defines the current scene where to apply this optimization
  70039. * @param optimizer defines the current optimizer
  70040. * @returns true if everything that can be done was applied
  70041. */
  70042. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70043. }
  70044. /**
  70045. * Defines an optimization used to merge meshes with compatible materials
  70046. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70047. */
  70048. export class MergeMeshesOptimization extends SceneOptimization {
  70049. private static _UpdateSelectionTree;
  70050. /**
  70051. * Gets or sets a boolean which defines if optimization octree has to be updated
  70052. */
  70053. static get UpdateSelectionTree(): boolean;
  70054. /**
  70055. * Gets or sets a boolean which defines if optimization octree has to be updated
  70056. */
  70057. static set UpdateSelectionTree(value: boolean);
  70058. /**
  70059. * Gets a string describing the action executed by the current optimization
  70060. * @return description string
  70061. */
  70062. getDescription(): string;
  70063. private _canBeMerged;
  70064. /**
  70065. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70066. * @param scene defines the current scene where to apply this optimization
  70067. * @param optimizer defines the current optimizer
  70068. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70069. * @returns true if everything that can be done was applied
  70070. */
  70071. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70072. }
  70073. /**
  70074. * Defines a list of options used by SceneOptimizer
  70075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70076. */
  70077. export class SceneOptimizerOptions {
  70078. /**
  70079. * Defines the target frame rate to reach (60 by default)
  70080. */
  70081. targetFrameRate: number;
  70082. /**
  70083. * Defines the interval between two checkes (2000ms by default)
  70084. */
  70085. trackerDuration: number;
  70086. /**
  70087. * Gets the list of optimizations to apply
  70088. */
  70089. optimizations: SceneOptimization[];
  70090. /**
  70091. * Creates a new list of options used by SceneOptimizer
  70092. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70093. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70094. */
  70095. constructor(
  70096. /**
  70097. * Defines the target frame rate to reach (60 by default)
  70098. */
  70099. targetFrameRate?: number,
  70100. /**
  70101. * Defines the interval between two checkes (2000ms by default)
  70102. */
  70103. trackerDuration?: number);
  70104. /**
  70105. * Add a new optimization
  70106. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70107. * @returns the current SceneOptimizerOptions
  70108. */
  70109. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70110. /**
  70111. * Add a new custom optimization
  70112. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70113. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70114. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70115. * @returns the current SceneOptimizerOptions
  70116. */
  70117. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70118. /**
  70119. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70120. * @param targetFrameRate defines the target frame rate (60 by default)
  70121. * @returns a SceneOptimizerOptions object
  70122. */
  70123. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70124. /**
  70125. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70126. * @param targetFrameRate defines the target frame rate (60 by default)
  70127. * @returns a SceneOptimizerOptions object
  70128. */
  70129. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70130. /**
  70131. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70132. * @param targetFrameRate defines the target frame rate (60 by default)
  70133. * @returns a SceneOptimizerOptions object
  70134. */
  70135. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70136. }
  70137. /**
  70138. * Class used to run optimizations in order to reach a target frame rate
  70139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70140. */
  70141. export class SceneOptimizer implements IDisposable {
  70142. private _isRunning;
  70143. private _options;
  70144. private _scene;
  70145. private _currentPriorityLevel;
  70146. private _targetFrameRate;
  70147. private _trackerDuration;
  70148. private _currentFrameRate;
  70149. private _sceneDisposeObserver;
  70150. private _improvementMode;
  70151. /**
  70152. * Defines an observable called when the optimizer reaches the target frame rate
  70153. */
  70154. onSuccessObservable: Observable<SceneOptimizer>;
  70155. /**
  70156. * Defines an observable called when the optimizer enables an optimization
  70157. */
  70158. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70159. /**
  70160. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70161. */
  70162. onFailureObservable: Observable<SceneOptimizer>;
  70163. /**
  70164. * Gets a boolean indicating if the optimizer is in improvement mode
  70165. */
  70166. get isInImprovementMode(): boolean;
  70167. /**
  70168. * Gets the current priority level (0 at start)
  70169. */
  70170. get currentPriorityLevel(): number;
  70171. /**
  70172. * Gets the current frame rate checked by the SceneOptimizer
  70173. */
  70174. get currentFrameRate(): number;
  70175. /**
  70176. * Gets or sets the current target frame rate (60 by default)
  70177. */
  70178. get targetFrameRate(): number;
  70179. /**
  70180. * Gets or sets the current target frame rate (60 by default)
  70181. */
  70182. set targetFrameRate(value: number);
  70183. /**
  70184. * Gets or sets the current interval between two checks (every 2000ms by default)
  70185. */
  70186. get trackerDuration(): number;
  70187. /**
  70188. * Gets or sets the current interval between two checks (every 2000ms by default)
  70189. */
  70190. set trackerDuration(value: number);
  70191. /**
  70192. * Gets the list of active optimizations
  70193. */
  70194. get optimizations(): SceneOptimization[];
  70195. /**
  70196. * Creates a new SceneOptimizer
  70197. * @param scene defines the scene to work on
  70198. * @param options defines the options to use with the SceneOptimizer
  70199. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70200. * @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)
  70201. */
  70202. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70203. /**
  70204. * Stops the current optimizer
  70205. */
  70206. stop(): void;
  70207. /**
  70208. * Reset the optimizer to initial step (current priority level = 0)
  70209. */
  70210. reset(): void;
  70211. /**
  70212. * Start the optimizer. By default it will try to reach a specific framerate
  70213. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70214. */
  70215. start(): void;
  70216. private _checkCurrentState;
  70217. /**
  70218. * Release all resources
  70219. */
  70220. dispose(): void;
  70221. /**
  70222. * Helper function to create a SceneOptimizer with one single line of code
  70223. * @param scene defines the scene to work on
  70224. * @param options defines the options to use with the SceneOptimizer
  70225. * @param onSuccess defines a callback to call on success
  70226. * @param onFailure defines a callback to call on failure
  70227. * @returns the new SceneOptimizer object
  70228. */
  70229. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70230. }
  70231. }
  70232. declare module "babylonjs/Misc/sceneSerializer" {
  70233. import { Scene } from "babylonjs/scene";
  70234. /**
  70235. * Class used to serialize a scene into a string
  70236. */
  70237. export class SceneSerializer {
  70238. /**
  70239. * Clear cache used by a previous serialization
  70240. */
  70241. static ClearCache(): void;
  70242. /**
  70243. * Serialize a scene into a JSON compatible object
  70244. * @param scene defines the scene to serialize
  70245. * @returns a JSON compatible object
  70246. */
  70247. static Serialize(scene: Scene): any;
  70248. /**
  70249. * Serialize a mesh into a JSON compatible object
  70250. * @param toSerialize defines the mesh to serialize
  70251. * @param withParents defines if parents must be serialized as well
  70252. * @param withChildren defines if children must be serialized as well
  70253. * @returns a JSON compatible object
  70254. */
  70255. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70256. }
  70257. }
  70258. declare module "babylonjs/Misc/textureTools" {
  70259. import { Texture } from "babylonjs/Materials/Textures/texture";
  70260. /**
  70261. * Class used to host texture specific utilities
  70262. */
  70263. export class TextureTools {
  70264. /**
  70265. * Uses the GPU to create a copy texture rescaled at a given size
  70266. * @param texture Texture to copy from
  70267. * @param width defines the desired width
  70268. * @param height defines the desired height
  70269. * @param useBilinearMode defines if bilinear mode has to be used
  70270. * @return the generated texture
  70271. */
  70272. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70273. }
  70274. }
  70275. declare module "babylonjs/Misc/videoRecorder" {
  70276. import { Nullable } from "babylonjs/types";
  70277. import { Engine } from "babylonjs/Engines/engine";
  70278. /**
  70279. * This represents the different options available for the video capture.
  70280. */
  70281. export interface VideoRecorderOptions {
  70282. /** Defines the mime type of the video. */
  70283. mimeType: string;
  70284. /** Defines the FPS the video should be recorded at. */
  70285. fps: number;
  70286. /** Defines the chunk size for the recording data. */
  70287. recordChunckSize: number;
  70288. /** The audio tracks to attach to the recording. */
  70289. audioTracks?: MediaStreamTrack[];
  70290. }
  70291. /**
  70292. * This can help with recording videos from BabylonJS.
  70293. * This is based on the available WebRTC functionalities of the browser.
  70294. *
  70295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70296. */
  70297. export class VideoRecorder {
  70298. private static readonly _defaultOptions;
  70299. /**
  70300. * Returns whether or not the VideoRecorder is available in your browser.
  70301. * @param engine Defines the Babylon Engine.
  70302. * @returns true if supported otherwise false.
  70303. */
  70304. static IsSupported(engine: Engine): boolean;
  70305. private readonly _options;
  70306. private _canvas;
  70307. private _mediaRecorder;
  70308. private _recordedChunks;
  70309. private _fileName;
  70310. private _resolve;
  70311. private _reject;
  70312. /**
  70313. * True when a recording is already in progress.
  70314. */
  70315. get isRecording(): boolean;
  70316. /**
  70317. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70318. * @param engine Defines the BabylonJS Engine you wish to record.
  70319. * @param options Defines options that can be used to customize the capture.
  70320. */
  70321. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70322. /**
  70323. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70324. */
  70325. stopRecording(): void;
  70326. /**
  70327. * Starts recording the canvas for a max duration specified in parameters.
  70328. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70329. * If null no automatic download will start and you can rely on the promise to get the data back.
  70330. * @param maxDuration Defines the maximum recording time in seconds.
  70331. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70332. * @return A promise callback at the end of the recording with the video data in Blob.
  70333. */
  70334. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70335. /**
  70336. * Releases internal resources used during the recording.
  70337. */
  70338. dispose(): void;
  70339. private _handleDataAvailable;
  70340. private _handleError;
  70341. private _handleStop;
  70342. }
  70343. }
  70344. declare module "babylonjs/Misc/screenshotTools" {
  70345. import { Camera } from "babylonjs/Cameras/camera";
  70346. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70347. import { Engine } from "babylonjs/Engines/engine";
  70348. /**
  70349. * Class containing a set of static utilities functions for screenshots
  70350. */
  70351. export class ScreenshotTools {
  70352. /**
  70353. * Captures a screenshot of the current rendering
  70354. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70355. * @param engine defines the rendering engine
  70356. * @param camera defines the source camera
  70357. * @param size This parameter can be set to a single number or to an object with the
  70358. * following (optional) properties: precision, width, height. If a single number is passed,
  70359. * it will be used for both width and height. If an object is passed, the screenshot size
  70360. * will be derived from the parameters. The precision property is a multiplier allowing
  70361. * rendering at a higher or lower resolution
  70362. * @param successCallback defines the callback receives a single parameter which contains the
  70363. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70364. * src parameter of an <img> to display it
  70365. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70366. * Check your browser for supported MIME types
  70367. */
  70368. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70369. /**
  70370. * Captures a screenshot of the current rendering
  70371. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70372. * @param engine defines the rendering engine
  70373. * @param camera defines the source camera
  70374. * @param size This parameter can be set to a single number or to an object with the
  70375. * following (optional) properties: precision, width, height. If a single number is passed,
  70376. * it will be used for both width and height. If an object is passed, the screenshot size
  70377. * will be derived from the parameters. The precision property is a multiplier allowing
  70378. * rendering at a higher or lower resolution
  70379. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70380. * Check your browser for supported MIME types
  70381. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70382. * to the src parameter of an <img> to display it
  70383. */
  70384. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70385. /**
  70386. * Generates an image screenshot from the specified camera.
  70387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70388. * @param engine The engine to use for rendering
  70389. * @param camera The camera to use for rendering
  70390. * @param size This parameter can be set to a single number or to an object with the
  70391. * following (optional) properties: precision, width, height. If a single number is passed,
  70392. * it will be used for both width and height. If an object is passed, the screenshot size
  70393. * will be derived from the parameters. The precision property is a multiplier allowing
  70394. * rendering at a higher or lower resolution
  70395. * @param successCallback The callback receives a single parameter which contains the
  70396. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70397. * src parameter of an <img> to display it
  70398. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70399. * Check your browser for supported MIME types
  70400. * @param samples Texture samples (default: 1)
  70401. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70402. * @param fileName A name for for the downloaded file.
  70403. */
  70404. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70405. /**
  70406. * Generates an image screenshot from the specified camera.
  70407. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70408. * @param engine The engine to use for rendering
  70409. * @param camera The camera to use for rendering
  70410. * @param size This parameter can be set to a single number or to an object with the
  70411. * following (optional) properties: precision, width, height. If a single number is passed,
  70412. * it will be used for both width and height. If an object is passed, the screenshot size
  70413. * will be derived from the parameters. The precision property is a multiplier allowing
  70414. * rendering at a higher or lower resolution
  70415. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70416. * Check your browser for supported MIME types
  70417. * @param samples Texture samples (default: 1)
  70418. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70419. * @param fileName A name for for the downloaded file.
  70420. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70421. * to the src parameter of an <img> to display it
  70422. */
  70423. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70424. /**
  70425. * Gets height and width for screenshot size
  70426. * @private
  70427. */
  70428. private static _getScreenshotSize;
  70429. }
  70430. }
  70431. declare module "babylonjs/Misc/dataReader" {
  70432. /**
  70433. * Interface for a data buffer
  70434. */
  70435. export interface IDataBuffer {
  70436. /**
  70437. * Reads bytes from the data buffer.
  70438. * @param byteOffset The byte offset to read
  70439. * @param byteLength The byte length to read
  70440. * @returns A promise that resolves when the bytes are read
  70441. */
  70442. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70443. /**
  70444. * The byte length of the buffer.
  70445. */
  70446. readonly byteLength: number;
  70447. }
  70448. /**
  70449. * Utility class for reading from a data buffer
  70450. */
  70451. export class DataReader {
  70452. /**
  70453. * The data buffer associated with this data reader.
  70454. */
  70455. readonly buffer: IDataBuffer;
  70456. /**
  70457. * The current byte offset from the beginning of the data buffer.
  70458. */
  70459. byteOffset: number;
  70460. private _dataView;
  70461. private _dataByteOffset;
  70462. /**
  70463. * Constructor
  70464. * @param buffer The buffer to read
  70465. */
  70466. constructor(buffer: IDataBuffer);
  70467. /**
  70468. * Loads the given byte length.
  70469. * @param byteLength The byte length to load
  70470. * @returns A promise that resolves when the load is complete
  70471. */
  70472. loadAsync(byteLength: number): Promise<void>;
  70473. /**
  70474. * Read a unsigned 32-bit integer from the currently loaded data range.
  70475. * @returns The 32-bit integer read
  70476. */
  70477. readUint32(): number;
  70478. /**
  70479. * Read a byte array from the currently loaded data range.
  70480. * @param byteLength The byte length to read
  70481. * @returns The byte array read
  70482. */
  70483. readUint8Array(byteLength: number): Uint8Array;
  70484. /**
  70485. * Read a string from the currently loaded data range.
  70486. * @param byteLength The byte length to read
  70487. * @returns The string read
  70488. */
  70489. readString(byteLength: number): string;
  70490. /**
  70491. * Skips the given byte length the currently loaded data range.
  70492. * @param byteLength The byte length to skip
  70493. */
  70494. skipBytes(byteLength: number): void;
  70495. }
  70496. }
  70497. declare module "babylonjs/Misc/index" {
  70498. export * from "babylonjs/Misc/andOrNotEvaluator";
  70499. export * from "babylonjs/Misc/assetsManager";
  70500. export * from "babylonjs/Misc/basis";
  70501. export * from "babylonjs/Misc/dds";
  70502. export * from "babylonjs/Misc/decorators";
  70503. export * from "babylonjs/Misc/deferred";
  70504. export * from "babylonjs/Misc/environmentTextureTools";
  70505. export * from "babylonjs/Misc/meshExploder";
  70506. export * from "babylonjs/Misc/filesInput";
  70507. export * from "babylonjs/Misc/HighDynamicRange/index";
  70508. export * from "babylonjs/Misc/khronosTextureContainer";
  70509. export * from "babylonjs/Misc/observable";
  70510. export * from "babylonjs/Misc/performanceMonitor";
  70511. export * from "babylonjs/Misc/promise";
  70512. export * from "babylonjs/Misc/sceneOptimizer";
  70513. export * from "babylonjs/Misc/sceneSerializer";
  70514. export * from "babylonjs/Misc/smartArray";
  70515. export * from "babylonjs/Misc/stringDictionary";
  70516. export * from "babylonjs/Misc/tags";
  70517. export * from "babylonjs/Misc/textureTools";
  70518. export * from "babylonjs/Misc/tga";
  70519. export * from "babylonjs/Misc/tools";
  70520. export * from "babylonjs/Misc/videoRecorder";
  70521. export * from "babylonjs/Misc/virtualJoystick";
  70522. export * from "babylonjs/Misc/workerPool";
  70523. export * from "babylonjs/Misc/logger";
  70524. export * from "babylonjs/Misc/typeStore";
  70525. export * from "babylonjs/Misc/filesInputStore";
  70526. export * from "babylonjs/Misc/deepCopier";
  70527. export * from "babylonjs/Misc/pivotTools";
  70528. export * from "babylonjs/Misc/precisionDate";
  70529. export * from "babylonjs/Misc/screenshotTools";
  70530. export * from "babylonjs/Misc/typeStore";
  70531. export * from "babylonjs/Misc/webRequest";
  70532. export * from "babylonjs/Misc/iInspectable";
  70533. export * from "babylonjs/Misc/brdfTextureTools";
  70534. export * from "babylonjs/Misc/rgbdTextureTools";
  70535. export * from "babylonjs/Misc/gradients";
  70536. export * from "babylonjs/Misc/perfCounter";
  70537. export * from "babylonjs/Misc/fileRequest";
  70538. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70539. export * from "babylonjs/Misc/retryStrategy";
  70540. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70541. export * from "babylonjs/Misc/canvasGenerator";
  70542. export * from "babylonjs/Misc/fileTools";
  70543. export * from "babylonjs/Misc/stringTools";
  70544. export * from "babylonjs/Misc/dataReader";
  70545. }
  70546. declare module "babylonjs/index" {
  70547. export * from "babylonjs/abstractScene";
  70548. export * from "babylonjs/Actions/index";
  70549. export * from "babylonjs/Animations/index";
  70550. export * from "babylonjs/assetContainer";
  70551. export * from "babylonjs/Audio/index";
  70552. export * from "babylonjs/Behaviors/index";
  70553. export * from "babylonjs/Bones/index";
  70554. export * from "babylonjs/Cameras/index";
  70555. export * from "babylonjs/Collisions/index";
  70556. export * from "babylonjs/Culling/index";
  70557. export * from "babylonjs/Debug/index";
  70558. export * from "babylonjs/Engines/index";
  70559. export * from "babylonjs/Events/index";
  70560. export * from "babylonjs/Gamepads/index";
  70561. export * from "babylonjs/Gizmos/index";
  70562. export * from "babylonjs/Helpers/index";
  70563. export * from "babylonjs/Instrumentation/index";
  70564. export * from "babylonjs/Layers/index";
  70565. export * from "babylonjs/LensFlares/index";
  70566. export * from "babylonjs/Lights/index";
  70567. export * from "babylonjs/Loading/index";
  70568. export * from "babylonjs/Materials/index";
  70569. export * from "babylonjs/Maths/index";
  70570. export * from "babylonjs/Meshes/index";
  70571. export * from "babylonjs/Morph/index";
  70572. export * from "babylonjs/Navigation/index";
  70573. export * from "babylonjs/node";
  70574. export * from "babylonjs/Offline/index";
  70575. export * from "babylonjs/Particles/index";
  70576. export * from "babylonjs/Physics/index";
  70577. export * from "babylonjs/PostProcesses/index";
  70578. export * from "babylonjs/Probes/index";
  70579. export * from "babylonjs/Rendering/index";
  70580. export * from "babylonjs/scene";
  70581. export * from "babylonjs/sceneComponent";
  70582. export * from "babylonjs/Sprites/index";
  70583. export * from "babylonjs/States/index";
  70584. export * from "babylonjs/Misc/index";
  70585. export * from "babylonjs/types";
  70586. }
  70587. declare module "babylonjs/Animations/pathCursor" {
  70588. import { Vector3 } from "babylonjs/Maths/math.vector";
  70589. import { Path2 } from "babylonjs/Maths/math.path";
  70590. /**
  70591. * A cursor which tracks a point on a path
  70592. */
  70593. export class PathCursor {
  70594. private path;
  70595. /**
  70596. * Stores path cursor callbacks for when an onchange event is triggered
  70597. */
  70598. private _onchange;
  70599. /**
  70600. * The value of the path cursor
  70601. */
  70602. value: number;
  70603. /**
  70604. * The animation array of the path cursor
  70605. */
  70606. animations: Animation[];
  70607. /**
  70608. * Initializes the path cursor
  70609. * @param path The path to track
  70610. */
  70611. constructor(path: Path2);
  70612. /**
  70613. * Gets the cursor point on the path
  70614. * @returns A point on the path cursor at the cursor location
  70615. */
  70616. getPoint(): Vector3;
  70617. /**
  70618. * Moves the cursor ahead by the step amount
  70619. * @param step The amount to move the cursor forward
  70620. * @returns This path cursor
  70621. */
  70622. moveAhead(step?: number): PathCursor;
  70623. /**
  70624. * Moves the cursor behind by the step amount
  70625. * @param step The amount to move the cursor back
  70626. * @returns This path cursor
  70627. */
  70628. moveBack(step?: number): PathCursor;
  70629. /**
  70630. * Moves the cursor by the step amount
  70631. * If the step amount is greater than one, an exception is thrown
  70632. * @param step The amount to move the cursor
  70633. * @returns This path cursor
  70634. */
  70635. move(step: number): PathCursor;
  70636. /**
  70637. * Ensures that the value is limited between zero and one
  70638. * @returns This path cursor
  70639. */
  70640. private ensureLimits;
  70641. /**
  70642. * Runs onchange callbacks on change (used by the animation engine)
  70643. * @returns This path cursor
  70644. */
  70645. private raiseOnChange;
  70646. /**
  70647. * Executes a function on change
  70648. * @param f A path cursor onchange callback
  70649. * @returns This path cursor
  70650. */
  70651. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70652. }
  70653. }
  70654. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70655. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70656. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70657. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70658. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70659. }
  70660. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70661. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70662. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70663. }
  70664. declare module "babylonjs/Engines/Processors/index" {
  70665. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70666. export * from "babylonjs/Engines/Processors/Expressions/index";
  70667. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70668. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70669. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70670. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70671. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70672. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70673. }
  70674. declare module "babylonjs/Legacy/legacy" {
  70675. import * as Babylon from "babylonjs/index";
  70676. export * from "babylonjs/index";
  70677. }
  70678. declare module "babylonjs/Shaders/blur.fragment" {
  70679. /** @hidden */
  70680. export var blurPixelShader: {
  70681. name: string;
  70682. shader: string;
  70683. };
  70684. }
  70685. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70686. /** @hidden */
  70687. export var pointCloudVertexDeclaration: {
  70688. name: string;
  70689. shader: string;
  70690. };
  70691. }
  70692. declare module "babylonjs" {
  70693. export * from "babylonjs/Legacy/legacy";
  70694. }
  70695. declare module BABYLON {
  70696. /** Alias type for value that can be null */
  70697. export type Nullable<T> = T | null;
  70698. /**
  70699. * Alias type for number that are floats
  70700. * @ignorenaming
  70701. */
  70702. export type float = number;
  70703. /**
  70704. * Alias type for number that are doubles.
  70705. * @ignorenaming
  70706. */
  70707. export type double = number;
  70708. /**
  70709. * Alias type for number that are integer
  70710. * @ignorenaming
  70711. */
  70712. export type int = number;
  70713. /** Alias type for number array or Float32Array */
  70714. export type FloatArray = number[] | Float32Array;
  70715. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70716. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70717. /**
  70718. * Alias for types that can be used by a Buffer or VertexBuffer.
  70719. */
  70720. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70721. /**
  70722. * Alias type for primitive types
  70723. * @ignorenaming
  70724. */
  70725. type Primitive = undefined | null | boolean | string | number | Function;
  70726. /**
  70727. * Type modifier to make all the properties of an object Readonly
  70728. */
  70729. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70730. /**
  70731. * Type modifier to make all the properties of an object Readonly recursively
  70732. */
  70733. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70734. /**
  70735. * Type modifier to make object properties readonly.
  70736. */
  70737. export type DeepImmutableObject<T> = {
  70738. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70739. };
  70740. /** @hidden */
  70741. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70742. }
  70743. }
  70744. declare module BABYLON {
  70745. /**
  70746. * A class serves as a medium between the observable and its observers
  70747. */
  70748. export class EventState {
  70749. /**
  70750. * Create a new EventState
  70751. * @param mask defines the mask associated with this state
  70752. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70753. * @param target defines the original target of the state
  70754. * @param currentTarget defines the current target of the state
  70755. */
  70756. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70757. /**
  70758. * Initialize the current event state
  70759. * @param mask defines the mask associated with this state
  70760. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70761. * @param target defines the original target of the state
  70762. * @param currentTarget defines the current target of the state
  70763. * @returns the current event state
  70764. */
  70765. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70766. /**
  70767. * An Observer can set this property to true to prevent subsequent observers of being notified
  70768. */
  70769. skipNextObservers: boolean;
  70770. /**
  70771. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70772. */
  70773. mask: number;
  70774. /**
  70775. * The object that originally notified the event
  70776. */
  70777. target?: any;
  70778. /**
  70779. * The current object in the bubbling phase
  70780. */
  70781. currentTarget?: any;
  70782. /**
  70783. * This will be populated with the return value of the last function that was executed.
  70784. * If it is the first function in the callback chain it will be the event data.
  70785. */
  70786. lastReturnValue?: any;
  70787. }
  70788. /**
  70789. * Represent an Observer registered to a given Observable object.
  70790. */
  70791. export class Observer<T> {
  70792. /**
  70793. * Defines the callback to call when the observer is notified
  70794. */
  70795. callback: (eventData: T, eventState: EventState) => void;
  70796. /**
  70797. * Defines the mask of the observer (used to filter notifications)
  70798. */
  70799. mask: number;
  70800. /**
  70801. * Defines the current scope used to restore the JS context
  70802. */
  70803. scope: any;
  70804. /** @hidden */
  70805. _willBeUnregistered: boolean;
  70806. /**
  70807. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70808. */
  70809. unregisterOnNextCall: boolean;
  70810. /**
  70811. * Creates a new observer
  70812. * @param callback defines the callback to call when the observer is notified
  70813. * @param mask defines the mask of the observer (used to filter notifications)
  70814. * @param scope defines the current scope used to restore the JS context
  70815. */
  70816. constructor(
  70817. /**
  70818. * Defines the callback to call when the observer is notified
  70819. */
  70820. callback: (eventData: T, eventState: EventState) => void,
  70821. /**
  70822. * Defines the mask of the observer (used to filter notifications)
  70823. */
  70824. mask: number,
  70825. /**
  70826. * Defines the current scope used to restore the JS context
  70827. */
  70828. scope?: any);
  70829. }
  70830. /**
  70831. * Represent a list of observers registered to multiple Observables object.
  70832. */
  70833. export class MultiObserver<T> {
  70834. private _observers;
  70835. private _observables;
  70836. /**
  70837. * Release associated resources
  70838. */
  70839. dispose(): void;
  70840. /**
  70841. * Raise a callback when one of the observable will notify
  70842. * @param observables defines a list of observables to watch
  70843. * @param callback defines the callback to call on notification
  70844. * @param mask defines the mask used to filter notifications
  70845. * @param scope defines the current scope used to restore the JS context
  70846. * @returns the new MultiObserver
  70847. */
  70848. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70849. }
  70850. /**
  70851. * The Observable class is a simple implementation of the Observable pattern.
  70852. *
  70853. * 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.
  70854. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70855. * 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).
  70856. * 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.
  70857. */
  70858. export class Observable<T> {
  70859. private _observers;
  70860. private _eventState;
  70861. private _onObserverAdded;
  70862. /**
  70863. * Gets the list of observers
  70864. */
  70865. get observers(): Array<Observer<T>>;
  70866. /**
  70867. * Creates a new observable
  70868. * @param onObserverAdded defines a callback to call when a new observer is added
  70869. */
  70870. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70871. /**
  70872. * Create a new Observer with the specified callback
  70873. * @param callback the callback that will be executed for that Observer
  70874. * @param mask the mask used to filter observers
  70875. * @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.
  70876. * @param scope optional scope for the callback to be called from
  70877. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70878. * @returns the new observer created for the callback
  70879. */
  70880. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70881. /**
  70882. * Create a new Observer with the specified callback and unregisters after the next notification
  70883. * @param callback the callback that will be executed for that Observer
  70884. * @returns the new observer created for the callback
  70885. */
  70886. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70887. /**
  70888. * Remove an Observer from the Observable object
  70889. * @param observer the instance of the Observer to remove
  70890. * @returns false if it doesn't belong to this Observable
  70891. */
  70892. remove(observer: Nullable<Observer<T>>): boolean;
  70893. /**
  70894. * Remove a callback from the Observable object
  70895. * @param callback the callback to remove
  70896. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70897. * @returns false if it doesn't belong to this Observable
  70898. */
  70899. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70900. private _deferUnregister;
  70901. private _remove;
  70902. /**
  70903. * Moves the observable to the top of the observer list making it get called first when notified
  70904. * @param observer the observer to move
  70905. */
  70906. makeObserverTopPriority(observer: Observer<T>): void;
  70907. /**
  70908. * Moves the observable to the bottom of the observer list making it get called last when notified
  70909. * @param observer the observer to move
  70910. */
  70911. makeObserverBottomPriority(observer: Observer<T>): void;
  70912. /**
  70913. * Notify all Observers by calling their respective callback with the given data
  70914. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70915. * @param eventData defines the data to send to all observers
  70916. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70917. * @param target defines the original target of the state
  70918. * @param currentTarget defines the current target of the state
  70919. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70920. */
  70921. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70922. /**
  70923. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70924. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70925. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70926. * and it is crucial that all callbacks will be executed.
  70927. * The order of the callbacks is kept, callbacks are not executed parallel.
  70928. *
  70929. * @param eventData The data to be sent to each callback
  70930. * @param mask is used to filter observers defaults to -1
  70931. * @param target defines the callback target (see EventState)
  70932. * @param currentTarget defines he current object in the bubbling phase
  70933. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70934. */
  70935. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70936. /**
  70937. * Notify a specific observer
  70938. * @param observer defines the observer to notify
  70939. * @param eventData defines the data to be sent to each callback
  70940. * @param mask is used to filter observers defaults to -1
  70941. */
  70942. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70943. /**
  70944. * Gets a boolean indicating if the observable has at least one observer
  70945. * @returns true is the Observable has at least one Observer registered
  70946. */
  70947. hasObservers(): boolean;
  70948. /**
  70949. * Clear the list of observers
  70950. */
  70951. clear(): void;
  70952. /**
  70953. * Clone the current observable
  70954. * @returns a new observable
  70955. */
  70956. clone(): Observable<T>;
  70957. /**
  70958. * Does this observable handles observer registered with a given mask
  70959. * @param mask defines the mask to be tested
  70960. * @return whether or not one observer registered with the given mask is handeled
  70961. **/
  70962. hasSpecificMask(mask?: number): boolean;
  70963. }
  70964. }
  70965. declare module BABYLON {
  70966. /**
  70967. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70968. * Babylon.js
  70969. */
  70970. export class DomManagement {
  70971. /**
  70972. * Checks if the window object exists
  70973. * @returns true if the window object exists
  70974. */
  70975. static IsWindowObjectExist(): boolean;
  70976. /**
  70977. * Checks if the navigator object exists
  70978. * @returns true if the navigator object exists
  70979. */
  70980. static IsNavigatorAvailable(): boolean;
  70981. /**
  70982. * Extracts text content from a DOM element hierarchy
  70983. * @param element defines the root element
  70984. * @returns a string
  70985. */
  70986. static GetDOMTextContent(element: HTMLElement): string;
  70987. }
  70988. }
  70989. declare module BABYLON {
  70990. /**
  70991. * Logger used througouht the application to allow configuration of
  70992. * the log level required for the messages.
  70993. */
  70994. export class Logger {
  70995. /**
  70996. * No log
  70997. */
  70998. static readonly NoneLogLevel: number;
  70999. /**
  71000. * Only message logs
  71001. */
  71002. static readonly MessageLogLevel: number;
  71003. /**
  71004. * Only warning logs
  71005. */
  71006. static readonly WarningLogLevel: number;
  71007. /**
  71008. * Only error logs
  71009. */
  71010. static readonly ErrorLogLevel: number;
  71011. /**
  71012. * All logs
  71013. */
  71014. static readonly AllLogLevel: number;
  71015. private static _LogCache;
  71016. /**
  71017. * Gets a value indicating the number of loading errors
  71018. * @ignorenaming
  71019. */
  71020. static errorsCount: number;
  71021. /**
  71022. * Callback called when a new log is added
  71023. */
  71024. static OnNewCacheEntry: (entry: string) => void;
  71025. private static _AddLogEntry;
  71026. private static _FormatMessage;
  71027. private static _LogDisabled;
  71028. private static _LogEnabled;
  71029. private static _WarnDisabled;
  71030. private static _WarnEnabled;
  71031. private static _ErrorDisabled;
  71032. private static _ErrorEnabled;
  71033. /**
  71034. * Log a message to the console
  71035. */
  71036. static Log: (message: string) => void;
  71037. /**
  71038. * Write a warning message to the console
  71039. */
  71040. static Warn: (message: string) => void;
  71041. /**
  71042. * Write an error message to the console
  71043. */
  71044. static Error: (message: string) => void;
  71045. /**
  71046. * Gets current log cache (list of logs)
  71047. */
  71048. static get LogCache(): string;
  71049. /**
  71050. * Clears the log cache
  71051. */
  71052. static ClearLogCache(): void;
  71053. /**
  71054. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71055. */
  71056. static set LogLevels(level: number);
  71057. }
  71058. }
  71059. declare module BABYLON {
  71060. /** @hidden */
  71061. export class _TypeStore {
  71062. /** @hidden */
  71063. static RegisteredTypes: {
  71064. [key: string]: Object;
  71065. };
  71066. /** @hidden */
  71067. static GetClass(fqdn: string): any;
  71068. }
  71069. }
  71070. declare module BABYLON {
  71071. /**
  71072. * Helper to manipulate strings
  71073. */
  71074. export class StringTools {
  71075. /**
  71076. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71077. * @param str Source string
  71078. * @param suffix Suffix to search for in the source string
  71079. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71080. */
  71081. static EndsWith(str: string, suffix: string): boolean;
  71082. /**
  71083. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71084. * @param str Source string
  71085. * @param suffix Suffix to search for in the source string
  71086. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71087. */
  71088. static StartsWith(str: string, suffix: string): boolean;
  71089. /**
  71090. * Decodes a buffer into a string
  71091. * @param buffer The buffer to decode
  71092. * @returns The decoded string
  71093. */
  71094. static Decode(buffer: Uint8Array | Uint16Array): string;
  71095. /**
  71096. * Encode a buffer to a base64 string
  71097. * @param buffer defines the buffer to encode
  71098. * @returns the encoded string
  71099. */
  71100. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71101. }
  71102. }
  71103. declare module BABYLON {
  71104. /**
  71105. * Class containing a set of static utilities functions for deep copy.
  71106. */
  71107. export class DeepCopier {
  71108. /**
  71109. * Tries to copy an object by duplicating every property
  71110. * @param source defines the source object
  71111. * @param destination defines the target object
  71112. * @param doNotCopyList defines a list of properties to avoid
  71113. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71114. */
  71115. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71116. }
  71117. }
  71118. declare module BABYLON {
  71119. /**
  71120. * Class containing a set of static utilities functions for precision date
  71121. */
  71122. export class PrecisionDate {
  71123. /**
  71124. * Gets either window.performance.now() if supported or Date.now() else
  71125. */
  71126. static get Now(): number;
  71127. }
  71128. }
  71129. declare module BABYLON {
  71130. /** @hidden */
  71131. export class _DevTools {
  71132. static WarnImport(name: string): string;
  71133. }
  71134. }
  71135. declare module BABYLON {
  71136. /**
  71137. * Interface used to define the mechanism to get data from the network
  71138. */
  71139. export interface IWebRequest {
  71140. /**
  71141. * Returns client's response url
  71142. */
  71143. responseURL: string;
  71144. /**
  71145. * Returns client's status
  71146. */
  71147. status: number;
  71148. /**
  71149. * Returns client's status as a text
  71150. */
  71151. statusText: string;
  71152. }
  71153. }
  71154. declare module BABYLON {
  71155. /**
  71156. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71157. */
  71158. export class WebRequest implements IWebRequest {
  71159. private _xhr;
  71160. /**
  71161. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71162. * i.e. when loading files, where the server/service expects an Authorization header
  71163. */
  71164. static CustomRequestHeaders: {
  71165. [key: string]: string;
  71166. };
  71167. /**
  71168. * Add callback functions in this array to update all the requests before they get sent to the network
  71169. */
  71170. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71171. private _injectCustomRequestHeaders;
  71172. /**
  71173. * Gets or sets a function to be called when loading progress changes
  71174. */
  71175. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71176. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71177. /**
  71178. * Returns client's state
  71179. */
  71180. get readyState(): number;
  71181. /**
  71182. * Returns client's status
  71183. */
  71184. get status(): number;
  71185. /**
  71186. * Returns client's status as a text
  71187. */
  71188. get statusText(): string;
  71189. /**
  71190. * Returns client's response
  71191. */
  71192. get response(): any;
  71193. /**
  71194. * Returns client's response url
  71195. */
  71196. get responseURL(): string;
  71197. /**
  71198. * Returns client's response as text
  71199. */
  71200. get responseText(): string;
  71201. /**
  71202. * Gets or sets the expected response type
  71203. */
  71204. get responseType(): XMLHttpRequestResponseType;
  71205. set responseType(value: XMLHttpRequestResponseType);
  71206. /** @hidden */
  71207. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71208. /** @hidden */
  71209. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71210. /**
  71211. * Cancels any network activity
  71212. */
  71213. abort(): void;
  71214. /**
  71215. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71216. * @param body defines an optional request body
  71217. */
  71218. send(body?: Document | BodyInit | null): void;
  71219. /**
  71220. * Sets the request method, request URL
  71221. * @param method defines the method to use (GET, POST, etc..)
  71222. * @param url defines the url to connect with
  71223. */
  71224. open(method: string, url: string): void;
  71225. /**
  71226. * Sets the value of a request header.
  71227. * @param name The name of the header whose value is to be set
  71228. * @param value The value to set as the body of the header
  71229. */
  71230. setRequestHeader(name: string, value: string): void;
  71231. /**
  71232. * Get the string containing the text of a particular header's value.
  71233. * @param name The name of the header
  71234. * @returns The string containing the text of the given header name
  71235. */
  71236. getResponseHeader(name: string): Nullable<string>;
  71237. }
  71238. }
  71239. declare module BABYLON {
  71240. /**
  71241. * File request interface
  71242. */
  71243. export interface IFileRequest {
  71244. /**
  71245. * Raised when the request is complete (success or error).
  71246. */
  71247. onCompleteObservable: Observable<IFileRequest>;
  71248. /**
  71249. * Aborts the request for a file.
  71250. */
  71251. abort: () => void;
  71252. }
  71253. }
  71254. declare module BABYLON {
  71255. /**
  71256. * Define options used to create a render target texture
  71257. */
  71258. export class RenderTargetCreationOptions {
  71259. /**
  71260. * Specifies is mipmaps must be generated
  71261. */
  71262. generateMipMaps?: boolean;
  71263. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71264. generateDepthBuffer?: boolean;
  71265. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71266. generateStencilBuffer?: boolean;
  71267. /** Defines texture type (int by default) */
  71268. type?: number;
  71269. /** Defines sampling mode (trilinear by default) */
  71270. samplingMode?: number;
  71271. /** Defines format (RGBA by default) */
  71272. format?: number;
  71273. }
  71274. }
  71275. declare module BABYLON {
  71276. /**
  71277. * @hidden
  71278. **/
  71279. export class _TimeToken {
  71280. _startTimeQuery: Nullable<WebGLQuery>;
  71281. _endTimeQuery: Nullable<WebGLQuery>;
  71282. _timeElapsedQuery: Nullable<WebGLQuery>;
  71283. _timeElapsedQueryEnded: boolean;
  71284. }
  71285. }
  71286. declare module BABYLON {
  71287. /** Defines the cross module used constants to avoid circular dependncies */
  71288. export class Constants {
  71289. /** Defines that alpha blending is disabled */
  71290. static readonly ALPHA_DISABLE: number;
  71291. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71292. static readonly ALPHA_ADD: number;
  71293. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71294. static readonly ALPHA_COMBINE: number;
  71295. /** Defines that alpha blending is DEST - SRC * DEST */
  71296. static readonly ALPHA_SUBTRACT: number;
  71297. /** Defines that alpha blending is SRC * DEST */
  71298. static readonly ALPHA_MULTIPLY: number;
  71299. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71300. static readonly ALPHA_MAXIMIZED: number;
  71301. /** Defines that alpha blending is SRC + DEST */
  71302. static readonly ALPHA_ONEONE: number;
  71303. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71304. static readonly ALPHA_PREMULTIPLIED: number;
  71305. /**
  71306. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71307. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71308. */
  71309. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71310. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71311. static readonly ALPHA_INTERPOLATE: number;
  71312. /**
  71313. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71314. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71315. */
  71316. static readonly ALPHA_SCREENMODE: number;
  71317. /**
  71318. * Defines that alpha blending is SRC + DST
  71319. * Alpha will be set to SRC ALPHA + DST ALPHA
  71320. */
  71321. static readonly ALPHA_ONEONE_ONEONE: number;
  71322. /**
  71323. * Defines that alpha blending is SRC * DST ALPHA + DST
  71324. * Alpha will be set to 0
  71325. */
  71326. static readonly ALPHA_ALPHATOCOLOR: number;
  71327. /**
  71328. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71329. */
  71330. static readonly ALPHA_REVERSEONEMINUS: number;
  71331. /**
  71332. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71333. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71334. */
  71335. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71336. /**
  71337. * Defines that alpha blending is SRC + DST
  71338. * Alpha will be set to SRC ALPHA
  71339. */
  71340. static readonly ALPHA_ONEONE_ONEZERO: number;
  71341. /**
  71342. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71343. * Alpha will be set to DST ALPHA
  71344. */
  71345. static readonly ALPHA_EXCLUSION: number;
  71346. /** Defines that alpha blending equation a SUM */
  71347. static readonly ALPHA_EQUATION_ADD: number;
  71348. /** Defines that alpha blending equation a SUBSTRACTION */
  71349. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71350. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71351. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71352. /** Defines that alpha blending equation a MAX operation */
  71353. static readonly ALPHA_EQUATION_MAX: number;
  71354. /** Defines that alpha blending equation a MIN operation */
  71355. static readonly ALPHA_EQUATION_MIN: number;
  71356. /**
  71357. * Defines that alpha blending equation a DARKEN operation:
  71358. * It takes the min of the src and sums the alpha channels.
  71359. */
  71360. static readonly ALPHA_EQUATION_DARKEN: number;
  71361. /** Defines that the ressource is not delayed*/
  71362. static readonly DELAYLOADSTATE_NONE: number;
  71363. /** Defines that the ressource was successfully delay loaded */
  71364. static readonly DELAYLOADSTATE_LOADED: number;
  71365. /** Defines that the ressource is currently delay loading */
  71366. static readonly DELAYLOADSTATE_LOADING: number;
  71367. /** Defines that the ressource is delayed and has not started loading */
  71368. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71370. static readonly NEVER: number;
  71371. /** 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 */
  71372. static readonly ALWAYS: number;
  71373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71374. static readonly LESS: number;
  71375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71376. static readonly EQUAL: number;
  71377. /** 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 */
  71378. static readonly LEQUAL: number;
  71379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71380. static readonly GREATER: number;
  71381. /** 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 */
  71382. static readonly GEQUAL: number;
  71383. /** 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 */
  71384. static readonly NOTEQUAL: number;
  71385. /** Passed to stencilOperation to specify that stencil value must be kept */
  71386. static readonly KEEP: number;
  71387. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71388. static readonly REPLACE: number;
  71389. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71390. static readonly INCR: number;
  71391. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71392. static readonly DECR: number;
  71393. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71394. static readonly INVERT: number;
  71395. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71396. static readonly INCR_WRAP: number;
  71397. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71398. static readonly DECR_WRAP: number;
  71399. /** Texture is not repeating outside of 0..1 UVs */
  71400. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71401. /** Texture is repeating outside of 0..1 UVs */
  71402. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71403. /** Texture is repeating and mirrored */
  71404. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71405. /** ALPHA */
  71406. static readonly TEXTUREFORMAT_ALPHA: number;
  71407. /** LUMINANCE */
  71408. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71409. /** LUMINANCE_ALPHA */
  71410. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71411. /** RGB */
  71412. static readonly TEXTUREFORMAT_RGB: number;
  71413. /** RGBA */
  71414. static readonly TEXTUREFORMAT_RGBA: number;
  71415. /** RED */
  71416. static readonly TEXTUREFORMAT_RED: number;
  71417. /** RED (2nd reference) */
  71418. static readonly TEXTUREFORMAT_R: number;
  71419. /** RG */
  71420. static readonly TEXTUREFORMAT_RG: number;
  71421. /** RED_INTEGER */
  71422. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71423. /** RED_INTEGER (2nd reference) */
  71424. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71425. /** RG_INTEGER */
  71426. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71427. /** RGB_INTEGER */
  71428. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71429. /** RGBA_INTEGER */
  71430. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71431. /** UNSIGNED_BYTE */
  71432. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71433. /** UNSIGNED_BYTE (2nd reference) */
  71434. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71435. /** FLOAT */
  71436. static readonly TEXTURETYPE_FLOAT: number;
  71437. /** HALF_FLOAT */
  71438. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71439. /** BYTE */
  71440. static readonly TEXTURETYPE_BYTE: number;
  71441. /** SHORT */
  71442. static readonly TEXTURETYPE_SHORT: number;
  71443. /** UNSIGNED_SHORT */
  71444. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71445. /** INT */
  71446. static readonly TEXTURETYPE_INT: number;
  71447. /** UNSIGNED_INT */
  71448. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71449. /** UNSIGNED_SHORT_4_4_4_4 */
  71450. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71451. /** UNSIGNED_SHORT_5_5_5_1 */
  71452. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71453. /** UNSIGNED_SHORT_5_6_5 */
  71454. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71455. /** UNSIGNED_INT_2_10_10_10_REV */
  71456. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71457. /** UNSIGNED_INT_24_8 */
  71458. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71459. /** UNSIGNED_INT_10F_11F_11F_REV */
  71460. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71461. /** UNSIGNED_INT_5_9_9_9_REV */
  71462. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71463. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71464. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71465. /** nearest is mag = nearest and min = nearest and no mip */
  71466. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71467. /** mag = nearest and min = nearest and mip = none */
  71468. static readonly TEXTURE_NEAREST_NEAREST: number;
  71469. /** Bilinear is mag = linear and min = linear and no mip */
  71470. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71471. /** mag = linear and min = linear and mip = none */
  71472. static readonly TEXTURE_LINEAR_LINEAR: number;
  71473. /** Trilinear is mag = linear and min = linear and mip = linear */
  71474. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71475. /** Trilinear is mag = linear and min = linear and mip = linear */
  71476. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71477. /** mag = nearest and min = nearest and mip = nearest */
  71478. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71479. /** mag = nearest and min = linear and mip = nearest */
  71480. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71481. /** mag = nearest and min = linear and mip = linear */
  71482. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71483. /** mag = nearest and min = linear and mip = none */
  71484. static readonly TEXTURE_NEAREST_LINEAR: number;
  71485. /** nearest is mag = nearest and min = nearest and mip = linear */
  71486. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71487. /** mag = linear and min = nearest and mip = nearest */
  71488. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71489. /** mag = linear and min = nearest and mip = linear */
  71490. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71492. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71493. /** mag = linear and min = nearest and mip = none */
  71494. static readonly TEXTURE_LINEAR_NEAREST: number;
  71495. /** Explicit coordinates mode */
  71496. static readonly TEXTURE_EXPLICIT_MODE: number;
  71497. /** Spherical coordinates mode */
  71498. static readonly TEXTURE_SPHERICAL_MODE: number;
  71499. /** Planar coordinates mode */
  71500. static readonly TEXTURE_PLANAR_MODE: number;
  71501. /** Cubic coordinates mode */
  71502. static readonly TEXTURE_CUBIC_MODE: number;
  71503. /** Projection coordinates mode */
  71504. static readonly TEXTURE_PROJECTION_MODE: number;
  71505. /** Skybox coordinates mode */
  71506. static readonly TEXTURE_SKYBOX_MODE: number;
  71507. /** Inverse Cubic coordinates mode */
  71508. static readonly TEXTURE_INVCUBIC_MODE: number;
  71509. /** Equirectangular coordinates mode */
  71510. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71511. /** Equirectangular Fixed coordinates mode */
  71512. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71513. /** Equirectangular Fixed Mirrored coordinates mode */
  71514. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71515. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71516. static readonly SCALEMODE_FLOOR: number;
  71517. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71518. static readonly SCALEMODE_NEAREST: number;
  71519. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71520. static readonly SCALEMODE_CEILING: number;
  71521. /**
  71522. * The dirty texture flag value
  71523. */
  71524. static readonly MATERIAL_TextureDirtyFlag: number;
  71525. /**
  71526. * The dirty light flag value
  71527. */
  71528. static readonly MATERIAL_LightDirtyFlag: number;
  71529. /**
  71530. * The dirty fresnel flag value
  71531. */
  71532. static readonly MATERIAL_FresnelDirtyFlag: number;
  71533. /**
  71534. * The dirty attribute flag value
  71535. */
  71536. static readonly MATERIAL_AttributesDirtyFlag: number;
  71537. /**
  71538. * The dirty misc flag value
  71539. */
  71540. static readonly MATERIAL_MiscDirtyFlag: number;
  71541. /**
  71542. * The all dirty flag value
  71543. */
  71544. static readonly MATERIAL_AllDirtyFlag: number;
  71545. /**
  71546. * Returns the triangle fill mode
  71547. */
  71548. static readonly MATERIAL_TriangleFillMode: number;
  71549. /**
  71550. * Returns the wireframe mode
  71551. */
  71552. static readonly MATERIAL_WireFrameFillMode: number;
  71553. /**
  71554. * Returns the point fill mode
  71555. */
  71556. static readonly MATERIAL_PointFillMode: number;
  71557. /**
  71558. * Returns the point list draw mode
  71559. */
  71560. static readonly MATERIAL_PointListDrawMode: number;
  71561. /**
  71562. * Returns the line list draw mode
  71563. */
  71564. static readonly MATERIAL_LineListDrawMode: number;
  71565. /**
  71566. * Returns the line loop draw mode
  71567. */
  71568. static readonly MATERIAL_LineLoopDrawMode: number;
  71569. /**
  71570. * Returns the line strip draw mode
  71571. */
  71572. static readonly MATERIAL_LineStripDrawMode: number;
  71573. /**
  71574. * Returns the triangle strip draw mode
  71575. */
  71576. static readonly MATERIAL_TriangleStripDrawMode: number;
  71577. /**
  71578. * Returns the triangle fan draw mode
  71579. */
  71580. static readonly MATERIAL_TriangleFanDrawMode: number;
  71581. /**
  71582. * Stores the clock-wise side orientation
  71583. */
  71584. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71585. /**
  71586. * Stores the counter clock-wise side orientation
  71587. */
  71588. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71589. /**
  71590. * Nothing
  71591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71592. */
  71593. static readonly ACTION_NothingTrigger: number;
  71594. /**
  71595. * On pick
  71596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71597. */
  71598. static readonly ACTION_OnPickTrigger: number;
  71599. /**
  71600. * On left pick
  71601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71602. */
  71603. static readonly ACTION_OnLeftPickTrigger: number;
  71604. /**
  71605. * On right pick
  71606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71607. */
  71608. static readonly ACTION_OnRightPickTrigger: number;
  71609. /**
  71610. * On center pick
  71611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71612. */
  71613. static readonly ACTION_OnCenterPickTrigger: number;
  71614. /**
  71615. * On pick down
  71616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71617. */
  71618. static readonly ACTION_OnPickDownTrigger: number;
  71619. /**
  71620. * On double pick
  71621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71622. */
  71623. static readonly ACTION_OnDoublePickTrigger: number;
  71624. /**
  71625. * On pick up
  71626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71627. */
  71628. static readonly ACTION_OnPickUpTrigger: number;
  71629. /**
  71630. * On pick out.
  71631. * This trigger will only be raised if you also declared a OnPickDown
  71632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71633. */
  71634. static readonly ACTION_OnPickOutTrigger: number;
  71635. /**
  71636. * On long press
  71637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71638. */
  71639. static readonly ACTION_OnLongPressTrigger: number;
  71640. /**
  71641. * On pointer over
  71642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71643. */
  71644. static readonly ACTION_OnPointerOverTrigger: number;
  71645. /**
  71646. * On pointer out
  71647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71648. */
  71649. static readonly ACTION_OnPointerOutTrigger: number;
  71650. /**
  71651. * On every frame
  71652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71653. */
  71654. static readonly ACTION_OnEveryFrameTrigger: number;
  71655. /**
  71656. * On intersection enter
  71657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71658. */
  71659. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71660. /**
  71661. * On intersection exit
  71662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71663. */
  71664. static readonly ACTION_OnIntersectionExitTrigger: number;
  71665. /**
  71666. * On key down
  71667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71668. */
  71669. static readonly ACTION_OnKeyDownTrigger: number;
  71670. /**
  71671. * On key up
  71672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71673. */
  71674. static readonly ACTION_OnKeyUpTrigger: number;
  71675. /**
  71676. * Billboard mode will only apply to Y axis
  71677. */
  71678. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71679. /**
  71680. * Billboard mode will apply to all axes
  71681. */
  71682. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71683. /**
  71684. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71685. */
  71686. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71687. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71688. * Test order :
  71689. * Is the bounding sphere outside the frustum ?
  71690. * If not, are the bounding box vertices outside the frustum ?
  71691. * It not, then the cullable object is in the frustum.
  71692. */
  71693. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71694. /** Culling strategy : Bounding Sphere Only.
  71695. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71696. * It's also less accurate than the standard because some not visible objects can still be selected.
  71697. * Test : is the bounding sphere outside the frustum ?
  71698. * If not, then the cullable object is in the frustum.
  71699. */
  71700. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71701. /** Culling strategy : Optimistic Inclusion.
  71702. * This in an inclusion test first, then the standard exclusion test.
  71703. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71704. * 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.
  71705. * Anyway, it's as accurate as the standard strategy.
  71706. * Test :
  71707. * Is the cullable object bounding sphere center in the frustum ?
  71708. * If not, apply the default culling strategy.
  71709. */
  71710. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71711. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71712. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71713. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71714. * 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.
  71715. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71716. * Test :
  71717. * Is the cullable object bounding sphere center in the frustum ?
  71718. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71719. */
  71720. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71721. /**
  71722. * No logging while loading
  71723. */
  71724. static readonly SCENELOADER_NO_LOGGING: number;
  71725. /**
  71726. * Minimal logging while loading
  71727. */
  71728. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71729. /**
  71730. * Summary logging while loading
  71731. */
  71732. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71733. /**
  71734. * Detailled logging while loading
  71735. */
  71736. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71737. }
  71738. }
  71739. declare module BABYLON {
  71740. /**
  71741. * This represents the required contract to create a new type of texture loader.
  71742. */
  71743. export interface IInternalTextureLoader {
  71744. /**
  71745. * Defines wether the loader supports cascade loading the different faces.
  71746. */
  71747. supportCascades: boolean;
  71748. /**
  71749. * This returns if the loader support the current file information.
  71750. * @param extension defines the file extension of the file being loaded
  71751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71752. * @param fallback defines the fallback internal texture if any
  71753. * @param isBase64 defines whether the texture is encoded as a base64
  71754. * @param isBuffer defines whether the texture data are stored as a buffer
  71755. * @returns true if the loader can load the specified file
  71756. */
  71757. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71758. /**
  71759. * Transform the url before loading if required.
  71760. * @param rootUrl the url of the texture
  71761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71762. * @returns the transformed texture
  71763. */
  71764. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71765. /**
  71766. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71767. * @param rootUrl the url of the texture
  71768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71769. * @returns the fallback texture
  71770. */
  71771. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71772. /**
  71773. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71774. * @param data contains the texture data
  71775. * @param texture defines the BabylonJS internal texture
  71776. * @param createPolynomials will be true if polynomials have been requested
  71777. * @param onLoad defines the callback to trigger once the texture is ready
  71778. * @param onError defines the callback to trigger in case of error
  71779. */
  71780. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71781. /**
  71782. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71783. * @param data contains the texture data
  71784. * @param texture defines the BabylonJS internal texture
  71785. * @param callback defines the method to call once ready to upload
  71786. */
  71787. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71788. }
  71789. }
  71790. declare module BABYLON {
  71791. /**
  71792. * Class used to store and describe the pipeline context associated with an effect
  71793. */
  71794. export interface IPipelineContext {
  71795. /**
  71796. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71797. */
  71798. isAsync: boolean;
  71799. /**
  71800. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71801. */
  71802. isReady: boolean;
  71803. /** @hidden */
  71804. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71805. }
  71806. }
  71807. declare module BABYLON {
  71808. /**
  71809. * Class used to store gfx data (like WebGLBuffer)
  71810. */
  71811. export class DataBuffer {
  71812. /**
  71813. * Gets or sets the number of objects referencing this buffer
  71814. */
  71815. references: number;
  71816. /** Gets or sets the size of the underlying buffer */
  71817. capacity: number;
  71818. /**
  71819. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71820. */
  71821. is32Bits: boolean;
  71822. /**
  71823. * Gets the underlying buffer
  71824. */
  71825. get underlyingResource(): any;
  71826. }
  71827. }
  71828. declare module BABYLON {
  71829. /** @hidden */
  71830. export interface IShaderProcessor {
  71831. attributeProcessor?: (attribute: string) => string;
  71832. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71833. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71834. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71835. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71836. lineProcessor?: (line: string, isFragment: boolean) => string;
  71837. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71838. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71839. }
  71840. }
  71841. declare module BABYLON {
  71842. /** @hidden */
  71843. export interface ProcessingOptions {
  71844. defines: string[];
  71845. indexParameters: any;
  71846. isFragment: boolean;
  71847. shouldUseHighPrecisionShader: boolean;
  71848. supportsUniformBuffers: boolean;
  71849. shadersRepository: string;
  71850. includesShadersStore: {
  71851. [key: string]: string;
  71852. };
  71853. processor?: IShaderProcessor;
  71854. version: string;
  71855. platformName: string;
  71856. lookForClosingBracketForUniformBuffer?: boolean;
  71857. }
  71858. }
  71859. declare module BABYLON {
  71860. /** @hidden */
  71861. export class ShaderCodeNode {
  71862. line: string;
  71863. children: ShaderCodeNode[];
  71864. additionalDefineKey?: string;
  71865. additionalDefineValue?: string;
  71866. isValid(preprocessors: {
  71867. [key: string]: string;
  71868. }): boolean;
  71869. process(preprocessors: {
  71870. [key: string]: string;
  71871. }, options: ProcessingOptions): string;
  71872. }
  71873. }
  71874. declare module BABYLON {
  71875. /** @hidden */
  71876. export class ShaderCodeCursor {
  71877. private _lines;
  71878. lineIndex: number;
  71879. get currentLine(): string;
  71880. get canRead(): boolean;
  71881. set lines(value: string[]);
  71882. }
  71883. }
  71884. declare module BABYLON {
  71885. /** @hidden */
  71886. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71887. process(preprocessors: {
  71888. [key: string]: string;
  71889. }, options: ProcessingOptions): string;
  71890. }
  71891. }
  71892. declare module BABYLON {
  71893. /** @hidden */
  71894. export class ShaderDefineExpression {
  71895. isTrue(preprocessors: {
  71896. [key: string]: string;
  71897. }): boolean;
  71898. }
  71899. }
  71900. declare module BABYLON {
  71901. /** @hidden */
  71902. export class ShaderCodeTestNode extends ShaderCodeNode {
  71903. testExpression: ShaderDefineExpression;
  71904. isValid(preprocessors: {
  71905. [key: string]: string;
  71906. }): boolean;
  71907. }
  71908. }
  71909. declare module BABYLON {
  71910. /** @hidden */
  71911. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71912. define: string;
  71913. not: boolean;
  71914. constructor(define: string, not?: boolean);
  71915. isTrue(preprocessors: {
  71916. [key: string]: string;
  71917. }): boolean;
  71918. }
  71919. }
  71920. declare module BABYLON {
  71921. /** @hidden */
  71922. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71923. leftOperand: ShaderDefineExpression;
  71924. rightOperand: ShaderDefineExpression;
  71925. isTrue(preprocessors: {
  71926. [key: string]: string;
  71927. }): boolean;
  71928. }
  71929. }
  71930. declare module BABYLON {
  71931. /** @hidden */
  71932. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71933. leftOperand: ShaderDefineExpression;
  71934. rightOperand: ShaderDefineExpression;
  71935. isTrue(preprocessors: {
  71936. [key: string]: string;
  71937. }): boolean;
  71938. }
  71939. }
  71940. declare module BABYLON {
  71941. /** @hidden */
  71942. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71943. define: string;
  71944. operand: string;
  71945. testValue: string;
  71946. constructor(define: string, operand: string, testValue: string);
  71947. isTrue(preprocessors: {
  71948. [key: string]: string;
  71949. }): boolean;
  71950. }
  71951. }
  71952. declare module BABYLON {
  71953. /**
  71954. * Class used to enable access to offline support
  71955. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71956. */
  71957. export interface IOfflineProvider {
  71958. /**
  71959. * Gets a boolean indicating if scene must be saved in the database
  71960. */
  71961. enableSceneOffline: boolean;
  71962. /**
  71963. * Gets a boolean indicating if textures must be saved in the database
  71964. */
  71965. enableTexturesOffline: boolean;
  71966. /**
  71967. * Open the offline support and make it available
  71968. * @param successCallback defines the callback to call on success
  71969. * @param errorCallback defines the callback to call on error
  71970. */
  71971. open(successCallback: () => void, errorCallback: () => void): void;
  71972. /**
  71973. * Loads an image from the offline support
  71974. * @param url defines the url to load from
  71975. * @param image defines the target DOM image
  71976. */
  71977. loadImage(url: string, image: HTMLImageElement): void;
  71978. /**
  71979. * Loads a file from offline support
  71980. * @param url defines the URL to load from
  71981. * @param sceneLoaded defines a callback to call on success
  71982. * @param progressCallBack defines a callback to call when progress changed
  71983. * @param errorCallback defines a callback to call on error
  71984. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71985. */
  71986. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71987. }
  71988. }
  71989. declare module BABYLON {
  71990. /**
  71991. * Class used to help managing file picking and drag'n'drop
  71992. * File Storage
  71993. */
  71994. export class FilesInputStore {
  71995. /**
  71996. * List of files ready to be loaded
  71997. */
  71998. static FilesToLoad: {
  71999. [key: string]: File;
  72000. };
  72001. }
  72002. }
  72003. declare module BABYLON {
  72004. /**
  72005. * Class used to define a retry strategy when error happens while loading assets
  72006. */
  72007. export class RetryStrategy {
  72008. /**
  72009. * Function used to defines an exponential back off strategy
  72010. * @param maxRetries defines the maximum number of retries (3 by default)
  72011. * @param baseInterval defines the interval between retries
  72012. * @returns the strategy function to use
  72013. */
  72014. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  72015. }
  72016. }
  72017. declare module BABYLON {
  72018. /**
  72019. * @ignore
  72020. * Application error to support additional information when loading a file
  72021. */
  72022. export abstract class BaseError extends Error {
  72023. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  72024. }
  72025. }
  72026. declare module BABYLON {
  72027. /** @ignore */
  72028. export class LoadFileError extends BaseError {
  72029. request?: WebRequest;
  72030. file?: File;
  72031. /**
  72032. * Creates a new LoadFileError
  72033. * @param message defines the message of the error
  72034. * @param request defines the optional web request
  72035. * @param file defines the optional file
  72036. */
  72037. constructor(message: string, object?: WebRequest | File);
  72038. }
  72039. /** @ignore */
  72040. export class RequestFileError extends BaseError {
  72041. request: WebRequest;
  72042. /**
  72043. * Creates a new LoadFileError
  72044. * @param message defines the message of the error
  72045. * @param request defines the optional web request
  72046. */
  72047. constructor(message: string, request: WebRequest);
  72048. }
  72049. /** @ignore */
  72050. export class ReadFileError extends BaseError {
  72051. file: File;
  72052. /**
  72053. * Creates a new ReadFileError
  72054. * @param message defines the message of the error
  72055. * @param file defines the optional file
  72056. */
  72057. constructor(message: string, file: File);
  72058. }
  72059. /**
  72060. * @hidden
  72061. */
  72062. export class FileTools {
  72063. /**
  72064. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72065. */
  72066. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72067. /**
  72068. * Gets or sets the base URL to use to load assets
  72069. */
  72070. static BaseUrl: string;
  72071. /**
  72072. * Default behaviour for cors in the application.
  72073. * It can be a string if the expected behavior is identical in the entire app.
  72074. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72075. */
  72076. static CorsBehavior: string | ((url: string | string[]) => string);
  72077. /**
  72078. * Gets or sets a function used to pre-process url before using them to load assets
  72079. */
  72080. static PreprocessUrl: (url: string) => string;
  72081. /**
  72082. * Removes unwanted characters from an url
  72083. * @param url defines the url to clean
  72084. * @returns the cleaned url
  72085. */
  72086. private static _CleanUrl;
  72087. /**
  72088. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72089. * @param url define the url we are trying
  72090. * @param element define the dom element where to configure the cors policy
  72091. */
  72092. static SetCorsBehavior(url: string | string[], element: {
  72093. crossOrigin: string | null;
  72094. }): void;
  72095. /**
  72096. * Loads an image as an HTMLImageElement.
  72097. * @param input url string, ArrayBuffer, or Blob to load
  72098. * @param onLoad callback called when the image successfully loads
  72099. * @param onError callback called when the image fails to load
  72100. * @param offlineProvider offline provider for caching
  72101. * @param mimeType optional mime type
  72102. * @returns the HTMLImageElement of the loaded image
  72103. */
  72104. 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>;
  72105. /**
  72106. * Reads a file from a File object
  72107. * @param file defines the file to load
  72108. * @param onSuccess defines the callback to call when data is loaded
  72109. * @param onProgress defines the callback to call during loading process
  72110. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72111. * @param onError defines the callback to call when an error occurs
  72112. * @returns a file request object
  72113. */
  72114. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72115. /**
  72116. * Loads a file from a url
  72117. * @param url url to load
  72118. * @param onSuccess callback called when the file successfully loads
  72119. * @param onProgress callback called while file is loading (if the server supports this mode)
  72120. * @param offlineProvider defines the offline provider for caching
  72121. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72122. * @param onError callback called when the file fails to load
  72123. * @returns a file request object
  72124. */
  72125. 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;
  72126. /**
  72127. * Loads a file
  72128. * @param url url to load
  72129. * @param onSuccess callback called when the file successfully loads
  72130. * @param onProgress callback called while file is loading (if the server supports this mode)
  72131. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72132. * @param onError callback called when the file fails to load
  72133. * @param onOpened callback called when the web request is opened
  72134. * @returns a file request object
  72135. */
  72136. 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;
  72137. /**
  72138. * Checks if the loaded document was accessed via `file:`-Protocol.
  72139. * @returns boolean
  72140. */
  72141. static IsFileURL(): boolean;
  72142. }
  72143. }
  72144. declare module BABYLON {
  72145. /** @hidden */
  72146. export class ShaderProcessor {
  72147. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72148. private static _ProcessPrecision;
  72149. private static _ExtractOperation;
  72150. private static _BuildSubExpression;
  72151. private static _BuildExpression;
  72152. private static _MoveCursorWithinIf;
  72153. private static _MoveCursor;
  72154. private static _EvaluatePreProcessors;
  72155. private static _PreparePreProcessors;
  72156. private static _ProcessShaderConversion;
  72157. private static _ProcessIncludes;
  72158. /**
  72159. * Loads a file from a url
  72160. * @param url url to load
  72161. * @param onSuccess callback called when the file successfully loads
  72162. * @param onProgress callback called while file is loading (if the server supports this mode)
  72163. * @param offlineProvider defines the offline provider for caching
  72164. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72165. * @param onError callback called when the file fails to load
  72166. * @returns a file request object
  72167. * @hidden
  72168. */
  72169. 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;
  72170. }
  72171. }
  72172. declare module BABYLON {
  72173. /**
  72174. * @hidden
  72175. */
  72176. export interface IColor4Like {
  72177. r: float;
  72178. g: float;
  72179. b: float;
  72180. a: float;
  72181. }
  72182. /**
  72183. * @hidden
  72184. */
  72185. export interface IColor3Like {
  72186. r: float;
  72187. g: float;
  72188. b: float;
  72189. }
  72190. /**
  72191. * @hidden
  72192. */
  72193. export interface IVector4Like {
  72194. x: float;
  72195. y: float;
  72196. z: float;
  72197. w: float;
  72198. }
  72199. /**
  72200. * @hidden
  72201. */
  72202. export interface IVector3Like {
  72203. x: float;
  72204. y: float;
  72205. z: float;
  72206. }
  72207. /**
  72208. * @hidden
  72209. */
  72210. export interface IVector2Like {
  72211. x: float;
  72212. y: float;
  72213. }
  72214. /**
  72215. * @hidden
  72216. */
  72217. export interface IMatrixLike {
  72218. toArray(): DeepImmutable<Float32Array>;
  72219. updateFlag: int;
  72220. }
  72221. /**
  72222. * @hidden
  72223. */
  72224. export interface IViewportLike {
  72225. x: float;
  72226. y: float;
  72227. width: float;
  72228. height: float;
  72229. }
  72230. /**
  72231. * @hidden
  72232. */
  72233. export interface IPlaneLike {
  72234. normal: IVector3Like;
  72235. d: float;
  72236. normalize(): void;
  72237. }
  72238. }
  72239. declare module BABYLON {
  72240. /**
  72241. * Interface used to define common properties for effect fallbacks
  72242. */
  72243. export interface IEffectFallbacks {
  72244. /**
  72245. * Removes the defines that should be removed when falling back.
  72246. * @param currentDefines defines the current define statements for the shader.
  72247. * @param effect defines the current effect we try to compile
  72248. * @returns The resulting defines with defines of the current rank removed.
  72249. */
  72250. reduce(currentDefines: string, effect: Effect): string;
  72251. /**
  72252. * Removes the fallback from the bound mesh.
  72253. */
  72254. unBindMesh(): void;
  72255. /**
  72256. * Checks to see if more fallbacks are still availible.
  72257. */
  72258. hasMoreFallbacks: boolean;
  72259. }
  72260. }
  72261. declare module BABYLON {
  72262. /**
  72263. * Class used to evalaute queries containing `and` and `or` operators
  72264. */
  72265. export class AndOrNotEvaluator {
  72266. /**
  72267. * Evaluate a query
  72268. * @param query defines the query to evaluate
  72269. * @param evaluateCallback defines the callback used to filter result
  72270. * @returns true if the query matches
  72271. */
  72272. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72273. private static _HandleParenthesisContent;
  72274. private static _SimplifyNegation;
  72275. }
  72276. }
  72277. declare module BABYLON {
  72278. /**
  72279. * Class used to store custom tags
  72280. */
  72281. export class Tags {
  72282. /**
  72283. * Adds support for tags on the given object
  72284. * @param obj defines the object to use
  72285. */
  72286. static EnableFor(obj: any): void;
  72287. /**
  72288. * Removes tags support
  72289. * @param obj defines the object to use
  72290. */
  72291. static DisableFor(obj: any): void;
  72292. /**
  72293. * Gets a boolean indicating if the given object has tags
  72294. * @param obj defines the object to use
  72295. * @returns a boolean
  72296. */
  72297. static HasTags(obj: any): boolean;
  72298. /**
  72299. * Gets the tags available on a given object
  72300. * @param obj defines the object to use
  72301. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72302. * @returns the tags
  72303. */
  72304. static GetTags(obj: any, asString?: boolean): any;
  72305. /**
  72306. * Adds tags to an object
  72307. * @param obj defines the object to use
  72308. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72309. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72310. */
  72311. static AddTagsTo(obj: any, tagsString: string): void;
  72312. /**
  72313. * @hidden
  72314. */
  72315. static _AddTagTo(obj: any, tag: string): void;
  72316. /**
  72317. * Removes specific tags from a specific object
  72318. * @param obj defines the object to use
  72319. * @param tagsString defines the tags to remove
  72320. */
  72321. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72322. /**
  72323. * @hidden
  72324. */
  72325. static _RemoveTagFrom(obj: any, tag: string): void;
  72326. /**
  72327. * Defines if tags hosted on an object match a given query
  72328. * @param obj defines the object to use
  72329. * @param tagsQuery defines the tag query
  72330. * @returns a boolean
  72331. */
  72332. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72333. }
  72334. }
  72335. declare module BABYLON {
  72336. /**
  72337. * Scalar computation library
  72338. */
  72339. export class Scalar {
  72340. /**
  72341. * Two pi constants convenient for computation.
  72342. */
  72343. static TwoPi: number;
  72344. /**
  72345. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72346. * @param a number
  72347. * @param b number
  72348. * @param epsilon (default = 1.401298E-45)
  72349. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72350. */
  72351. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72352. /**
  72353. * Returns a string : the upper case translation of the number i to hexadecimal.
  72354. * @param i number
  72355. * @returns the upper case translation of the number i to hexadecimal.
  72356. */
  72357. static ToHex(i: number): string;
  72358. /**
  72359. * Returns -1 if value is negative and +1 is value is positive.
  72360. * @param value the value
  72361. * @returns the value itself if it's equal to zero.
  72362. */
  72363. static Sign(value: number): number;
  72364. /**
  72365. * Returns the value itself if it's between min and max.
  72366. * Returns min if the value is lower than min.
  72367. * Returns max if the value is greater than max.
  72368. * @param value the value to clmap
  72369. * @param min the min value to clamp to (default: 0)
  72370. * @param max the max value to clamp to (default: 1)
  72371. * @returns the clamped value
  72372. */
  72373. static Clamp(value: number, min?: number, max?: number): number;
  72374. /**
  72375. * the log2 of value.
  72376. * @param value the value to compute log2 of
  72377. * @returns the log2 of value.
  72378. */
  72379. static Log2(value: number): number;
  72380. /**
  72381. * Loops the value, so that it is never larger than length and never smaller than 0.
  72382. *
  72383. * This is similar to the modulo operator but it works with floating point numbers.
  72384. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72385. * With t = 5 and length = 2.5, the result would be 0.0.
  72386. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72387. * @param value the value
  72388. * @param length the length
  72389. * @returns the looped value
  72390. */
  72391. static Repeat(value: number, length: number): number;
  72392. /**
  72393. * Normalize the value between 0.0 and 1.0 using min and max values
  72394. * @param value value to normalize
  72395. * @param min max to normalize between
  72396. * @param max min to normalize between
  72397. * @returns the normalized value
  72398. */
  72399. static Normalize(value: number, min: number, max: number): number;
  72400. /**
  72401. * Denormalize the value from 0.0 and 1.0 using min and max values
  72402. * @param normalized value to denormalize
  72403. * @param min max to denormalize between
  72404. * @param max min to denormalize between
  72405. * @returns the denormalized value
  72406. */
  72407. static Denormalize(normalized: number, min: number, max: number): number;
  72408. /**
  72409. * Calculates the shortest difference between two given angles given in degrees.
  72410. * @param current current angle in degrees
  72411. * @param target target angle in degrees
  72412. * @returns the delta
  72413. */
  72414. static DeltaAngle(current: number, target: number): number;
  72415. /**
  72416. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72417. * @param tx value
  72418. * @param length length
  72419. * @returns The returned value will move back and forth between 0 and length
  72420. */
  72421. static PingPong(tx: number, length: number): number;
  72422. /**
  72423. * Interpolates between min and max with smoothing at the limits.
  72424. *
  72425. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72426. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72427. * @param from from
  72428. * @param to to
  72429. * @param tx value
  72430. * @returns the smooth stepped value
  72431. */
  72432. static SmoothStep(from: number, to: number, tx: number): number;
  72433. /**
  72434. * Moves a value current towards target.
  72435. *
  72436. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72437. * Negative values of maxDelta pushes the value away from target.
  72438. * @param current current value
  72439. * @param target target value
  72440. * @param maxDelta max distance to move
  72441. * @returns resulting value
  72442. */
  72443. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72444. /**
  72445. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72446. *
  72447. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72448. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72449. * @param current current value
  72450. * @param target target value
  72451. * @param maxDelta max distance to move
  72452. * @returns resulting angle
  72453. */
  72454. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72455. /**
  72456. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72457. * @param start start value
  72458. * @param end target value
  72459. * @param amount amount to lerp between
  72460. * @returns the lerped value
  72461. */
  72462. static Lerp(start: number, end: number, amount: number): number;
  72463. /**
  72464. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72465. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72466. * @param start start value
  72467. * @param end target value
  72468. * @param amount amount to lerp between
  72469. * @returns the lerped value
  72470. */
  72471. static LerpAngle(start: number, end: number, amount: number): number;
  72472. /**
  72473. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72474. * @param a start value
  72475. * @param b target value
  72476. * @param value value between a and b
  72477. * @returns the inverseLerp value
  72478. */
  72479. static InverseLerp(a: number, b: number, value: number): number;
  72480. /**
  72481. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72482. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72483. * @param value1 spline value
  72484. * @param tangent1 spline value
  72485. * @param value2 spline value
  72486. * @param tangent2 spline value
  72487. * @param amount input value
  72488. * @returns hermite result
  72489. */
  72490. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72491. /**
  72492. * Returns a random float number between and min and max values
  72493. * @param min min value of random
  72494. * @param max max value of random
  72495. * @returns random value
  72496. */
  72497. static RandomRange(min: number, max: number): number;
  72498. /**
  72499. * This function returns percentage of a number in a given range.
  72500. *
  72501. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72502. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72503. * @param number to convert to percentage
  72504. * @param min min range
  72505. * @param max max range
  72506. * @returns the percentage
  72507. */
  72508. static RangeToPercent(number: number, min: number, max: number): number;
  72509. /**
  72510. * This function returns number that corresponds to the percentage in a given range.
  72511. *
  72512. * PercentToRange(0.34,0,100) will return 34.
  72513. * @param percent to convert to number
  72514. * @param min min range
  72515. * @param max max range
  72516. * @returns the number
  72517. */
  72518. static PercentToRange(percent: number, min: number, max: number): number;
  72519. /**
  72520. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72521. * @param angle The angle to normalize in radian.
  72522. * @return The converted angle.
  72523. */
  72524. static NormalizeRadians(angle: number): number;
  72525. }
  72526. }
  72527. declare module BABYLON {
  72528. /**
  72529. * Constant used to convert a value to gamma space
  72530. * @ignorenaming
  72531. */
  72532. export const ToGammaSpace: number;
  72533. /**
  72534. * Constant used to convert a value to linear space
  72535. * @ignorenaming
  72536. */
  72537. export const ToLinearSpace = 2.2;
  72538. /**
  72539. * Constant used to define the minimal number value in Babylon.js
  72540. * @ignorenaming
  72541. */
  72542. let Epsilon: number;
  72543. }
  72544. declare module BABYLON {
  72545. /**
  72546. * Class used to represent a viewport on screen
  72547. */
  72548. export class Viewport {
  72549. /** viewport left coordinate */
  72550. x: number;
  72551. /** viewport top coordinate */
  72552. y: number;
  72553. /**viewport width */
  72554. width: number;
  72555. /** viewport height */
  72556. height: number;
  72557. /**
  72558. * Creates a Viewport object located at (x, y) and sized (width, height)
  72559. * @param x defines viewport left coordinate
  72560. * @param y defines viewport top coordinate
  72561. * @param width defines the viewport width
  72562. * @param height defines the viewport height
  72563. */
  72564. constructor(
  72565. /** viewport left coordinate */
  72566. x: number,
  72567. /** viewport top coordinate */
  72568. y: number,
  72569. /**viewport width */
  72570. width: number,
  72571. /** viewport height */
  72572. height: number);
  72573. /**
  72574. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72575. * @param renderWidth defines the rendering width
  72576. * @param renderHeight defines the rendering height
  72577. * @returns a new Viewport
  72578. */
  72579. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72580. /**
  72581. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72582. * @param renderWidth defines the rendering width
  72583. * @param renderHeight defines the rendering height
  72584. * @param ref defines the target viewport
  72585. * @returns the current viewport
  72586. */
  72587. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72588. /**
  72589. * Returns a new Viewport copied from the current one
  72590. * @returns a new Viewport
  72591. */
  72592. clone(): Viewport;
  72593. }
  72594. }
  72595. declare module BABYLON {
  72596. /**
  72597. * Class containing a set of static utilities functions for arrays.
  72598. */
  72599. export class ArrayTools {
  72600. /**
  72601. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72602. * @param size the number of element to construct and put in the array
  72603. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72604. * @returns a new array filled with new objects
  72605. */
  72606. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72607. }
  72608. }
  72609. declare module BABYLON {
  72610. /**
  72611. * Class representing a vector containing 2 coordinates
  72612. */
  72613. export class Vector2 {
  72614. /** defines the first coordinate */
  72615. x: number;
  72616. /** defines the second coordinate */
  72617. y: number;
  72618. /**
  72619. * Creates a new Vector2 from the given x and y coordinates
  72620. * @param x defines the first coordinate
  72621. * @param y defines the second coordinate
  72622. */
  72623. constructor(
  72624. /** defines the first coordinate */
  72625. x?: number,
  72626. /** defines the second coordinate */
  72627. y?: number);
  72628. /**
  72629. * Gets a string with the Vector2 coordinates
  72630. * @returns a string with the Vector2 coordinates
  72631. */
  72632. toString(): string;
  72633. /**
  72634. * Gets class name
  72635. * @returns the string "Vector2"
  72636. */
  72637. getClassName(): string;
  72638. /**
  72639. * Gets current vector hash code
  72640. * @returns the Vector2 hash code as a number
  72641. */
  72642. getHashCode(): number;
  72643. /**
  72644. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72645. * @param array defines the source array
  72646. * @param index defines the offset in source array
  72647. * @returns the current Vector2
  72648. */
  72649. toArray(array: FloatArray, index?: number): Vector2;
  72650. /**
  72651. * Copy the current vector to an array
  72652. * @returns a new array with 2 elements: the Vector2 coordinates.
  72653. */
  72654. asArray(): number[];
  72655. /**
  72656. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72657. * @param source defines the source Vector2
  72658. * @returns the current updated Vector2
  72659. */
  72660. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72661. /**
  72662. * Sets the Vector2 coordinates with the given floats
  72663. * @param x defines the first coordinate
  72664. * @param y defines the second coordinate
  72665. * @returns the current updated Vector2
  72666. */
  72667. copyFromFloats(x: number, y: number): Vector2;
  72668. /**
  72669. * Sets the Vector2 coordinates with the given floats
  72670. * @param x defines the first coordinate
  72671. * @param y defines the second coordinate
  72672. * @returns the current updated Vector2
  72673. */
  72674. set(x: number, y: number): Vector2;
  72675. /**
  72676. * Add another vector with the current one
  72677. * @param otherVector defines the other vector
  72678. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72679. */
  72680. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72681. /**
  72682. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72683. * @param otherVector defines the other vector
  72684. * @param result defines the target vector
  72685. * @returns the unmodified current Vector2
  72686. */
  72687. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72688. /**
  72689. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72690. * @param otherVector defines the other vector
  72691. * @returns the current updated Vector2
  72692. */
  72693. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72694. /**
  72695. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72696. * @param otherVector defines the other vector
  72697. * @returns a new Vector2
  72698. */
  72699. addVector3(otherVector: Vector3): Vector2;
  72700. /**
  72701. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72702. * @param otherVector defines the other vector
  72703. * @returns a new Vector2
  72704. */
  72705. subtract(otherVector: Vector2): Vector2;
  72706. /**
  72707. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72708. * @param otherVector defines the other vector
  72709. * @param result defines the target vector
  72710. * @returns the unmodified current Vector2
  72711. */
  72712. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72713. /**
  72714. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72715. * @param otherVector defines the other vector
  72716. * @returns the current updated Vector2
  72717. */
  72718. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72719. /**
  72720. * Multiplies in place the current Vector2 coordinates by the given ones
  72721. * @param otherVector defines the other vector
  72722. * @returns the current updated Vector2
  72723. */
  72724. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72725. /**
  72726. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72727. * @param otherVector defines the other vector
  72728. * @returns a new Vector2
  72729. */
  72730. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72731. /**
  72732. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72733. * @param otherVector defines the other vector
  72734. * @param result defines the target vector
  72735. * @returns the unmodified current Vector2
  72736. */
  72737. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72738. /**
  72739. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72740. * @param x defines the first coordinate
  72741. * @param y defines the second coordinate
  72742. * @returns a new Vector2
  72743. */
  72744. multiplyByFloats(x: number, y: number): Vector2;
  72745. /**
  72746. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72747. * @param otherVector defines the other vector
  72748. * @returns a new Vector2
  72749. */
  72750. divide(otherVector: Vector2): Vector2;
  72751. /**
  72752. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72753. * @param otherVector defines the other vector
  72754. * @param result defines the target vector
  72755. * @returns the unmodified current Vector2
  72756. */
  72757. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72758. /**
  72759. * Divides the current Vector2 coordinates by the given ones
  72760. * @param otherVector defines the other vector
  72761. * @returns the current updated Vector2
  72762. */
  72763. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72764. /**
  72765. * Gets a new Vector2 with current Vector2 negated coordinates
  72766. * @returns a new Vector2
  72767. */
  72768. negate(): Vector2;
  72769. /**
  72770. * Multiply the Vector2 coordinates by scale
  72771. * @param scale defines the scaling factor
  72772. * @returns the current updated Vector2
  72773. */
  72774. scaleInPlace(scale: number): Vector2;
  72775. /**
  72776. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72777. * @param scale defines the scaling factor
  72778. * @returns a new Vector2
  72779. */
  72780. scale(scale: number): Vector2;
  72781. /**
  72782. * Scale the current Vector2 values by a factor to a given Vector2
  72783. * @param scale defines the scale factor
  72784. * @param result defines the Vector2 object where to store the result
  72785. * @returns the unmodified current Vector2
  72786. */
  72787. scaleToRef(scale: number, result: Vector2): Vector2;
  72788. /**
  72789. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72790. * @param scale defines the scale factor
  72791. * @param result defines the Vector2 object where to store the result
  72792. * @returns the unmodified current Vector2
  72793. */
  72794. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72795. /**
  72796. * Gets a boolean if two vectors are equals
  72797. * @param otherVector defines the other vector
  72798. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72799. */
  72800. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72801. /**
  72802. * Gets a boolean if two vectors are equals (using an epsilon value)
  72803. * @param otherVector defines the other vector
  72804. * @param epsilon defines the minimal distance to consider equality
  72805. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72806. */
  72807. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72808. /**
  72809. * Gets a new Vector2 from current Vector2 floored values
  72810. * @returns a new Vector2
  72811. */
  72812. floor(): Vector2;
  72813. /**
  72814. * Gets a new Vector2 from current Vector2 floored values
  72815. * @returns a new Vector2
  72816. */
  72817. fract(): Vector2;
  72818. /**
  72819. * Gets the length of the vector
  72820. * @returns the vector length (float)
  72821. */
  72822. length(): number;
  72823. /**
  72824. * Gets the vector squared length
  72825. * @returns the vector squared length (float)
  72826. */
  72827. lengthSquared(): number;
  72828. /**
  72829. * Normalize the vector
  72830. * @returns the current updated Vector2
  72831. */
  72832. normalize(): Vector2;
  72833. /**
  72834. * Gets a new Vector2 copied from the Vector2
  72835. * @returns a new Vector2
  72836. */
  72837. clone(): Vector2;
  72838. /**
  72839. * Gets a new Vector2(0, 0)
  72840. * @returns a new Vector2
  72841. */
  72842. static Zero(): Vector2;
  72843. /**
  72844. * Gets a new Vector2(1, 1)
  72845. * @returns a new Vector2
  72846. */
  72847. static One(): Vector2;
  72848. /**
  72849. * Gets a new Vector2 set from the given index element of the given array
  72850. * @param array defines the data source
  72851. * @param offset defines the offset in the data source
  72852. * @returns a new Vector2
  72853. */
  72854. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72855. /**
  72856. * Sets "result" from the given index element of the given array
  72857. * @param array defines the data source
  72858. * @param offset defines the offset in the data source
  72859. * @param result defines the target vector
  72860. */
  72861. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72862. /**
  72863. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72864. * @param value1 defines 1st point of control
  72865. * @param value2 defines 2nd point of control
  72866. * @param value3 defines 3rd point of control
  72867. * @param value4 defines 4th point of control
  72868. * @param amount defines the interpolation factor
  72869. * @returns a new Vector2
  72870. */
  72871. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72872. /**
  72873. * 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".
  72874. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72875. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72876. * @param value defines the value to clamp
  72877. * @param min defines the lower limit
  72878. * @param max defines the upper limit
  72879. * @returns a new Vector2
  72880. */
  72881. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72882. /**
  72883. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72884. * @param value1 defines the 1st control point
  72885. * @param tangent1 defines the outgoing tangent
  72886. * @param value2 defines the 2nd control point
  72887. * @param tangent2 defines the incoming tangent
  72888. * @param amount defines the interpolation factor
  72889. * @returns a new Vector2
  72890. */
  72891. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72892. /**
  72893. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72894. * @param start defines the start vector
  72895. * @param end defines the end vector
  72896. * @param amount defines the interpolation factor
  72897. * @returns a new Vector2
  72898. */
  72899. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72900. /**
  72901. * Gets the dot product of the vector "left" and the vector "right"
  72902. * @param left defines first vector
  72903. * @param right defines second vector
  72904. * @returns the dot product (float)
  72905. */
  72906. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72907. /**
  72908. * Returns a new Vector2 equal to the normalized given vector
  72909. * @param vector defines the vector to normalize
  72910. * @returns a new Vector2
  72911. */
  72912. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72913. /**
  72914. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72915. * @param left defines 1st vector
  72916. * @param right defines 2nd vector
  72917. * @returns a new Vector2
  72918. */
  72919. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72920. /**
  72921. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72922. * @param left defines 1st vector
  72923. * @param right defines 2nd vector
  72924. * @returns a new Vector2
  72925. */
  72926. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72927. /**
  72928. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72929. * @param vector defines the vector to transform
  72930. * @param transformation defines the matrix to apply
  72931. * @returns a new Vector2
  72932. */
  72933. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72934. /**
  72935. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72936. * @param vector defines the vector to transform
  72937. * @param transformation defines the matrix to apply
  72938. * @param result defines the target vector
  72939. */
  72940. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72941. /**
  72942. * Determines if a given vector is included in a triangle
  72943. * @param p defines the vector to test
  72944. * @param p0 defines 1st triangle point
  72945. * @param p1 defines 2nd triangle point
  72946. * @param p2 defines 3rd triangle point
  72947. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72948. */
  72949. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72950. /**
  72951. * Gets the distance between the vectors "value1" and "value2"
  72952. * @param value1 defines first vector
  72953. * @param value2 defines second vector
  72954. * @returns the distance between vectors
  72955. */
  72956. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72957. /**
  72958. * Returns the squared distance between the vectors "value1" and "value2"
  72959. * @param value1 defines first vector
  72960. * @param value2 defines second vector
  72961. * @returns the squared distance between vectors
  72962. */
  72963. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72964. /**
  72965. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72966. * @param value1 defines first vector
  72967. * @param value2 defines second vector
  72968. * @returns a new Vector2
  72969. */
  72970. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72971. /**
  72972. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72973. * @param p defines the middle point
  72974. * @param segA defines one point of the segment
  72975. * @param segB defines the other point of the segment
  72976. * @returns the shortest distance
  72977. */
  72978. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72979. }
  72980. /**
  72981. * Class used to store (x,y,z) vector representation
  72982. * A Vector3 is the main object used in 3D geometry
  72983. * It can represent etiher the coordinates of a point the space, either a direction
  72984. * Reminder: js uses a left handed forward facing system
  72985. */
  72986. export class Vector3 {
  72987. /**
  72988. * Defines the first coordinates (on X axis)
  72989. */
  72990. x: number;
  72991. /**
  72992. * Defines the second coordinates (on Y axis)
  72993. */
  72994. y: number;
  72995. /**
  72996. * Defines the third coordinates (on Z axis)
  72997. */
  72998. z: number;
  72999. private static _UpReadOnly;
  73000. private static _ZeroReadOnly;
  73001. /**
  73002. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  73003. * @param x defines the first coordinates (on X axis)
  73004. * @param y defines the second coordinates (on Y axis)
  73005. * @param z defines the third coordinates (on Z axis)
  73006. */
  73007. constructor(
  73008. /**
  73009. * Defines the first coordinates (on X axis)
  73010. */
  73011. x?: number,
  73012. /**
  73013. * Defines the second coordinates (on Y axis)
  73014. */
  73015. y?: number,
  73016. /**
  73017. * Defines the third coordinates (on Z axis)
  73018. */
  73019. z?: number);
  73020. /**
  73021. * Creates a string representation of the Vector3
  73022. * @returns a string with the Vector3 coordinates.
  73023. */
  73024. toString(): string;
  73025. /**
  73026. * Gets the class name
  73027. * @returns the string "Vector3"
  73028. */
  73029. getClassName(): string;
  73030. /**
  73031. * Creates the Vector3 hash code
  73032. * @returns a number which tends to be unique between Vector3 instances
  73033. */
  73034. getHashCode(): number;
  73035. /**
  73036. * Creates an array containing three elements : the coordinates of the Vector3
  73037. * @returns a new array of numbers
  73038. */
  73039. asArray(): number[];
  73040. /**
  73041. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73042. * @param array defines the destination array
  73043. * @param index defines the offset in the destination array
  73044. * @returns the current Vector3
  73045. */
  73046. toArray(array: FloatArray, index?: number): Vector3;
  73047. /**
  73048. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73049. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73050. */
  73051. toQuaternion(): Quaternion;
  73052. /**
  73053. * Adds the given vector to the current Vector3
  73054. * @param otherVector defines the second operand
  73055. * @returns the current updated Vector3
  73056. */
  73057. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73058. /**
  73059. * Adds the given coordinates to the current Vector3
  73060. * @param x defines the x coordinate of the operand
  73061. * @param y defines the y coordinate of the operand
  73062. * @param z defines the z coordinate of the operand
  73063. * @returns the current updated Vector3
  73064. */
  73065. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73066. /**
  73067. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73068. * @param otherVector defines the second operand
  73069. * @returns the resulting Vector3
  73070. */
  73071. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73072. /**
  73073. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73074. * @param otherVector defines the second operand
  73075. * @param result defines the Vector3 object where to store the result
  73076. * @returns the current Vector3
  73077. */
  73078. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73079. /**
  73080. * Subtract the given vector from the current Vector3
  73081. * @param otherVector defines the second operand
  73082. * @returns the current updated Vector3
  73083. */
  73084. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73085. /**
  73086. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73087. * @param otherVector defines the second operand
  73088. * @returns the resulting Vector3
  73089. */
  73090. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73091. /**
  73092. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73093. * @param otherVector defines the second operand
  73094. * @param result defines the Vector3 object where to store the result
  73095. * @returns the current Vector3
  73096. */
  73097. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73098. /**
  73099. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73100. * @param x defines the x coordinate of the operand
  73101. * @param y defines the y coordinate of the operand
  73102. * @param z defines the z coordinate of the operand
  73103. * @returns the resulting Vector3
  73104. */
  73105. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73106. /**
  73107. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73108. * @param x defines the x coordinate of the operand
  73109. * @param y defines the y coordinate of the operand
  73110. * @param z defines the z coordinate of the operand
  73111. * @param result defines the Vector3 object where to store the result
  73112. * @returns the current Vector3
  73113. */
  73114. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73115. /**
  73116. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73117. * @returns a new Vector3
  73118. */
  73119. negate(): Vector3;
  73120. /**
  73121. * Negate this vector in place
  73122. * @returns this
  73123. */
  73124. negateInPlace(): Vector3;
  73125. /**
  73126. * Multiplies the Vector3 coordinates by the float "scale"
  73127. * @param scale defines the multiplier factor
  73128. * @returns the current updated Vector3
  73129. */
  73130. scaleInPlace(scale: number): Vector3;
  73131. /**
  73132. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73133. * @param scale defines the multiplier factor
  73134. * @returns a new Vector3
  73135. */
  73136. scale(scale: number): Vector3;
  73137. /**
  73138. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73139. * @param scale defines the multiplier factor
  73140. * @param result defines the Vector3 object where to store the result
  73141. * @returns the current Vector3
  73142. */
  73143. scaleToRef(scale: number, result: Vector3): Vector3;
  73144. /**
  73145. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73146. * @param scale defines the scale factor
  73147. * @param result defines the Vector3 object where to store the result
  73148. * @returns the unmodified current Vector3
  73149. */
  73150. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73151. /**
  73152. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73153. * @param otherVector defines the second operand
  73154. * @returns true if both vectors are equals
  73155. */
  73156. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73157. /**
  73158. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73159. * @param otherVector defines the second operand
  73160. * @param epsilon defines the minimal distance to define values as equals
  73161. * @returns true if both vectors are distant less than epsilon
  73162. */
  73163. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73164. /**
  73165. * Returns true if the current Vector3 coordinates equals the given floats
  73166. * @param x defines the x coordinate of the operand
  73167. * @param y defines the y coordinate of the operand
  73168. * @param z defines the z coordinate of the operand
  73169. * @returns true if both vectors are equals
  73170. */
  73171. equalsToFloats(x: number, y: number, z: number): boolean;
  73172. /**
  73173. * Multiplies the current Vector3 coordinates by the given ones
  73174. * @param otherVector defines the second operand
  73175. * @returns the current updated Vector3
  73176. */
  73177. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73178. /**
  73179. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73180. * @param otherVector defines the second operand
  73181. * @returns the new Vector3
  73182. */
  73183. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73184. /**
  73185. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73186. * @param otherVector defines the second operand
  73187. * @param result defines the Vector3 object where to store the result
  73188. * @returns the current Vector3
  73189. */
  73190. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73191. /**
  73192. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73193. * @param x defines the x coordinate of the operand
  73194. * @param y defines the y coordinate of the operand
  73195. * @param z defines the z coordinate of the operand
  73196. * @returns the new Vector3
  73197. */
  73198. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73199. /**
  73200. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73201. * @param otherVector defines the second operand
  73202. * @returns the new Vector3
  73203. */
  73204. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73205. /**
  73206. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73207. * @param otherVector defines the second operand
  73208. * @param result defines the Vector3 object where to store the result
  73209. * @returns the current Vector3
  73210. */
  73211. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73212. /**
  73213. * Divides the current Vector3 coordinates by the given ones.
  73214. * @param otherVector defines the second operand
  73215. * @returns the current updated Vector3
  73216. */
  73217. divideInPlace(otherVector: Vector3): Vector3;
  73218. /**
  73219. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73220. * @param other defines the second operand
  73221. * @returns the current updated Vector3
  73222. */
  73223. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73224. /**
  73225. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73226. * @param other defines the second operand
  73227. * @returns the current updated Vector3
  73228. */
  73229. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73230. /**
  73231. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73232. * @param x defines the x coordinate of the operand
  73233. * @param y defines the y coordinate of the operand
  73234. * @param z defines the z coordinate of the operand
  73235. * @returns the current updated Vector3
  73236. */
  73237. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73238. /**
  73239. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73240. * @param x defines the x coordinate of the operand
  73241. * @param y defines the y coordinate of the operand
  73242. * @param z defines the z coordinate of the operand
  73243. * @returns the current updated Vector3
  73244. */
  73245. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73246. /**
  73247. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73248. * Check if is non uniform within a certain amount of decimal places to account for this
  73249. * @param epsilon the amount the values can differ
  73250. * @returns if the the vector is non uniform to a certain number of decimal places
  73251. */
  73252. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73253. /**
  73254. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73255. */
  73256. get isNonUniform(): boolean;
  73257. /**
  73258. * Gets a new Vector3 from current Vector3 floored values
  73259. * @returns a new Vector3
  73260. */
  73261. floor(): Vector3;
  73262. /**
  73263. * Gets a new Vector3 from current Vector3 floored values
  73264. * @returns a new Vector3
  73265. */
  73266. fract(): Vector3;
  73267. /**
  73268. * Gets the length of the Vector3
  73269. * @returns the length of the Vector3
  73270. */
  73271. length(): number;
  73272. /**
  73273. * Gets the squared length of the Vector3
  73274. * @returns squared length of the Vector3
  73275. */
  73276. lengthSquared(): number;
  73277. /**
  73278. * Normalize the current Vector3.
  73279. * Please note that this is an in place operation.
  73280. * @returns the current updated Vector3
  73281. */
  73282. normalize(): Vector3;
  73283. /**
  73284. * Reorders the x y z properties of the vector in place
  73285. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73286. * @returns the current updated vector
  73287. */
  73288. reorderInPlace(order: string): this;
  73289. /**
  73290. * Rotates the vector around 0,0,0 by a quaternion
  73291. * @param quaternion the rotation quaternion
  73292. * @param result vector to store the result
  73293. * @returns the resulting vector
  73294. */
  73295. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73296. /**
  73297. * Rotates a vector around a given point
  73298. * @param quaternion the rotation quaternion
  73299. * @param point the point to rotate around
  73300. * @param result vector to store the result
  73301. * @returns the resulting vector
  73302. */
  73303. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73304. /**
  73305. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73306. * The cross product is then orthogonal to both current and "other"
  73307. * @param other defines the right operand
  73308. * @returns the cross product
  73309. */
  73310. cross(other: Vector3): Vector3;
  73311. /**
  73312. * Normalize the current Vector3 with the given input length.
  73313. * Please note that this is an in place operation.
  73314. * @param len the length of the vector
  73315. * @returns the current updated Vector3
  73316. */
  73317. normalizeFromLength(len: number): Vector3;
  73318. /**
  73319. * Normalize the current Vector3 to a new vector
  73320. * @returns the new Vector3
  73321. */
  73322. normalizeToNew(): Vector3;
  73323. /**
  73324. * Normalize the current Vector3 to the reference
  73325. * @param reference define the Vector3 to update
  73326. * @returns the updated Vector3
  73327. */
  73328. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73329. /**
  73330. * Creates a new Vector3 copied from the current Vector3
  73331. * @returns the new Vector3
  73332. */
  73333. clone(): Vector3;
  73334. /**
  73335. * Copies the given vector coordinates to the current Vector3 ones
  73336. * @param source defines the source Vector3
  73337. * @returns the current updated Vector3
  73338. */
  73339. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73340. /**
  73341. * Copies the given floats to the current Vector3 coordinates
  73342. * @param x defines the x coordinate of the operand
  73343. * @param y defines the y coordinate of the operand
  73344. * @param z defines the z coordinate of the operand
  73345. * @returns the current updated Vector3
  73346. */
  73347. copyFromFloats(x: number, y: number, z: number): Vector3;
  73348. /**
  73349. * Copies the given floats to the current Vector3 coordinates
  73350. * @param x defines the x coordinate of the operand
  73351. * @param y defines the y coordinate of the operand
  73352. * @param z defines the z coordinate of the operand
  73353. * @returns the current updated Vector3
  73354. */
  73355. set(x: number, y: number, z: number): Vector3;
  73356. /**
  73357. * Copies the given float to the current Vector3 coordinates
  73358. * @param v defines the x, y and z coordinates of the operand
  73359. * @returns the current updated Vector3
  73360. */
  73361. setAll(v: number): Vector3;
  73362. /**
  73363. * Get the clip factor between two vectors
  73364. * @param vector0 defines the first operand
  73365. * @param vector1 defines the second operand
  73366. * @param axis defines the axis to use
  73367. * @param size defines the size along the axis
  73368. * @returns the clip factor
  73369. */
  73370. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73371. /**
  73372. * Get angle between two vectors
  73373. * @param vector0 angle between vector0 and vector1
  73374. * @param vector1 angle between vector0 and vector1
  73375. * @param normal direction of the normal
  73376. * @return the angle between vector0 and vector1
  73377. */
  73378. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73379. /**
  73380. * Returns a new Vector3 set from the index "offset" of the given array
  73381. * @param array defines the source array
  73382. * @param offset defines the offset in the source array
  73383. * @returns the new Vector3
  73384. */
  73385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73386. /**
  73387. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73388. * @param array defines the source array
  73389. * @param offset defines the offset in the source array
  73390. * @returns the new Vector3
  73391. * @deprecated Please use FromArray instead.
  73392. */
  73393. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73394. /**
  73395. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73396. * @param array defines the source array
  73397. * @param offset defines the offset in the source array
  73398. * @param result defines the Vector3 where to store the result
  73399. */
  73400. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73401. /**
  73402. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73403. * @param array defines the source array
  73404. * @param offset defines the offset in the source array
  73405. * @param result defines the Vector3 where to store the result
  73406. * @deprecated Please use FromArrayToRef instead.
  73407. */
  73408. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73409. /**
  73410. * Sets the given vector "result" with the given floats.
  73411. * @param x defines the x coordinate of the source
  73412. * @param y defines the y coordinate of the source
  73413. * @param z defines the z coordinate of the source
  73414. * @param result defines the Vector3 where to store the result
  73415. */
  73416. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73417. /**
  73418. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73419. * @returns a new empty Vector3
  73420. */
  73421. static Zero(): Vector3;
  73422. /**
  73423. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73424. * @returns a new unit Vector3
  73425. */
  73426. static One(): Vector3;
  73427. /**
  73428. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73429. * @returns a new up Vector3
  73430. */
  73431. static Up(): Vector3;
  73432. /**
  73433. * Gets a up Vector3 that must not be updated
  73434. */
  73435. static get UpReadOnly(): DeepImmutable<Vector3>;
  73436. /**
  73437. * Gets a zero Vector3 that must not be updated
  73438. */
  73439. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73440. /**
  73441. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73442. * @returns a new down Vector3
  73443. */
  73444. static Down(): Vector3;
  73445. /**
  73446. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73447. * @returns a new forward Vector3
  73448. */
  73449. static Forward(): Vector3;
  73450. /**
  73451. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73452. * @returns a new forward Vector3
  73453. */
  73454. static Backward(): Vector3;
  73455. /**
  73456. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73457. * @returns a new right Vector3
  73458. */
  73459. static Right(): Vector3;
  73460. /**
  73461. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73462. * @returns a new left Vector3
  73463. */
  73464. static Left(): Vector3;
  73465. /**
  73466. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73467. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73468. * @param vector defines the Vector3 to transform
  73469. * @param transformation defines the transformation matrix
  73470. * @returns the transformed Vector3
  73471. */
  73472. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73473. /**
  73474. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73475. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73476. * @param vector defines the Vector3 to transform
  73477. * @param transformation defines the transformation matrix
  73478. * @param result defines the Vector3 where to store the result
  73479. */
  73480. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73481. /**
  73482. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73483. * This method computes tranformed coordinates only, not transformed direction vectors
  73484. * @param x define the x coordinate of the source vector
  73485. * @param y define the y coordinate of the source vector
  73486. * @param z define the z coordinate of the source vector
  73487. * @param transformation defines the transformation matrix
  73488. * @param result defines the Vector3 where to store the result
  73489. */
  73490. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73491. /**
  73492. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73493. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73494. * @param vector defines the Vector3 to transform
  73495. * @param transformation defines the transformation matrix
  73496. * @returns the new Vector3
  73497. */
  73498. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73499. /**
  73500. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73501. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73502. * @param vector defines the Vector3 to transform
  73503. * @param transformation defines the transformation matrix
  73504. * @param result defines the Vector3 where to store the result
  73505. */
  73506. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73507. /**
  73508. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73509. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73510. * @param x define the x coordinate of the source vector
  73511. * @param y define the y coordinate of the source vector
  73512. * @param z define the z coordinate of the source vector
  73513. * @param transformation defines the transformation matrix
  73514. * @param result defines the Vector3 where to store the result
  73515. */
  73516. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73517. /**
  73518. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73519. * @param value1 defines the first control point
  73520. * @param value2 defines the second control point
  73521. * @param value3 defines the third control point
  73522. * @param value4 defines the fourth control point
  73523. * @param amount defines the amount on the spline to use
  73524. * @returns the new Vector3
  73525. */
  73526. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73527. /**
  73528. * 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"
  73529. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73530. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73531. * @param value defines the current value
  73532. * @param min defines the lower range value
  73533. * @param max defines the upper range value
  73534. * @returns the new Vector3
  73535. */
  73536. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73537. /**
  73538. * 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"
  73539. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73540. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73541. * @param value defines the current value
  73542. * @param min defines the lower range value
  73543. * @param max defines the upper range value
  73544. * @param result defines the Vector3 where to store the result
  73545. */
  73546. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73547. /**
  73548. * Checks if a given vector is inside a specific range
  73549. * @param v defines the vector to test
  73550. * @param min defines the minimum range
  73551. * @param max defines the maximum range
  73552. */
  73553. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73554. /**
  73555. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73556. * @param value1 defines the first control point
  73557. * @param tangent1 defines the first tangent vector
  73558. * @param value2 defines the second control point
  73559. * @param tangent2 defines the second tangent vector
  73560. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73561. * @returns the new Vector3
  73562. */
  73563. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73564. /**
  73565. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73566. * @param start defines the start value
  73567. * @param end defines the end value
  73568. * @param amount max defines amount between both (between 0 and 1)
  73569. * @returns the new Vector3
  73570. */
  73571. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73572. /**
  73573. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73574. * @param start defines the start value
  73575. * @param end defines the end value
  73576. * @param amount max defines amount between both (between 0 and 1)
  73577. * @param result defines the Vector3 where to store the result
  73578. */
  73579. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73580. /**
  73581. * Returns the dot product (float) between the vectors "left" and "right"
  73582. * @param left defines the left operand
  73583. * @param right defines the right operand
  73584. * @returns the dot product
  73585. */
  73586. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73587. /**
  73588. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73589. * The cross product is then orthogonal to both "left" and "right"
  73590. * @param left defines the left operand
  73591. * @param right defines the right operand
  73592. * @returns the cross product
  73593. */
  73594. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73595. /**
  73596. * Sets the given vector "result" with the cross product of "left" and "right"
  73597. * The cross product is then orthogonal to both "left" and "right"
  73598. * @param left defines the left operand
  73599. * @param right defines the right operand
  73600. * @param result defines the Vector3 where to store the result
  73601. */
  73602. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73603. /**
  73604. * Returns a new Vector3 as the normalization of the given vector
  73605. * @param vector defines the Vector3 to normalize
  73606. * @returns the new Vector3
  73607. */
  73608. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73609. /**
  73610. * Sets the given vector "result" with the normalization of the given first vector
  73611. * @param vector defines the Vector3 to normalize
  73612. * @param result defines the Vector3 where to store the result
  73613. */
  73614. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73615. /**
  73616. * Project a Vector3 onto screen space
  73617. * @param vector defines the Vector3 to project
  73618. * @param world defines the world matrix to use
  73619. * @param transform defines the transform (view x projection) matrix to use
  73620. * @param viewport defines the screen viewport to use
  73621. * @returns the new Vector3
  73622. */
  73623. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73624. /** @hidden */
  73625. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73626. /**
  73627. * Unproject from screen space to object space
  73628. * @param source defines the screen space Vector3 to use
  73629. * @param viewportWidth defines the current width of the viewport
  73630. * @param viewportHeight defines the current height of the viewport
  73631. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73632. * @param transform defines the transform (view x projection) matrix to use
  73633. * @returns the new Vector3
  73634. */
  73635. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73636. /**
  73637. * Unproject from screen space to object space
  73638. * @param source defines the screen space Vector3 to use
  73639. * @param viewportWidth defines the current width of the viewport
  73640. * @param viewportHeight defines the current height of the viewport
  73641. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73642. * @param view defines the view matrix to use
  73643. * @param projection defines the projection matrix to use
  73644. * @returns the new Vector3
  73645. */
  73646. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73647. /**
  73648. * Unproject from screen space to object space
  73649. * @param source defines the screen space Vector3 to use
  73650. * @param viewportWidth defines the current width of the viewport
  73651. * @param viewportHeight defines the current height of the viewport
  73652. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73653. * @param view defines the view matrix to use
  73654. * @param projection defines the projection matrix to use
  73655. * @param result defines the Vector3 where to store the result
  73656. */
  73657. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73658. /**
  73659. * Unproject from screen space to object space
  73660. * @param sourceX defines the screen space x coordinate to use
  73661. * @param sourceY defines the screen space y coordinate to use
  73662. * @param sourceZ defines the screen space z coordinate to use
  73663. * @param viewportWidth defines the current width of the viewport
  73664. * @param viewportHeight defines the current height of the viewport
  73665. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73666. * @param view defines the view matrix to use
  73667. * @param projection defines the projection matrix to use
  73668. * @param result defines the Vector3 where to store the result
  73669. */
  73670. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73671. /**
  73672. * Gets the minimal coordinate values between two Vector3
  73673. * @param left defines the first operand
  73674. * @param right defines the second operand
  73675. * @returns the new Vector3
  73676. */
  73677. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73678. /**
  73679. * Gets the maximal coordinate values between two Vector3
  73680. * @param left defines the first operand
  73681. * @param right defines the second operand
  73682. * @returns the new Vector3
  73683. */
  73684. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73685. /**
  73686. * Returns the distance between the vectors "value1" and "value2"
  73687. * @param value1 defines the first operand
  73688. * @param value2 defines the second operand
  73689. * @returns the distance
  73690. */
  73691. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73692. /**
  73693. * Returns the squared distance between the vectors "value1" and "value2"
  73694. * @param value1 defines the first operand
  73695. * @param value2 defines the second operand
  73696. * @returns the squared distance
  73697. */
  73698. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73699. /**
  73700. * Returns a new Vector3 located at the center between "value1" and "value2"
  73701. * @param value1 defines the first operand
  73702. * @param value2 defines the second operand
  73703. * @returns the new Vector3
  73704. */
  73705. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73706. /**
  73707. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73708. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73709. * to something in order to rotate it from its local system to the given target system
  73710. * Note: axis1, axis2 and axis3 are normalized during this operation
  73711. * @param axis1 defines the first axis
  73712. * @param axis2 defines the second axis
  73713. * @param axis3 defines the third axis
  73714. * @returns a new Vector3
  73715. */
  73716. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73717. /**
  73718. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73719. * @param axis1 defines the first axis
  73720. * @param axis2 defines the second axis
  73721. * @param axis3 defines the third axis
  73722. * @param ref defines the Vector3 where to store the result
  73723. */
  73724. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73725. }
  73726. /**
  73727. * Vector4 class created for EulerAngle class conversion to Quaternion
  73728. */
  73729. export class Vector4 {
  73730. /** x value of the vector */
  73731. x: number;
  73732. /** y value of the vector */
  73733. y: number;
  73734. /** z value of the vector */
  73735. z: number;
  73736. /** w value of the vector */
  73737. w: number;
  73738. /**
  73739. * Creates a Vector4 object from the given floats.
  73740. * @param x x value of the vector
  73741. * @param y y value of the vector
  73742. * @param z z value of the vector
  73743. * @param w w value of the vector
  73744. */
  73745. constructor(
  73746. /** x value of the vector */
  73747. x: number,
  73748. /** y value of the vector */
  73749. y: number,
  73750. /** z value of the vector */
  73751. z: number,
  73752. /** w value of the vector */
  73753. w: number);
  73754. /**
  73755. * Returns the string with the Vector4 coordinates.
  73756. * @returns a string containing all the vector values
  73757. */
  73758. toString(): string;
  73759. /**
  73760. * Returns the string "Vector4".
  73761. * @returns "Vector4"
  73762. */
  73763. getClassName(): string;
  73764. /**
  73765. * Returns the Vector4 hash code.
  73766. * @returns a unique hash code
  73767. */
  73768. getHashCode(): number;
  73769. /**
  73770. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73771. * @returns the resulting array
  73772. */
  73773. asArray(): number[];
  73774. /**
  73775. * Populates the given array from the given index with the Vector4 coordinates.
  73776. * @param array array to populate
  73777. * @param index index of the array to start at (default: 0)
  73778. * @returns the Vector4.
  73779. */
  73780. toArray(array: FloatArray, index?: number): Vector4;
  73781. /**
  73782. * Adds the given vector to the current Vector4.
  73783. * @param otherVector the vector to add
  73784. * @returns the updated Vector4.
  73785. */
  73786. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73787. /**
  73788. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73789. * @param otherVector the vector to add
  73790. * @returns the resulting vector
  73791. */
  73792. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73793. /**
  73794. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73795. * @param otherVector the vector to add
  73796. * @param result the vector to store the result
  73797. * @returns the current Vector4.
  73798. */
  73799. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73800. /**
  73801. * Subtract in place the given vector from the current Vector4.
  73802. * @param otherVector the vector to subtract
  73803. * @returns the updated Vector4.
  73804. */
  73805. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73806. /**
  73807. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73808. * @param otherVector the vector to add
  73809. * @returns the new vector with the result
  73810. */
  73811. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73812. /**
  73813. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73814. * @param otherVector the vector to subtract
  73815. * @param result the vector to store the result
  73816. * @returns the current Vector4.
  73817. */
  73818. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73819. /**
  73820. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73821. */
  73822. /**
  73823. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73824. * @param x value to subtract
  73825. * @param y value to subtract
  73826. * @param z value to subtract
  73827. * @param w value to subtract
  73828. * @returns new vector containing the result
  73829. */
  73830. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73831. /**
  73832. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73833. * @param x value to subtract
  73834. * @param y value to subtract
  73835. * @param z value to subtract
  73836. * @param w value to subtract
  73837. * @param result the vector to store the result in
  73838. * @returns the current Vector4.
  73839. */
  73840. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73841. /**
  73842. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73843. * @returns a new vector with the negated values
  73844. */
  73845. negate(): Vector4;
  73846. /**
  73847. * Multiplies the current Vector4 coordinates by scale (float).
  73848. * @param scale the number to scale with
  73849. * @returns the updated Vector4.
  73850. */
  73851. scaleInPlace(scale: number): Vector4;
  73852. /**
  73853. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73854. * @param scale the number to scale with
  73855. * @returns a new vector with the result
  73856. */
  73857. scale(scale: number): Vector4;
  73858. /**
  73859. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73860. * @param scale the number to scale with
  73861. * @param result a vector to store the result in
  73862. * @returns the current Vector4.
  73863. */
  73864. scaleToRef(scale: number, result: Vector4): Vector4;
  73865. /**
  73866. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73867. * @param scale defines the scale factor
  73868. * @param result defines the Vector4 object where to store the result
  73869. * @returns the unmodified current Vector4
  73870. */
  73871. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73872. /**
  73873. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73874. * @param otherVector the vector to compare against
  73875. * @returns true if they are equal
  73876. */
  73877. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73878. /**
  73879. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73880. * @param otherVector vector to compare against
  73881. * @param epsilon (Default: very small number)
  73882. * @returns true if they are equal
  73883. */
  73884. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73885. /**
  73886. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73887. * @param x x value to compare against
  73888. * @param y y value to compare against
  73889. * @param z z value to compare against
  73890. * @param w w value to compare against
  73891. * @returns true if equal
  73892. */
  73893. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73894. /**
  73895. * Multiplies in place the current Vector4 by the given one.
  73896. * @param otherVector vector to multiple with
  73897. * @returns the updated Vector4.
  73898. */
  73899. multiplyInPlace(otherVector: Vector4): Vector4;
  73900. /**
  73901. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73902. * @param otherVector vector to multiple with
  73903. * @returns resulting new vector
  73904. */
  73905. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73906. /**
  73907. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73908. * @param otherVector vector to multiple with
  73909. * @param result vector to store the result
  73910. * @returns the current Vector4.
  73911. */
  73912. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73913. /**
  73914. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73915. * @param x x value multiply with
  73916. * @param y y value multiply with
  73917. * @param z z value multiply with
  73918. * @param w w value multiply with
  73919. * @returns resulting new vector
  73920. */
  73921. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73922. /**
  73923. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73924. * @param otherVector vector to devide with
  73925. * @returns resulting new vector
  73926. */
  73927. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73928. /**
  73929. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73930. * @param otherVector vector to devide with
  73931. * @param result vector to store the result
  73932. * @returns the current Vector4.
  73933. */
  73934. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73935. /**
  73936. * Divides the current Vector3 coordinates by the given ones.
  73937. * @param otherVector vector to devide with
  73938. * @returns the updated Vector3.
  73939. */
  73940. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73941. /**
  73942. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73943. * @param other defines the second operand
  73944. * @returns the current updated Vector4
  73945. */
  73946. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73947. /**
  73948. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73949. * @param other defines the second operand
  73950. * @returns the current updated Vector4
  73951. */
  73952. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73953. /**
  73954. * Gets a new Vector4 from current Vector4 floored values
  73955. * @returns a new Vector4
  73956. */
  73957. floor(): Vector4;
  73958. /**
  73959. * Gets a new Vector4 from current Vector3 floored values
  73960. * @returns a new Vector4
  73961. */
  73962. fract(): Vector4;
  73963. /**
  73964. * Returns the Vector4 length (float).
  73965. * @returns the length
  73966. */
  73967. length(): number;
  73968. /**
  73969. * Returns the Vector4 squared length (float).
  73970. * @returns the length squared
  73971. */
  73972. lengthSquared(): number;
  73973. /**
  73974. * Normalizes in place the Vector4.
  73975. * @returns the updated Vector4.
  73976. */
  73977. normalize(): Vector4;
  73978. /**
  73979. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73980. * @returns this converted to a new vector3
  73981. */
  73982. toVector3(): Vector3;
  73983. /**
  73984. * Returns a new Vector4 copied from the current one.
  73985. * @returns the new cloned vector
  73986. */
  73987. clone(): Vector4;
  73988. /**
  73989. * Updates the current Vector4 with the given one coordinates.
  73990. * @param source the source vector to copy from
  73991. * @returns the updated Vector4.
  73992. */
  73993. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73994. /**
  73995. * Updates the current Vector4 coordinates with the given floats.
  73996. * @param x float to copy from
  73997. * @param y float to copy from
  73998. * @param z float to copy from
  73999. * @param w float to copy from
  74000. * @returns the updated Vector4.
  74001. */
  74002. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74003. /**
  74004. * Updates the current Vector4 coordinates with the given floats.
  74005. * @param x float to set from
  74006. * @param y float to set from
  74007. * @param z float to set from
  74008. * @param w float to set from
  74009. * @returns the updated Vector4.
  74010. */
  74011. set(x: number, y: number, z: number, w: number): Vector4;
  74012. /**
  74013. * Copies the given float to the current Vector3 coordinates
  74014. * @param v defines the x, y, z and w coordinates of the operand
  74015. * @returns the current updated Vector3
  74016. */
  74017. setAll(v: number): Vector4;
  74018. /**
  74019. * Returns a new Vector4 set from the starting index of the given array.
  74020. * @param array the array to pull values from
  74021. * @param offset the offset into the array to start at
  74022. * @returns the new vector
  74023. */
  74024. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  74025. /**
  74026. * Updates the given vector "result" from the starting index of the given array.
  74027. * @param array the array to pull values from
  74028. * @param offset the offset into the array to start at
  74029. * @param result the vector to store the result in
  74030. */
  74031. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  74032. /**
  74033. * Updates the given vector "result" from the starting index of the given Float32Array.
  74034. * @param array the array to pull values from
  74035. * @param offset the offset into the array to start at
  74036. * @param result the vector to store the result in
  74037. */
  74038. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  74039. /**
  74040. * Updates the given vector "result" coordinates from the given floats.
  74041. * @param x float to set from
  74042. * @param y float to set from
  74043. * @param z float to set from
  74044. * @param w float to set from
  74045. * @param result the vector to the floats in
  74046. */
  74047. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74048. /**
  74049. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74050. * @returns the new vector
  74051. */
  74052. static Zero(): Vector4;
  74053. /**
  74054. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74055. * @returns the new vector
  74056. */
  74057. static One(): Vector4;
  74058. /**
  74059. * Returns a new normalized Vector4 from the given one.
  74060. * @param vector the vector to normalize
  74061. * @returns the vector
  74062. */
  74063. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74064. /**
  74065. * Updates the given vector "result" from the normalization of the given one.
  74066. * @param vector the vector to normalize
  74067. * @param result the vector to store the result in
  74068. */
  74069. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74070. /**
  74071. * Returns a vector with the minimum values from the left and right vectors
  74072. * @param left left vector to minimize
  74073. * @param right right vector to minimize
  74074. * @returns a new vector with the minimum of the left and right vector values
  74075. */
  74076. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74077. /**
  74078. * Returns a vector with the maximum values from the left and right vectors
  74079. * @param left left vector to maximize
  74080. * @param right right vector to maximize
  74081. * @returns a new vector with the maximum of the left and right vector values
  74082. */
  74083. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74084. /**
  74085. * Returns the distance (float) between the vectors "value1" and "value2".
  74086. * @param value1 value to calulate the distance between
  74087. * @param value2 value to calulate the distance between
  74088. * @return the distance between the two vectors
  74089. */
  74090. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74091. /**
  74092. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74093. * @param value1 value to calulate the distance between
  74094. * @param value2 value to calulate the distance between
  74095. * @return the distance between the two vectors squared
  74096. */
  74097. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74098. /**
  74099. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74100. * @param value1 value to calulate the center between
  74101. * @param value2 value to calulate the center between
  74102. * @return the center between the two vectors
  74103. */
  74104. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74105. /**
  74106. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74107. * This methods computes transformed normalized direction vectors only.
  74108. * @param vector the vector to transform
  74109. * @param transformation the transformation matrix to apply
  74110. * @returns the new vector
  74111. */
  74112. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74113. /**
  74114. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74115. * This methods computes transformed normalized direction vectors only.
  74116. * @param vector the vector to transform
  74117. * @param transformation the transformation matrix to apply
  74118. * @param result the vector to store the result in
  74119. */
  74120. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74121. /**
  74122. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74123. * This methods computes transformed normalized direction vectors only.
  74124. * @param x value to transform
  74125. * @param y value to transform
  74126. * @param z value to transform
  74127. * @param w value to transform
  74128. * @param transformation the transformation matrix to apply
  74129. * @param result the vector to store the results in
  74130. */
  74131. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74132. /**
  74133. * Creates a new Vector4 from a Vector3
  74134. * @param source defines the source data
  74135. * @param w defines the 4th component (default is 0)
  74136. * @returns a new Vector4
  74137. */
  74138. static FromVector3(source: Vector3, w?: number): Vector4;
  74139. }
  74140. /**
  74141. * Class used to store quaternion data
  74142. * @see https://en.wikipedia.org/wiki/Quaternion
  74143. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74144. */
  74145. export class Quaternion {
  74146. /** defines the first component (0 by default) */
  74147. x: number;
  74148. /** defines the second component (0 by default) */
  74149. y: number;
  74150. /** defines the third component (0 by default) */
  74151. z: number;
  74152. /** defines the fourth component (1.0 by default) */
  74153. w: number;
  74154. /**
  74155. * Creates a new Quaternion from the given floats
  74156. * @param x defines the first component (0 by default)
  74157. * @param y defines the second component (0 by default)
  74158. * @param z defines the third component (0 by default)
  74159. * @param w defines the fourth component (1.0 by default)
  74160. */
  74161. constructor(
  74162. /** defines the first component (0 by default) */
  74163. x?: number,
  74164. /** defines the second component (0 by default) */
  74165. y?: number,
  74166. /** defines the third component (0 by default) */
  74167. z?: number,
  74168. /** defines the fourth component (1.0 by default) */
  74169. w?: number);
  74170. /**
  74171. * Gets a string representation for the current quaternion
  74172. * @returns a string with the Quaternion coordinates
  74173. */
  74174. toString(): string;
  74175. /**
  74176. * Gets the class name of the quaternion
  74177. * @returns the string "Quaternion"
  74178. */
  74179. getClassName(): string;
  74180. /**
  74181. * Gets a hash code for this quaternion
  74182. * @returns the quaternion hash code
  74183. */
  74184. getHashCode(): number;
  74185. /**
  74186. * Copy the quaternion to an array
  74187. * @returns a new array populated with 4 elements from the quaternion coordinates
  74188. */
  74189. asArray(): number[];
  74190. /**
  74191. * Check if two quaternions are equals
  74192. * @param otherQuaternion defines the second operand
  74193. * @return true if the current quaternion and the given one coordinates are strictly equals
  74194. */
  74195. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74196. /**
  74197. * Gets a boolean if two quaternions are equals (using an epsilon value)
  74198. * @param otherQuaternion defines the other quaternion
  74199. * @param epsilon defines the minimal distance to consider equality
  74200. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  74201. */
  74202. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  74203. /**
  74204. * Clone the current quaternion
  74205. * @returns a new quaternion copied from the current one
  74206. */
  74207. clone(): Quaternion;
  74208. /**
  74209. * Copy a quaternion to the current one
  74210. * @param other defines the other quaternion
  74211. * @returns the updated current quaternion
  74212. */
  74213. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74214. /**
  74215. * Updates the current quaternion with the given float coordinates
  74216. * @param x defines the x coordinate
  74217. * @param y defines the y coordinate
  74218. * @param z defines the z coordinate
  74219. * @param w defines the w coordinate
  74220. * @returns the updated current quaternion
  74221. */
  74222. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74223. /**
  74224. * Updates the current quaternion from the given float coordinates
  74225. * @param x defines the x coordinate
  74226. * @param y defines the y coordinate
  74227. * @param z defines the z coordinate
  74228. * @param w defines the w coordinate
  74229. * @returns the updated current quaternion
  74230. */
  74231. set(x: number, y: number, z: number, w: number): Quaternion;
  74232. /**
  74233. * Adds two quaternions
  74234. * @param other defines the second operand
  74235. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74236. */
  74237. add(other: DeepImmutable<Quaternion>): Quaternion;
  74238. /**
  74239. * Add a quaternion to the current one
  74240. * @param other defines the quaternion to add
  74241. * @returns the current quaternion
  74242. */
  74243. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74244. /**
  74245. * Subtract two quaternions
  74246. * @param other defines the second operand
  74247. * @returns a new quaternion as the subtraction result of the given one from the current one
  74248. */
  74249. subtract(other: Quaternion): Quaternion;
  74250. /**
  74251. * Multiplies the current quaternion by a scale factor
  74252. * @param value defines the scale factor
  74253. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74254. */
  74255. scale(value: number): Quaternion;
  74256. /**
  74257. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74258. * @param scale defines the scale factor
  74259. * @param result defines the Quaternion object where to store the result
  74260. * @returns the unmodified current quaternion
  74261. */
  74262. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74263. /**
  74264. * Multiplies in place the current quaternion by a scale factor
  74265. * @param value defines the scale factor
  74266. * @returns the current modified quaternion
  74267. */
  74268. scaleInPlace(value: number): Quaternion;
  74269. /**
  74270. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74271. * @param scale defines the scale factor
  74272. * @param result defines the Quaternion object where to store the result
  74273. * @returns the unmodified current quaternion
  74274. */
  74275. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74276. /**
  74277. * Multiplies two quaternions
  74278. * @param q1 defines the second operand
  74279. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74280. */
  74281. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74282. /**
  74283. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74284. * @param q1 defines the second operand
  74285. * @param result defines the target quaternion
  74286. * @returns the current quaternion
  74287. */
  74288. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74289. /**
  74290. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74291. * @param q1 defines the second operand
  74292. * @returns the currentupdated quaternion
  74293. */
  74294. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74295. /**
  74296. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74297. * @param ref defines the target quaternion
  74298. * @returns the current quaternion
  74299. */
  74300. conjugateToRef(ref: Quaternion): Quaternion;
  74301. /**
  74302. * Conjugates in place (1-q) the current quaternion
  74303. * @returns the current updated quaternion
  74304. */
  74305. conjugateInPlace(): Quaternion;
  74306. /**
  74307. * Conjugates in place (1-q) the current quaternion
  74308. * @returns a new quaternion
  74309. */
  74310. conjugate(): Quaternion;
  74311. /**
  74312. * Gets length of current quaternion
  74313. * @returns the quaternion length (float)
  74314. */
  74315. length(): number;
  74316. /**
  74317. * Normalize in place the current quaternion
  74318. * @returns the current updated quaternion
  74319. */
  74320. normalize(): Quaternion;
  74321. /**
  74322. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74323. * @param order is a reserved parameter and is ignore for now
  74324. * @returns a new Vector3 containing the Euler angles
  74325. */
  74326. toEulerAngles(order?: string): Vector3;
  74327. /**
  74328. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74329. * @param result defines the vector which will be filled with the Euler angles
  74330. * @param order is a reserved parameter and is ignore for now
  74331. * @returns the current unchanged quaternion
  74332. */
  74333. toEulerAnglesToRef(result: Vector3): Quaternion;
  74334. /**
  74335. * Updates the given rotation matrix with the current quaternion values
  74336. * @param result defines the target matrix
  74337. * @returns the current unchanged quaternion
  74338. */
  74339. toRotationMatrix(result: Matrix): Quaternion;
  74340. /**
  74341. * Updates the current quaternion from the given rotation matrix values
  74342. * @param matrix defines the source matrix
  74343. * @returns the current updated quaternion
  74344. */
  74345. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74346. /**
  74347. * Creates a new quaternion from a rotation matrix
  74348. * @param matrix defines the source matrix
  74349. * @returns a new quaternion created from the given rotation matrix values
  74350. */
  74351. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74352. /**
  74353. * Updates the given quaternion with the given rotation matrix values
  74354. * @param matrix defines the source matrix
  74355. * @param result defines the target quaternion
  74356. */
  74357. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74358. /**
  74359. * Returns the dot product (float) between the quaternions "left" and "right"
  74360. * @param left defines the left operand
  74361. * @param right defines the right operand
  74362. * @returns the dot product
  74363. */
  74364. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74365. /**
  74366. * Checks if the two quaternions are close to each other
  74367. * @param quat0 defines the first quaternion to check
  74368. * @param quat1 defines the second quaternion to check
  74369. * @returns true if the two quaternions are close to each other
  74370. */
  74371. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74372. /**
  74373. * Creates an empty quaternion
  74374. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74375. */
  74376. static Zero(): Quaternion;
  74377. /**
  74378. * Inverse a given quaternion
  74379. * @param q defines the source quaternion
  74380. * @returns a new quaternion as the inverted current quaternion
  74381. */
  74382. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74383. /**
  74384. * Inverse a given quaternion
  74385. * @param q defines the source quaternion
  74386. * @param result the quaternion the result will be stored in
  74387. * @returns the result quaternion
  74388. */
  74389. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74390. /**
  74391. * Creates an identity quaternion
  74392. * @returns the identity quaternion
  74393. */
  74394. static Identity(): Quaternion;
  74395. /**
  74396. * Gets a boolean indicating if the given quaternion is identity
  74397. * @param quaternion defines the quaternion to check
  74398. * @returns true if the quaternion is identity
  74399. */
  74400. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74401. /**
  74402. * Creates a quaternion from a rotation around an axis
  74403. * @param axis defines the axis to use
  74404. * @param angle defines the angle to use
  74405. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74406. */
  74407. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74408. /**
  74409. * Creates a rotation around an axis and stores it into the given quaternion
  74410. * @param axis defines the axis to use
  74411. * @param angle defines the angle to use
  74412. * @param result defines the target quaternion
  74413. * @returns the target quaternion
  74414. */
  74415. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74416. /**
  74417. * Creates a new quaternion from data stored into an array
  74418. * @param array defines the data source
  74419. * @param offset defines the offset in the source array where the data starts
  74420. * @returns a new quaternion
  74421. */
  74422. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74423. /**
  74424. * Create a quaternion from Euler rotation angles
  74425. * @param x Pitch
  74426. * @param y Yaw
  74427. * @param z Roll
  74428. * @returns the new Quaternion
  74429. */
  74430. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74431. /**
  74432. * Updates a quaternion from Euler rotation angles
  74433. * @param x Pitch
  74434. * @param y Yaw
  74435. * @param z Roll
  74436. * @param result the quaternion to store the result
  74437. * @returns the updated quaternion
  74438. */
  74439. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74440. /**
  74441. * Create a quaternion from Euler rotation vector
  74442. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74443. * @returns the new Quaternion
  74444. */
  74445. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74446. /**
  74447. * Updates a quaternion from Euler rotation vector
  74448. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74449. * @param result the quaternion to store the result
  74450. * @returns the updated quaternion
  74451. */
  74452. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74453. /**
  74454. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74455. * @param yaw defines the rotation around Y axis
  74456. * @param pitch defines the rotation around X axis
  74457. * @param roll defines the rotation around Z axis
  74458. * @returns the new quaternion
  74459. */
  74460. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74461. /**
  74462. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74463. * @param yaw defines the rotation around Y axis
  74464. * @param pitch defines the rotation around X axis
  74465. * @param roll defines the rotation around Z axis
  74466. * @param result defines the target quaternion
  74467. */
  74468. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74469. /**
  74470. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74471. * @param alpha defines the rotation around first axis
  74472. * @param beta defines the rotation around second axis
  74473. * @param gamma defines the rotation around third axis
  74474. * @returns the new quaternion
  74475. */
  74476. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74477. /**
  74478. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74479. * @param alpha defines the rotation around first axis
  74480. * @param beta defines the rotation around second axis
  74481. * @param gamma defines the rotation around third axis
  74482. * @param result defines the target quaternion
  74483. */
  74484. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74485. /**
  74486. * 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)
  74487. * @param axis1 defines the first axis
  74488. * @param axis2 defines the second axis
  74489. * @param axis3 defines the third axis
  74490. * @returns the new quaternion
  74491. */
  74492. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74493. /**
  74494. * 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
  74495. * @param axis1 defines the first axis
  74496. * @param axis2 defines the second axis
  74497. * @param axis3 defines the third axis
  74498. * @param ref defines the target quaternion
  74499. */
  74500. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74501. /**
  74502. * Interpolates between two quaternions
  74503. * @param left defines first quaternion
  74504. * @param right defines second quaternion
  74505. * @param amount defines the gradient to use
  74506. * @returns the new interpolated quaternion
  74507. */
  74508. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74509. /**
  74510. * Interpolates between two quaternions and stores it into a target quaternion
  74511. * @param left defines first quaternion
  74512. * @param right defines second quaternion
  74513. * @param amount defines the gradient to use
  74514. * @param result defines the target quaternion
  74515. */
  74516. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74517. /**
  74518. * Interpolate between two quaternions using Hermite interpolation
  74519. * @param value1 defines first quaternion
  74520. * @param tangent1 defines the incoming tangent
  74521. * @param value2 defines second quaternion
  74522. * @param tangent2 defines the outgoing tangent
  74523. * @param amount defines the target quaternion
  74524. * @returns the new interpolated quaternion
  74525. */
  74526. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74527. }
  74528. /**
  74529. * Class used to store matrix data (4x4)
  74530. */
  74531. export class Matrix {
  74532. private static _updateFlagSeed;
  74533. private static _identityReadOnly;
  74534. private _isIdentity;
  74535. private _isIdentityDirty;
  74536. private _isIdentity3x2;
  74537. private _isIdentity3x2Dirty;
  74538. /**
  74539. * Gets the update flag of the matrix which is an unique number for the matrix.
  74540. * It will be incremented every time the matrix data change.
  74541. * You can use it to speed the comparison between two versions of the same matrix.
  74542. */
  74543. updateFlag: number;
  74544. private readonly _m;
  74545. /**
  74546. * Gets the internal data of the matrix
  74547. */
  74548. get m(): DeepImmutable<Float32Array>;
  74549. /** @hidden */
  74550. _markAsUpdated(): void;
  74551. /** @hidden */
  74552. private _updateIdentityStatus;
  74553. /**
  74554. * Creates an empty matrix (filled with zeros)
  74555. */
  74556. constructor();
  74557. /**
  74558. * Check if the current matrix is identity
  74559. * @returns true is the matrix is the identity matrix
  74560. */
  74561. isIdentity(): boolean;
  74562. /**
  74563. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74564. * @returns true is the matrix is the identity matrix
  74565. */
  74566. isIdentityAs3x2(): boolean;
  74567. /**
  74568. * Gets the determinant of the matrix
  74569. * @returns the matrix determinant
  74570. */
  74571. determinant(): number;
  74572. /**
  74573. * Returns the matrix as a Float32Array
  74574. * @returns the matrix underlying array
  74575. */
  74576. toArray(): DeepImmutable<Float32Array>;
  74577. /**
  74578. * Returns the matrix as a Float32Array
  74579. * @returns the matrix underlying array.
  74580. */
  74581. asArray(): DeepImmutable<Float32Array>;
  74582. /**
  74583. * Inverts the current matrix in place
  74584. * @returns the current inverted matrix
  74585. */
  74586. invert(): Matrix;
  74587. /**
  74588. * Sets all the matrix elements to zero
  74589. * @returns the current matrix
  74590. */
  74591. reset(): Matrix;
  74592. /**
  74593. * Adds the current matrix with a second one
  74594. * @param other defines the matrix to add
  74595. * @returns a new matrix as the addition of the current matrix and the given one
  74596. */
  74597. add(other: DeepImmutable<Matrix>): Matrix;
  74598. /**
  74599. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74600. * @param other defines the matrix to add
  74601. * @param result defines the target matrix
  74602. * @returns the current matrix
  74603. */
  74604. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74605. /**
  74606. * Adds in place the given matrix to the current matrix
  74607. * @param other defines the second operand
  74608. * @returns the current updated matrix
  74609. */
  74610. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74611. /**
  74612. * Sets the given matrix to the current inverted Matrix
  74613. * @param other defines the target matrix
  74614. * @returns the unmodified current matrix
  74615. */
  74616. invertToRef(other: Matrix): Matrix;
  74617. /**
  74618. * add a value at the specified position in the current Matrix
  74619. * @param index the index of the value within the matrix. between 0 and 15.
  74620. * @param value the value to be added
  74621. * @returns the current updated matrix
  74622. */
  74623. addAtIndex(index: number, value: number): Matrix;
  74624. /**
  74625. * mutiply the specified position in the current Matrix by a value
  74626. * @param index the index of the value within the matrix. between 0 and 15.
  74627. * @param value the value to be added
  74628. * @returns the current updated matrix
  74629. */
  74630. multiplyAtIndex(index: number, value: number): Matrix;
  74631. /**
  74632. * Inserts the translation vector (using 3 floats) in the current matrix
  74633. * @param x defines the 1st component of the translation
  74634. * @param y defines the 2nd component of the translation
  74635. * @param z defines the 3rd component of the translation
  74636. * @returns the current updated matrix
  74637. */
  74638. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74639. /**
  74640. * Adds the translation vector (using 3 floats) in the current matrix
  74641. * @param x defines the 1st component of the translation
  74642. * @param y defines the 2nd component of the translation
  74643. * @param z defines the 3rd component of the translation
  74644. * @returns the current updated matrix
  74645. */
  74646. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74647. /**
  74648. * Inserts the translation vector in the current matrix
  74649. * @param vector3 defines the translation to insert
  74650. * @returns the current updated matrix
  74651. */
  74652. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74653. /**
  74654. * Gets the translation value of the current matrix
  74655. * @returns a new Vector3 as the extracted translation from the matrix
  74656. */
  74657. getTranslation(): Vector3;
  74658. /**
  74659. * Fill a Vector3 with the extracted translation from the matrix
  74660. * @param result defines the Vector3 where to store the translation
  74661. * @returns the current matrix
  74662. */
  74663. getTranslationToRef(result: Vector3): Matrix;
  74664. /**
  74665. * Remove rotation and scaling part from the matrix
  74666. * @returns the updated matrix
  74667. */
  74668. removeRotationAndScaling(): Matrix;
  74669. /**
  74670. * Multiply two matrices
  74671. * @param other defines the second operand
  74672. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74673. */
  74674. multiply(other: DeepImmutable<Matrix>): Matrix;
  74675. /**
  74676. * Copy the current matrix from the given one
  74677. * @param other defines the source matrix
  74678. * @returns the current updated matrix
  74679. */
  74680. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74681. /**
  74682. * Populates the given array from the starting index with the current matrix values
  74683. * @param array defines the target array
  74684. * @param offset defines the offset in the target array where to start storing values
  74685. * @returns the current matrix
  74686. */
  74687. copyToArray(array: Float32Array, offset?: number): Matrix;
  74688. /**
  74689. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74690. * @param other defines the second operand
  74691. * @param result defines the matrix where to store the multiplication
  74692. * @returns the current matrix
  74693. */
  74694. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74695. /**
  74696. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74697. * @param other defines the second operand
  74698. * @param result defines the array where to store the multiplication
  74699. * @param offset defines the offset in the target array where to start storing values
  74700. * @returns the current matrix
  74701. */
  74702. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74703. /**
  74704. * Check equality between this matrix and a second one
  74705. * @param value defines the second matrix to compare
  74706. * @returns true is the current matrix and the given one values are strictly equal
  74707. */
  74708. equals(value: DeepImmutable<Matrix>): boolean;
  74709. /**
  74710. * Clone the current matrix
  74711. * @returns a new matrix from the current matrix
  74712. */
  74713. clone(): Matrix;
  74714. /**
  74715. * Returns the name of the current matrix class
  74716. * @returns the string "Matrix"
  74717. */
  74718. getClassName(): string;
  74719. /**
  74720. * Gets the hash code of the current matrix
  74721. * @returns the hash code
  74722. */
  74723. getHashCode(): number;
  74724. /**
  74725. * Decomposes the current Matrix into a translation, rotation and scaling components
  74726. * @param scale defines the scale vector3 given as a reference to update
  74727. * @param rotation defines the rotation quaternion given as a reference to update
  74728. * @param translation defines the translation vector3 given as a reference to update
  74729. * @returns true if operation was successful
  74730. */
  74731. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74732. /**
  74733. * Gets specific row of the matrix
  74734. * @param index defines the number of the row to get
  74735. * @returns the index-th row of the current matrix as a new Vector4
  74736. */
  74737. getRow(index: number): Nullable<Vector4>;
  74738. /**
  74739. * Sets the index-th row of the current matrix to the vector4 values
  74740. * @param index defines the number of the row to set
  74741. * @param row defines the target vector4
  74742. * @returns the updated current matrix
  74743. */
  74744. setRow(index: number, row: Vector4): Matrix;
  74745. /**
  74746. * Compute the transpose of the matrix
  74747. * @returns the new transposed matrix
  74748. */
  74749. transpose(): Matrix;
  74750. /**
  74751. * Compute the transpose of the matrix and store it in a given matrix
  74752. * @param result defines the target matrix
  74753. * @returns the current matrix
  74754. */
  74755. transposeToRef(result: Matrix): Matrix;
  74756. /**
  74757. * Sets the index-th row of the current matrix with the given 4 x float values
  74758. * @param index defines the row index
  74759. * @param x defines the x component to set
  74760. * @param y defines the y component to set
  74761. * @param z defines the z component to set
  74762. * @param w defines the w component to set
  74763. * @returns the updated current matrix
  74764. */
  74765. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74766. /**
  74767. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74768. * @param scale defines the scale factor
  74769. * @returns a new matrix
  74770. */
  74771. scale(scale: number): Matrix;
  74772. /**
  74773. * Scale the current matrix values by a factor to a given result matrix
  74774. * @param scale defines the scale factor
  74775. * @param result defines the matrix to store the result
  74776. * @returns the current matrix
  74777. */
  74778. scaleToRef(scale: number, result: Matrix): Matrix;
  74779. /**
  74780. * Scale the current matrix values by a factor and add the result to a given matrix
  74781. * @param scale defines the scale factor
  74782. * @param result defines the Matrix to store the result
  74783. * @returns the current matrix
  74784. */
  74785. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74786. /**
  74787. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74788. * @param ref matrix to store the result
  74789. */
  74790. toNormalMatrix(ref: Matrix): void;
  74791. /**
  74792. * Gets only rotation part of the current matrix
  74793. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74794. */
  74795. getRotationMatrix(): Matrix;
  74796. /**
  74797. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74798. * @param result defines the target matrix to store data to
  74799. * @returns the current matrix
  74800. */
  74801. getRotationMatrixToRef(result: Matrix): Matrix;
  74802. /**
  74803. * Toggles model matrix from being right handed to left handed in place and vice versa
  74804. */
  74805. toggleModelMatrixHandInPlace(): void;
  74806. /**
  74807. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74808. */
  74809. toggleProjectionMatrixHandInPlace(): void;
  74810. /**
  74811. * Creates a matrix from an array
  74812. * @param array defines the source array
  74813. * @param offset defines an offset in the source array
  74814. * @returns a new Matrix set from the starting index of the given array
  74815. */
  74816. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74817. /**
  74818. * Copy the content of an array into a given matrix
  74819. * @param array defines the source array
  74820. * @param offset defines an offset in the source array
  74821. * @param result defines the target matrix
  74822. */
  74823. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74824. /**
  74825. * Stores an array into a matrix after having multiplied each component by a given factor
  74826. * @param array defines the source array
  74827. * @param offset defines the offset in the source array
  74828. * @param scale defines the scaling factor
  74829. * @param result defines the target matrix
  74830. */
  74831. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74832. /**
  74833. * Gets an identity matrix that must not be updated
  74834. */
  74835. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74836. /**
  74837. * Stores a list of values (16) inside a given matrix
  74838. * @param initialM11 defines 1st value of 1st row
  74839. * @param initialM12 defines 2nd value of 1st row
  74840. * @param initialM13 defines 3rd value of 1st row
  74841. * @param initialM14 defines 4th value of 1st row
  74842. * @param initialM21 defines 1st value of 2nd row
  74843. * @param initialM22 defines 2nd value of 2nd row
  74844. * @param initialM23 defines 3rd value of 2nd row
  74845. * @param initialM24 defines 4th value of 2nd row
  74846. * @param initialM31 defines 1st value of 3rd row
  74847. * @param initialM32 defines 2nd value of 3rd row
  74848. * @param initialM33 defines 3rd value of 3rd row
  74849. * @param initialM34 defines 4th value of 3rd row
  74850. * @param initialM41 defines 1st value of 4th row
  74851. * @param initialM42 defines 2nd value of 4th row
  74852. * @param initialM43 defines 3rd value of 4th row
  74853. * @param initialM44 defines 4th value of 4th row
  74854. * @param result defines the target matrix
  74855. */
  74856. 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;
  74857. /**
  74858. * Creates new matrix from a list of values (16)
  74859. * @param initialM11 defines 1st value of 1st row
  74860. * @param initialM12 defines 2nd value of 1st row
  74861. * @param initialM13 defines 3rd value of 1st row
  74862. * @param initialM14 defines 4th value of 1st row
  74863. * @param initialM21 defines 1st value of 2nd row
  74864. * @param initialM22 defines 2nd value of 2nd row
  74865. * @param initialM23 defines 3rd value of 2nd row
  74866. * @param initialM24 defines 4th value of 2nd row
  74867. * @param initialM31 defines 1st value of 3rd row
  74868. * @param initialM32 defines 2nd value of 3rd row
  74869. * @param initialM33 defines 3rd value of 3rd row
  74870. * @param initialM34 defines 4th value of 3rd row
  74871. * @param initialM41 defines 1st value of 4th row
  74872. * @param initialM42 defines 2nd value of 4th row
  74873. * @param initialM43 defines 3rd value of 4th row
  74874. * @param initialM44 defines 4th value of 4th row
  74875. * @returns the new matrix
  74876. */
  74877. 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;
  74878. /**
  74879. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74880. * @param scale defines the scale vector3
  74881. * @param rotation defines the rotation quaternion
  74882. * @param translation defines the translation vector3
  74883. * @returns a new matrix
  74884. */
  74885. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74886. /**
  74887. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74888. * @param scale defines the scale vector3
  74889. * @param rotation defines the rotation quaternion
  74890. * @param translation defines the translation vector3
  74891. * @param result defines the target matrix
  74892. */
  74893. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74894. /**
  74895. * Creates a new identity matrix
  74896. * @returns a new identity matrix
  74897. */
  74898. static Identity(): Matrix;
  74899. /**
  74900. * Creates a new identity matrix and stores the result in a given matrix
  74901. * @param result defines the target matrix
  74902. */
  74903. static IdentityToRef(result: Matrix): void;
  74904. /**
  74905. * Creates a new zero matrix
  74906. * @returns a new zero matrix
  74907. */
  74908. static Zero(): Matrix;
  74909. /**
  74910. * Creates a new rotation matrix for "angle" radians around the X axis
  74911. * @param angle defines the angle (in radians) to use
  74912. * @return the new matrix
  74913. */
  74914. static RotationX(angle: number): Matrix;
  74915. /**
  74916. * Creates a new matrix as the invert of a given matrix
  74917. * @param source defines the source matrix
  74918. * @returns the new matrix
  74919. */
  74920. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74921. /**
  74922. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74923. * @param angle defines the angle (in radians) to use
  74924. * @param result defines the target matrix
  74925. */
  74926. static RotationXToRef(angle: number, result: Matrix): void;
  74927. /**
  74928. * Creates a new rotation matrix for "angle" radians around the Y axis
  74929. * @param angle defines the angle (in radians) to use
  74930. * @return the new matrix
  74931. */
  74932. static RotationY(angle: number): Matrix;
  74933. /**
  74934. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74935. * @param angle defines the angle (in radians) to use
  74936. * @param result defines the target matrix
  74937. */
  74938. static RotationYToRef(angle: number, result: Matrix): void;
  74939. /**
  74940. * Creates a new rotation matrix for "angle" radians around the Z axis
  74941. * @param angle defines the angle (in radians) to use
  74942. * @return the new matrix
  74943. */
  74944. static RotationZ(angle: number): Matrix;
  74945. /**
  74946. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74947. * @param angle defines the angle (in radians) to use
  74948. * @param result defines the target matrix
  74949. */
  74950. static RotationZToRef(angle: number, result: Matrix): void;
  74951. /**
  74952. * Creates a new rotation matrix for "angle" radians around the given axis
  74953. * @param axis defines the axis to use
  74954. * @param angle defines the angle (in radians) to use
  74955. * @return the new matrix
  74956. */
  74957. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74958. /**
  74959. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74960. * @param axis defines the axis to use
  74961. * @param angle defines the angle (in radians) to use
  74962. * @param result defines the target matrix
  74963. */
  74964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74965. /**
  74966. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74967. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74968. * @param from defines the vector to align
  74969. * @param to defines the vector to align to
  74970. * @param result defines the target matrix
  74971. */
  74972. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74973. /**
  74974. * Creates a rotation matrix
  74975. * @param yaw defines the yaw angle in radians (Y axis)
  74976. * @param pitch defines the pitch angle in radians (X axis)
  74977. * @param roll defines the roll angle in radians (X axis)
  74978. * @returns the new rotation matrix
  74979. */
  74980. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74981. /**
  74982. * Creates a rotation matrix and stores it in a given matrix
  74983. * @param yaw defines the yaw angle in radians (Y axis)
  74984. * @param pitch defines the pitch angle in radians (X axis)
  74985. * @param roll defines the roll angle in radians (X axis)
  74986. * @param result defines the target matrix
  74987. */
  74988. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74989. /**
  74990. * Creates a scaling matrix
  74991. * @param x defines the scale factor on X axis
  74992. * @param y defines the scale factor on Y axis
  74993. * @param z defines the scale factor on Z axis
  74994. * @returns the new matrix
  74995. */
  74996. static Scaling(x: number, y: number, z: number): Matrix;
  74997. /**
  74998. * Creates a scaling matrix and stores it in a given matrix
  74999. * @param x defines the scale factor on X axis
  75000. * @param y defines the scale factor on Y axis
  75001. * @param z defines the scale factor on Z axis
  75002. * @param result defines the target matrix
  75003. */
  75004. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  75005. /**
  75006. * Creates a translation matrix
  75007. * @param x defines the translation on X axis
  75008. * @param y defines the translation on Y axis
  75009. * @param z defines the translationon Z axis
  75010. * @returns the new matrix
  75011. */
  75012. static Translation(x: number, y: number, z: number): Matrix;
  75013. /**
  75014. * Creates a translation matrix and stores it in a given matrix
  75015. * @param x defines the translation on X axis
  75016. * @param y defines the translation on Y axis
  75017. * @param z defines the translationon Z axis
  75018. * @param result defines the target matrix
  75019. */
  75020. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  75021. /**
  75022. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75023. * @param startValue defines the start value
  75024. * @param endValue defines the end value
  75025. * @param gradient defines the gradient factor
  75026. * @returns the new matrix
  75027. */
  75028. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75029. /**
  75030. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75031. * @param startValue defines the start value
  75032. * @param endValue defines the end value
  75033. * @param gradient defines the gradient factor
  75034. * @param result defines the Matrix object where to store data
  75035. */
  75036. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75037. /**
  75038. * Builds a new matrix whose values are computed by:
  75039. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75040. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75041. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75042. * @param startValue defines the first matrix
  75043. * @param endValue defines the second matrix
  75044. * @param gradient defines the gradient between the two matrices
  75045. * @returns the new matrix
  75046. */
  75047. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75048. /**
  75049. * Update a matrix to values which are computed by:
  75050. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75051. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75052. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75053. * @param startValue defines the first matrix
  75054. * @param endValue defines the second matrix
  75055. * @param gradient defines the gradient between the two matrices
  75056. * @param result defines the target matrix
  75057. */
  75058. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75059. /**
  75060. * 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"
  75061. * This function works in left handed mode
  75062. * @param eye defines the final position of the entity
  75063. * @param target defines where the entity should look at
  75064. * @param up defines the up vector for the entity
  75065. * @returns the new matrix
  75066. */
  75067. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75068. /**
  75069. * 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".
  75070. * This function works in left handed mode
  75071. * @param eye defines the final position of the entity
  75072. * @param target defines where the entity should look at
  75073. * @param up defines the up vector for the entity
  75074. * @param result defines the target matrix
  75075. */
  75076. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75077. /**
  75078. * 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"
  75079. * This function works in right handed mode
  75080. * @param eye defines the final position of the entity
  75081. * @param target defines where the entity should look at
  75082. * @param up defines the up vector for the entity
  75083. * @returns the new matrix
  75084. */
  75085. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75086. /**
  75087. * 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".
  75088. * This function works in right handed mode
  75089. * @param eye defines the final position of the entity
  75090. * @param target defines where the entity should look at
  75091. * @param up defines the up vector for the entity
  75092. * @param result defines the target matrix
  75093. */
  75094. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75095. /**
  75096. * Create a left-handed orthographic projection matrix
  75097. * @param width defines the viewport width
  75098. * @param height defines the viewport height
  75099. * @param znear defines the near clip plane
  75100. * @param zfar defines the far clip plane
  75101. * @returns a new matrix as a left-handed orthographic projection matrix
  75102. */
  75103. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75104. /**
  75105. * Store a left-handed orthographic projection to a given matrix
  75106. * @param width defines the viewport width
  75107. * @param height defines the viewport height
  75108. * @param znear defines the near clip plane
  75109. * @param zfar defines the far clip plane
  75110. * @param result defines the target matrix
  75111. */
  75112. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75113. /**
  75114. * Create a left-handed orthographic projection matrix
  75115. * @param left defines the viewport left coordinate
  75116. * @param right defines the viewport right coordinate
  75117. * @param bottom defines the viewport bottom coordinate
  75118. * @param top defines the viewport top coordinate
  75119. * @param znear defines the near clip plane
  75120. * @param zfar defines the far clip plane
  75121. * @returns a new matrix as a left-handed orthographic projection matrix
  75122. */
  75123. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75124. /**
  75125. * Stores a left-handed orthographic projection into a given matrix
  75126. * @param left defines the viewport left coordinate
  75127. * @param right defines the viewport right coordinate
  75128. * @param bottom defines the viewport bottom coordinate
  75129. * @param top defines the viewport top coordinate
  75130. * @param znear defines the near clip plane
  75131. * @param zfar defines the far clip plane
  75132. * @param result defines the target matrix
  75133. */
  75134. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75135. /**
  75136. * Creates a right-handed orthographic projection matrix
  75137. * @param left defines the viewport left coordinate
  75138. * @param right defines the viewport right coordinate
  75139. * @param bottom defines the viewport bottom coordinate
  75140. * @param top defines the viewport top coordinate
  75141. * @param znear defines the near clip plane
  75142. * @param zfar defines the far clip plane
  75143. * @returns a new matrix as a right-handed orthographic projection matrix
  75144. */
  75145. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75146. /**
  75147. * Stores a right-handed orthographic projection into a given matrix
  75148. * @param left defines the viewport left coordinate
  75149. * @param right defines the viewport right coordinate
  75150. * @param bottom defines the viewport bottom coordinate
  75151. * @param top defines the viewport top coordinate
  75152. * @param znear defines the near clip plane
  75153. * @param zfar defines the far clip plane
  75154. * @param result defines the target matrix
  75155. */
  75156. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75157. /**
  75158. * Creates a left-handed perspective projection matrix
  75159. * @param width defines the viewport width
  75160. * @param height defines the viewport height
  75161. * @param znear defines the near clip plane
  75162. * @param zfar defines the far clip plane
  75163. * @returns a new matrix as a left-handed perspective projection matrix
  75164. */
  75165. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75166. /**
  75167. * Creates a left-handed perspective projection matrix
  75168. * @param fov defines the horizontal field of view
  75169. * @param aspect defines the aspect ratio
  75170. * @param znear defines the near clip plane
  75171. * @param zfar defines the far clip plane
  75172. * @returns a new matrix as a left-handed perspective projection matrix
  75173. */
  75174. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75175. /**
  75176. * Stores a left-handed perspective projection into a given matrix
  75177. * @param fov defines the horizontal field of view
  75178. * @param aspect defines the aspect ratio
  75179. * @param znear defines the near clip plane
  75180. * @param zfar defines the far clip plane
  75181. * @param result defines the target matrix
  75182. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75183. */
  75184. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75185. /**
  75186. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75187. * @param fov defines the horizontal field of view
  75188. * @param aspect defines the aspect ratio
  75189. * @param znear defines the near clip plane
  75190. * @param zfar not used as infinity is used as far clip
  75191. * @param result defines the target matrix
  75192. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75193. */
  75194. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75195. /**
  75196. * Creates a right-handed perspective projection matrix
  75197. * @param fov defines the horizontal field of view
  75198. * @param aspect defines the aspect ratio
  75199. * @param znear defines the near clip plane
  75200. * @param zfar defines the far clip plane
  75201. * @returns a new matrix as a right-handed perspective projection matrix
  75202. */
  75203. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75204. /**
  75205. * Stores a right-handed perspective projection into a given matrix
  75206. * @param fov defines the horizontal field of view
  75207. * @param aspect defines the aspect ratio
  75208. * @param znear defines the near clip plane
  75209. * @param zfar defines the far clip plane
  75210. * @param result defines the target matrix
  75211. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75212. */
  75213. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75214. /**
  75215. * Stores a right-handed perspective projection into a given matrix
  75216. * @param fov defines the horizontal field of view
  75217. * @param aspect defines the aspect ratio
  75218. * @param znear defines the near clip plane
  75219. * @param zfar not used as infinity is used as far clip
  75220. * @param result defines the target matrix
  75221. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75222. */
  75223. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75224. /**
  75225. * Stores a perspective projection for WebVR info a given matrix
  75226. * @param fov defines the field of view
  75227. * @param znear defines the near clip plane
  75228. * @param zfar defines the far clip plane
  75229. * @param result defines the target matrix
  75230. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75231. */
  75232. static PerspectiveFovWebVRToRef(fov: {
  75233. upDegrees: number;
  75234. downDegrees: number;
  75235. leftDegrees: number;
  75236. rightDegrees: number;
  75237. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75238. /**
  75239. * Computes a complete transformation matrix
  75240. * @param viewport defines the viewport to use
  75241. * @param world defines the world matrix
  75242. * @param view defines the view matrix
  75243. * @param projection defines the projection matrix
  75244. * @param zmin defines the near clip plane
  75245. * @param zmax defines the far clip plane
  75246. * @returns the transformation matrix
  75247. */
  75248. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75249. /**
  75250. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75251. * @param matrix defines the matrix to use
  75252. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75253. */
  75254. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75255. /**
  75256. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75257. * @param matrix defines the matrix to use
  75258. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75259. */
  75260. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75261. /**
  75262. * Compute the transpose of a given matrix
  75263. * @param matrix defines the matrix to transpose
  75264. * @returns the new matrix
  75265. */
  75266. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75267. /**
  75268. * Compute the transpose of a matrix and store it in a target matrix
  75269. * @param matrix defines the matrix to transpose
  75270. * @param result defines the target matrix
  75271. */
  75272. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75273. /**
  75274. * Computes a reflection matrix from a plane
  75275. * @param plane defines the reflection plane
  75276. * @returns a new matrix
  75277. */
  75278. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75279. /**
  75280. * Computes a reflection matrix from a plane
  75281. * @param plane defines the reflection plane
  75282. * @param result defines the target matrix
  75283. */
  75284. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75285. /**
  75286. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75287. * @param xaxis defines the value of the 1st axis
  75288. * @param yaxis defines the value of the 2nd axis
  75289. * @param zaxis defines the value of the 3rd axis
  75290. * @param result defines the target matrix
  75291. */
  75292. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75293. /**
  75294. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75295. * @param quat defines the quaternion to use
  75296. * @param result defines the target matrix
  75297. */
  75298. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75299. }
  75300. /**
  75301. * @hidden
  75302. */
  75303. export class TmpVectors {
  75304. static Vector2: Vector2[];
  75305. static Vector3: Vector3[];
  75306. static Vector4: Vector4[];
  75307. static Quaternion: Quaternion[];
  75308. static Matrix: Matrix[];
  75309. }
  75310. }
  75311. declare module BABYLON {
  75312. /**
  75313. * Defines potential orientation for back face culling
  75314. */
  75315. export enum Orientation {
  75316. /**
  75317. * Clockwise
  75318. */
  75319. CW = 0,
  75320. /** Counter clockwise */
  75321. CCW = 1
  75322. }
  75323. /** Class used to represent a Bezier curve */
  75324. export class BezierCurve {
  75325. /**
  75326. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75327. * @param t defines the time
  75328. * @param x1 defines the left coordinate on X axis
  75329. * @param y1 defines the left coordinate on Y axis
  75330. * @param x2 defines the right coordinate on X axis
  75331. * @param y2 defines the right coordinate on Y axis
  75332. * @returns the interpolated value
  75333. */
  75334. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75335. }
  75336. /**
  75337. * Defines angle representation
  75338. */
  75339. export class Angle {
  75340. private _radians;
  75341. /**
  75342. * Creates an Angle object of "radians" radians (float).
  75343. * @param radians the angle in radians
  75344. */
  75345. constructor(radians: number);
  75346. /**
  75347. * Get value in degrees
  75348. * @returns the Angle value in degrees (float)
  75349. */
  75350. degrees(): number;
  75351. /**
  75352. * Get value in radians
  75353. * @returns the Angle value in radians (float)
  75354. */
  75355. radians(): number;
  75356. /**
  75357. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75358. * @param a defines first vector
  75359. * @param b defines second vector
  75360. * @returns a new Angle
  75361. */
  75362. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75363. /**
  75364. * Gets a new Angle object from the given float in radians
  75365. * @param radians defines the angle value in radians
  75366. * @returns a new Angle
  75367. */
  75368. static FromRadians(radians: number): Angle;
  75369. /**
  75370. * Gets a new Angle object from the given float in degrees
  75371. * @param degrees defines the angle value in degrees
  75372. * @returns a new Angle
  75373. */
  75374. static FromDegrees(degrees: number): Angle;
  75375. }
  75376. /**
  75377. * This represents an arc in a 2d space.
  75378. */
  75379. export class Arc2 {
  75380. /** Defines the start point of the arc */
  75381. startPoint: Vector2;
  75382. /** Defines the mid point of the arc */
  75383. midPoint: Vector2;
  75384. /** Defines the end point of the arc */
  75385. endPoint: Vector2;
  75386. /**
  75387. * Defines the center point of the arc.
  75388. */
  75389. centerPoint: Vector2;
  75390. /**
  75391. * Defines the radius of the arc.
  75392. */
  75393. radius: number;
  75394. /**
  75395. * Defines the angle of the arc (from mid point to end point).
  75396. */
  75397. angle: Angle;
  75398. /**
  75399. * Defines the start angle of the arc (from start point to middle point).
  75400. */
  75401. startAngle: Angle;
  75402. /**
  75403. * Defines the orientation of the arc (clock wise/counter clock wise).
  75404. */
  75405. orientation: Orientation;
  75406. /**
  75407. * Creates an Arc object from the three given points : start, middle and end.
  75408. * @param startPoint Defines the start point of the arc
  75409. * @param midPoint Defines the midlle point of the arc
  75410. * @param endPoint Defines the end point of the arc
  75411. */
  75412. constructor(
  75413. /** Defines the start point of the arc */
  75414. startPoint: Vector2,
  75415. /** Defines the mid point of the arc */
  75416. midPoint: Vector2,
  75417. /** Defines the end point of the arc */
  75418. endPoint: Vector2);
  75419. }
  75420. /**
  75421. * Represents a 2D path made up of multiple 2D points
  75422. */
  75423. export class Path2 {
  75424. private _points;
  75425. private _length;
  75426. /**
  75427. * If the path start and end point are the same
  75428. */
  75429. closed: boolean;
  75430. /**
  75431. * Creates a Path2 object from the starting 2D coordinates x and y.
  75432. * @param x the starting points x value
  75433. * @param y the starting points y value
  75434. */
  75435. constructor(x: number, y: number);
  75436. /**
  75437. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75438. * @param x the added points x value
  75439. * @param y the added points y value
  75440. * @returns the updated Path2.
  75441. */
  75442. addLineTo(x: number, y: number): Path2;
  75443. /**
  75444. * 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.
  75445. * @param midX middle point x value
  75446. * @param midY middle point y value
  75447. * @param endX end point x value
  75448. * @param endY end point y value
  75449. * @param numberOfSegments (default: 36)
  75450. * @returns the updated Path2.
  75451. */
  75452. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75453. /**
  75454. * Closes the Path2.
  75455. * @returns the Path2.
  75456. */
  75457. close(): Path2;
  75458. /**
  75459. * Gets the sum of the distance between each sequential point in the path
  75460. * @returns the Path2 total length (float).
  75461. */
  75462. length(): number;
  75463. /**
  75464. * Gets the points which construct the path
  75465. * @returns the Path2 internal array of points.
  75466. */
  75467. getPoints(): Vector2[];
  75468. /**
  75469. * Retreives the point at the distance aways from the starting point
  75470. * @param normalizedLengthPosition the length along the path to retreive the point from
  75471. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75472. */
  75473. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75474. /**
  75475. * Creates a new path starting from an x and y position
  75476. * @param x starting x value
  75477. * @param y starting y value
  75478. * @returns a new Path2 starting at the coordinates (x, y).
  75479. */
  75480. static StartingAt(x: number, y: number): Path2;
  75481. }
  75482. /**
  75483. * Represents a 3D path made up of multiple 3D points
  75484. */
  75485. export class Path3D {
  75486. /**
  75487. * an array of Vector3, the curve axis of the Path3D
  75488. */
  75489. path: Vector3[];
  75490. private _curve;
  75491. private _distances;
  75492. private _tangents;
  75493. private _normals;
  75494. private _binormals;
  75495. private _raw;
  75496. private _alignTangentsWithPath;
  75497. private readonly _pointAtData;
  75498. /**
  75499. * new Path3D(path, normal, raw)
  75500. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75501. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75502. * @param path an array of Vector3, the curve axis of the Path3D
  75503. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75504. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75505. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75506. */
  75507. constructor(
  75508. /**
  75509. * an array of Vector3, the curve axis of the Path3D
  75510. */
  75511. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  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. getCurve(): Vector3[];
  75517. /**
  75518. * Returns the Path3D array of successive Vector3 designing its curve.
  75519. * @returns the Path3D array of successive Vector3 designing its curve.
  75520. */
  75521. getPoints(): Vector3[];
  75522. /**
  75523. * @returns the computed length (float) of the path.
  75524. */
  75525. length(): number;
  75526. /**
  75527. * Returns an array populated with tangent vectors on each Path3D curve point.
  75528. * @returns an array populated with tangent vectors on each Path3D curve point.
  75529. */
  75530. getTangents(): Vector3[];
  75531. /**
  75532. * Returns an array populated with normal vectors on each Path3D curve point.
  75533. * @returns an array populated with normal vectors on each Path3D curve point.
  75534. */
  75535. getNormals(): Vector3[];
  75536. /**
  75537. * Returns an array populated with binormal vectors on each Path3D curve point.
  75538. * @returns an array populated with binormal vectors on each Path3D curve point.
  75539. */
  75540. getBinormals(): Vector3[];
  75541. /**
  75542. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75543. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75544. */
  75545. getDistances(): number[];
  75546. /**
  75547. * Returns an interpolated point along this path
  75548. * @param position the position of the point along this path, from 0.0 to 1.0
  75549. * @returns a new Vector3 as the point
  75550. */
  75551. getPointAt(position: number): Vector3;
  75552. /**
  75553. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75554. * @param position the position of the point along this path, from 0.0 to 1.0
  75555. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75556. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75557. */
  75558. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75559. /**
  75560. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75561. * @param position the position of the point along this path, from 0.0 to 1.0
  75562. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75563. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75564. */
  75565. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75566. /**
  75567. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75568. * @param position the position of the point along this path, from 0.0 to 1.0
  75569. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75570. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75571. */
  75572. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75573. /**
  75574. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75575. * @param position the position of the point along this path, from 0.0 to 1.0
  75576. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75577. */
  75578. getDistanceAt(position: number): number;
  75579. /**
  75580. * Returns the array index of the previous point of an interpolated point along this path
  75581. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75582. * @returns the array index
  75583. */
  75584. getPreviousPointIndexAt(position: number): number;
  75585. /**
  75586. * 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)
  75587. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75588. * @returns the sub position
  75589. */
  75590. getSubPositionAt(position: number): number;
  75591. /**
  75592. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75593. * @param target the vector of which to get the closest position to
  75594. * @returns the position of the closest virtual point on this path to the target vector
  75595. */
  75596. getClosestPositionTo(target: Vector3): number;
  75597. /**
  75598. * Returns a sub path (slice) of this path
  75599. * @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
  75600. * @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
  75601. * @returns a sub path (slice) of this path
  75602. */
  75603. slice(start?: number, end?: number): Path3D;
  75604. /**
  75605. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75606. * @param path path which all values are copied into the curves points
  75607. * @param firstNormal which should be projected onto the curve
  75608. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75609. * @returns the same object updated.
  75610. */
  75611. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75612. private _compute;
  75613. private _getFirstNonNullVector;
  75614. private _getLastNonNullVector;
  75615. private _normalVector;
  75616. /**
  75617. * Updates the point at data for an interpolated point along this curve
  75618. * @param position the position of the point along this curve, from 0.0 to 1.0
  75619. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75620. * @returns the (updated) point at data
  75621. */
  75622. private _updatePointAtData;
  75623. /**
  75624. * Updates the point at data from the specified parameters
  75625. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75626. * @param point the interpolated point
  75627. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75628. */
  75629. private _setPointAtData;
  75630. /**
  75631. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75632. */
  75633. private _updateInterpolationMatrix;
  75634. }
  75635. /**
  75636. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75637. * A Curve3 is designed from a series of successive Vector3.
  75638. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75639. */
  75640. export class Curve3 {
  75641. private _points;
  75642. private _length;
  75643. /**
  75644. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75645. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75646. * @param v1 (Vector3) the control point
  75647. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75648. * @param nbPoints (integer) the wanted number of points in the curve
  75649. * @returns the created Curve3
  75650. */
  75651. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75652. /**
  75653. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75654. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75655. * @param v1 (Vector3) the first control point
  75656. * @param v2 (Vector3) the second control point
  75657. * @param v3 (Vector3) the end point of the Cubic Bezier
  75658. * @param nbPoints (integer) the wanted number of points in the curve
  75659. * @returns the created Curve3
  75660. */
  75661. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75662. /**
  75663. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75664. * @param p1 (Vector3) the origin point of the Hermite Spline
  75665. * @param t1 (Vector3) the tangent vector at the origin point
  75666. * @param p2 (Vector3) the end point of the Hermite Spline
  75667. * @param t2 (Vector3) the tangent vector at the end point
  75668. * @param nbPoints (integer) the wanted number of points in the curve
  75669. * @returns the created Curve3
  75670. */
  75671. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75672. /**
  75673. * Returns a Curve3 object along a CatmullRom Spline curve :
  75674. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75675. * @param nbPoints (integer) the wanted number of points between each curve control points
  75676. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75677. * @returns the created Curve3
  75678. */
  75679. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75680. /**
  75681. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75682. * A Curve3 is designed from a series of successive Vector3.
  75683. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75684. * @param points points which make up the curve
  75685. */
  75686. constructor(points: Vector3[]);
  75687. /**
  75688. * @returns the Curve3 stored array of successive Vector3
  75689. */
  75690. getPoints(): Vector3[];
  75691. /**
  75692. * @returns the computed length (float) of the curve.
  75693. */
  75694. length(): number;
  75695. /**
  75696. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75697. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75698. * curveA and curveB keep unchanged.
  75699. * @param curve the curve to continue from this curve
  75700. * @returns the newly constructed curve
  75701. */
  75702. continue(curve: DeepImmutable<Curve3>): Curve3;
  75703. private _computeLength;
  75704. }
  75705. }
  75706. declare module BABYLON {
  75707. /**
  75708. * This represents the main contract an easing function should follow.
  75709. * Easing functions are used throughout the animation system.
  75710. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75711. */
  75712. export interface IEasingFunction {
  75713. /**
  75714. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75715. * of the easing function.
  75716. * The link below provides some of the most common examples of easing functions.
  75717. * @see https://easings.net/
  75718. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75719. * @returns the corresponding value on the curve defined by the easing function
  75720. */
  75721. ease(gradient: number): number;
  75722. }
  75723. /**
  75724. * Base class used for every default easing function.
  75725. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75726. */
  75727. export class EasingFunction implements IEasingFunction {
  75728. /**
  75729. * Interpolation follows the mathematical formula associated with the easing function.
  75730. */
  75731. static readonly EASINGMODE_EASEIN: number;
  75732. /**
  75733. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75734. */
  75735. static readonly EASINGMODE_EASEOUT: number;
  75736. /**
  75737. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75738. */
  75739. static readonly EASINGMODE_EASEINOUT: number;
  75740. private _easingMode;
  75741. /**
  75742. * Sets the easing mode of the current function.
  75743. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75744. */
  75745. setEasingMode(easingMode: number): void;
  75746. /**
  75747. * Gets the current easing mode.
  75748. * @returns the easing mode
  75749. */
  75750. getEasingMode(): number;
  75751. /**
  75752. * @hidden
  75753. */
  75754. easeInCore(gradient: number): number;
  75755. /**
  75756. * Given an input gradient between 0 and 1, this returns the corresponding value
  75757. * of the easing function.
  75758. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75759. * @returns the corresponding value on the curve defined by the easing function
  75760. */
  75761. ease(gradient: number): number;
  75762. }
  75763. /**
  75764. * Easing function with a circle shape (see link below).
  75765. * @see https://easings.net/#easeInCirc
  75766. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75767. */
  75768. export class CircleEase extends EasingFunction implements IEasingFunction {
  75769. /** @hidden */
  75770. easeInCore(gradient: number): number;
  75771. }
  75772. /**
  75773. * Easing function with a ease back shape (see link below).
  75774. * @see https://easings.net/#easeInBack
  75775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75776. */
  75777. export class BackEase extends EasingFunction implements IEasingFunction {
  75778. /** Defines the amplitude of the function */
  75779. amplitude: number;
  75780. /**
  75781. * Instantiates a back ease easing
  75782. * @see https://easings.net/#easeInBack
  75783. * @param amplitude Defines the amplitude of the function
  75784. */
  75785. constructor(
  75786. /** Defines the amplitude of the function */
  75787. amplitude?: number);
  75788. /** @hidden */
  75789. easeInCore(gradient: number): number;
  75790. }
  75791. /**
  75792. * Easing function with a bouncing shape (see link below).
  75793. * @see https://easings.net/#easeInBounce
  75794. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75795. */
  75796. export class BounceEase extends EasingFunction implements IEasingFunction {
  75797. /** Defines the number of bounces */
  75798. bounces: number;
  75799. /** Defines the amplitude of the bounce */
  75800. bounciness: number;
  75801. /**
  75802. * Instantiates a bounce easing
  75803. * @see https://easings.net/#easeInBounce
  75804. * @param bounces Defines the number of bounces
  75805. * @param bounciness Defines the amplitude of the bounce
  75806. */
  75807. constructor(
  75808. /** Defines the number of bounces */
  75809. bounces?: number,
  75810. /** Defines the amplitude of the bounce */
  75811. bounciness?: number);
  75812. /** @hidden */
  75813. easeInCore(gradient: number): number;
  75814. }
  75815. /**
  75816. * Easing function with a power of 3 shape (see link below).
  75817. * @see https://easings.net/#easeInCubic
  75818. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75819. */
  75820. export class CubicEase extends EasingFunction implements IEasingFunction {
  75821. /** @hidden */
  75822. easeInCore(gradient: number): number;
  75823. }
  75824. /**
  75825. * Easing function with an elastic shape (see link below).
  75826. * @see https://easings.net/#easeInElastic
  75827. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75828. */
  75829. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75830. /** Defines the number of oscillations*/
  75831. oscillations: number;
  75832. /** Defines the amplitude of the oscillations*/
  75833. springiness: number;
  75834. /**
  75835. * Instantiates an elastic easing function
  75836. * @see https://easings.net/#easeInElastic
  75837. * @param oscillations Defines the number of oscillations
  75838. * @param springiness Defines the amplitude of the oscillations
  75839. */
  75840. constructor(
  75841. /** Defines the number of oscillations*/
  75842. oscillations?: number,
  75843. /** Defines the amplitude of the oscillations*/
  75844. springiness?: number);
  75845. /** @hidden */
  75846. easeInCore(gradient: number): number;
  75847. }
  75848. /**
  75849. * Easing function with an exponential shape (see link below).
  75850. * @see https://easings.net/#easeInExpo
  75851. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75852. */
  75853. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75854. /** Defines the exponent of the function */
  75855. exponent: number;
  75856. /**
  75857. * Instantiates an exponential easing function
  75858. * @see https://easings.net/#easeInExpo
  75859. * @param exponent Defines the exponent of the function
  75860. */
  75861. constructor(
  75862. /** Defines the exponent of the function */
  75863. exponent?: number);
  75864. /** @hidden */
  75865. easeInCore(gradient: number): number;
  75866. }
  75867. /**
  75868. * Easing function with a power shape (see link below).
  75869. * @see https://easings.net/#easeInQuad
  75870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75871. */
  75872. export class PowerEase extends EasingFunction implements IEasingFunction {
  75873. /** Defines the power of the function */
  75874. power: number;
  75875. /**
  75876. * Instantiates an power base easing function
  75877. * @see https://easings.net/#easeInQuad
  75878. * @param power Defines the power of the function
  75879. */
  75880. constructor(
  75881. /** Defines the power of the function */
  75882. power?: number);
  75883. /** @hidden */
  75884. easeInCore(gradient: number): number;
  75885. }
  75886. /**
  75887. * Easing function with a power of 2 shape (see link below).
  75888. * @see https://easings.net/#easeInQuad
  75889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75890. */
  75891. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75892. /** @hidden */
  75893. easeInCore(gradient: number): number;
  75894. }
  75895. /**
  75896. * Easing function with a power of 4 shape (see link below).
  75897. * @see https://easings.net/#easeInQuart
  75898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75899. */
  75900. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75901. /** @hidden */
  75902. easeInCore(gradient: number): number;
  75903. }
  75904. /**
  75905. * Easing function with a power of 5 shape (see link below).
  75906. * @see https://easings.net/#easeInQuint
  75907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75908. */
  75909. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75910. /** @hidden */
  75911. easeInCore(gradient: number): number;
  75912. }
  75913. /**
  75914. * Easing function with a sin shape (see link below).
  75915. * @see https://easings.net/#easeInSine
  75916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75917. */
  75918. export class SineEase extends EasingFunction implements IEasingFunction {
  75919. /** @hidden */
  75920. easeInCore(gradient: number): number;
  75921. }
  75922. /**
  75923. * Easing function with a bezier shape (see link below).
  75924. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75926. */
  75927. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75928. /** Defines the x component of the start tangent in the bezier curve */
  75929. x1: number;
  75930. /** Defines the y component of the start tangent in the bezier curve */
  75931. y1: number;
  75932. /** Defines the x component of the end tangent in the bezier curve */
  75933. x2: number;
  75934. /** Defines the y component of the end tangent in the bezier curve */
  75935. y2: number;
  75936. /**
  75937. * Instantiates a bezier function
  75938. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75939. * @param x1 Defines the x component of the start tangent in the bezier curve
  75940. * @param y1 Defines the y component of the start tangent in the bezier curve
  75941. * @param x2 Defines the x component of the end tangent in the bezier curve
  75942. * @param y2 Defines the y component of the end tangent in the bezier curve
  75943. */
  75944. constructor(
  75945. /** Defines the x component of the start tangent in the bezier curve */
  75946. x1?: number,
  75947. /** Defines the y component of the start tangent in the bezier curve */
  75948. y1?: number,
  75949. /** Defines the x component of the end tangent in the bezier curve */
  75950. x2?: number,
  75951. /** Defines the y component of the end tangent in the bezier curve */
  75952. y2?: number);
  75953. /** @hidden */
  75954. easeInCore(gradient: number): number;
  75955. }
  75956. }
  75957. declare module BABYLON {
  75958. /**
  75959. * Class used to hold a RBG color
  75960. */
  75961. export class Color3 {
  75962. /**
  75963. * Defines the red component (between 0 and 1, default is 0)
  75964. */
  75965. r: number;
  75966. /**
  75967. * Defines the green component (between 0 and 1, default is 0)
  75968. */
  75969. g: number;
  75970. /**
  75971. * Defines the blue component (between 0 and 1, default is 0)
  75972. */
  75973. b: number;
  75974. /**
  75975. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75976. * @param r defines the red component (between 0 and 1, default is 0)
  75977. * @param g defines the green component (between 0 and 1, default is 0)
  75978. * @param b defines the blue component (between 0 and 1, default is 0)
  75979. */
  75980. constructor(
  75981. /**
  75982. * Defines the red component (between 0 and 1, default is 0)
  75983. */
  75984. r?: number,
  75985. /**
  75986. * Defines the green component (between 0 and 1, default is 0)
  75987. */
  75988. g?: number,
  75989. /**
  75990. * Defines the blue component (between 0 and 1, default is 0)
  75991. */
  75992. b?: number);
  75993. /**
  75994. * Creates a string with the Color3 current values
  75995. * @returns the string representation of the Color3 object
  75996. */
  75997. toString(): string;
  75998. /**
  75999. * Returns the string "Color3"
  76000. * @returns "Color3"
  76001. */
  76002. getClassName(): string;
  76003. /**
  76004. * Compute the Color3 hash code
  76005. * @returns an unique number that can be used to hash Color3 objects
  76006. */
  76007. getHashCode(): number;
  76008. /**
  76009. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  76010. * @param array defines the array where to store the r,g,b components
  76011. * @param index defines an optional index in the target array to define where to start storing values
  76012. * @returns the current Color3 object
  76013. */
  76014. toArray(array: FloatArray, index?: number): Color3;
  76015. /**
  76016. * Returns a new Color4 object from the current Color3 and the given alpha
  76017. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  76018. * @returns a new Color4 object
  76019. */
  76020. toColor4(alpha?: number): Color4;
  76021. /**
  76022. * Returns a new array populated with 3 numeric elements : red, green and blue values
  76023. * @returns the new array
  76024. */
  76025. asArray(): number[];
  76026. /**
  76027. * Returns the luminance value
  76028. * @returns a float value
  76029. */
  76030. toLuminance(): number;
  76031. /**
  76032. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  76033. * @param otherColor defines the second operand
  76034. * @returns the new Color3 object
  76035. */
  76036. multiply(otherColor: DeepImmutable<Color3>): Color3;
  76037. /**
  76038. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  76039. * @param otherColor defines the second operand
  76040. * @param result defines the Color3 object where to store the result
  76041. * @returns the current Color3
  76042. */
  76043. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76044. /**
  76045. * Determines equality between Color3 objects
  76046. * @param otherColor defines the second operand
  76047. * @returns true if the rgb values are equal to the given ones
  76048. */
  76049. equals(otherColor: DeepImmutable<Color3>): boolean;
  76050. /**
  76051. * Determines equality between the current Color3 object and a set of r,b,g values
  76052. * @param r defines the red component to check
  76053. * @param g defines the green component to check
  76054. * @param b defines the blue component to check
  76055. * @returns true if the rgb values are equal to the given ones
  76056. */
  76057. equalsFloats(r: number, g: number, b: number): boolean;
  76058. /**
  76059. * Multiplies in place each rgb value by scale
  76060. * @param scale defines the scaling factor
  76061. * @returns the updated Color3
  76062. */
  76063. scale(scale: number): Color3;
  76064. /**
  76065. * Multiplies the rgb values by scale and stores the result into "result"
  76066. * @param scale defines the scaling factor
  76067. * @param result defines the Color3 object where to store the result
  76068. * @returns the unmodified current Color3
  76069. */
  76070. scaleToRef(scale: number, result: Color3): Color3;
  76071. /**
  76072. * Scale the current Color3 values by a factor and add the result to a given Color3
  76073. * @param scale defines the scale factor
  76074. * @param result defines color to store the result into
  76075. * @returns the unmodified current Color3
  76076. */
  76077. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76078. /**
  76079. * Clamps the rgb values by the min and max values and stores the result into "result"
  76080. * @param min defines minimum clamping value (default is 0)
  76081. * @param max defines maximum clamping value (default is 1)
  76082. * @param result defines color to store the result into
  76083. * @returns the original Color3
  76084. */
  76085. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76086. /**
  76087. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76088. * @param otherColor defines the second operand
  76089. * @returns the new Color3
  76090. */
  76091. add(otherColor: DeepImmutable<Color3>): Color3;
  76092. /**
  76093. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76094. * @param otherColor defines the second operand
  76095. * @param result defines Color3 object to store the result into
  76096. * @returns the unmodified current Color3
  76097. */
  76098. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76099. /**
  76100. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76101. * @param otherColor defines the second operand
  76102. * @returns the new Color3
  76103. */
  76104. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76105. /**
  76106. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76107. * @param otherColor defines the second operand
  76108. * @param result defines Color3 object to store the result into
  76109. * @returns the unmodified current Color3
  76110. */
  76111. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76112. /**
  76113. * Copy the current object
  76114. * @returns a new Color3 copied the current one
  76115. */
  76116. clone(): Color3;
  76117. /**
  76118. * Copies the rgb values from the source in the current Color3
  76119. * @param source defines the source Color3 object
  76120. * @returns the updated Color3 object
  76121. */
  76122. copyFrom(source: DeepImmutable<Color3>): Color3;
  76123. /**
  76124. * Updates the Color3 rgb values from the given floats
  76125. * @param r defines the red component to read from
  76126. * @param g defines the green component to read from
  76127. * @param b defines the blue component to read from
  76128. * @returns the current Color3 object
  76129. */
  76130. copyFromFloats(r: number, g: number, b: number): Color3;
  76131. /**
  76132. * Updates the Color3 rgb values from the given floats
  76133. * @param r defines the red component to read from
  76134. * @param g defines the green component to read from
  76135. * @param b defines the blue component to read from
  76136. * @returns the current Color3 object
  76137. */
  76138. set(r: number, g: number, b: number): Color3;
  76139. /**
  76140. * Compute the Color3 hexadecimal code as a string
  76141. * @returns a string containing the hexadecimal representation of the Color3 object
  76142. */
  76143. toHexString(): string;
  76144. /**
  76145. * Computes a new Color3 converted from the current one to linear space
  76146. * @returns a new Color3 object
  76147. */
  76148. toLinearSpace(): Color3;
  76149. /**
  76150. * Converts current color in rgb space to HSV values
  76151. * @returns a new color3 representing the HSV values
  76152. */
  76153. toHSV(): Color3;
  76154. /**
  76155. * Converts current color in rgb space to HSV values
  76156. * @param result defines the Color3 where to store the HSV values
  76157. */
  76158. toHSVToRef(result: Color3): void;
  76159. /**
  76160. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76161. * @param convertedColor defines the Color3 object where to store the linear space version
  76162. * @returns the unmodified Color3
  76163. */
  76164. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76165. /**
  76166. * Computes a new Color3 converted from the current one to gamma space
  76167. * @returns a new Color3 object
  76168. */
  76169. toGammaSpace(): Color3;
  76170. /**
  76171. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76172. * @param convertedColor defines the Color3 object where to store the gamma space version
  76173. * @returns the unmodified Color3
  76174. */
  76175. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76176. private static _BlackReadOnly;
  76177. /**
  76178. * Convert Hue, saturation and value to a Color3 (RGB)
  76179. * @param hue defines the hue
  76180. * @param saturation defines the saturation
  76181. * @param value defines the value
  76182. * @param result defines the Color3 where to store the RGB values
  76183. */
  76184. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76185. /**
  76186. * Creates a new Color3 from the string containing valid hexadecimal values
  76187. * @param hex defines a string containing valid hexadecimal values
  76188. * @returns a new Color3 object
  76189. */
  76190. static FromHexString(hex: string): Color3;
  76191. /**
  76192. * Creates a new Color3 from the starting index of the given array
  76193. * @param array defines the source array
  76194. * @param offset defines an offset in the source array
  76195. * @returns a new Color3 object
  76196. */
  76197. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76198. /**
  76199. * Creates a new Color3 from integer values (< 256)
  76200. * @param r defines the red component to read from (value between 0 and 255)
  76201. * @param g defines the green component to read from (value between 0 and 255)
  76202. * @param b defines the blue component to read from (value between 0 and 255)
  76203. * @returns a new Color3 object
  76204. */
  76205. static FromInts(r: number, g: number, b: number): Color3;
  76206. /**
  76207. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76208. * @param start defines the start Color3 value
  76209. * @param end defines the end Color3 value
  76210. * @param amount defines the gradient value between start and end
  76211. * @returns a new Color3 object
  76212. */
  76213. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76214. /**
  76215. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76216. * @param left defines the start value
  76217. * @param right defines the end value
  76218. * @param amount defines the gradient factor
  76219. * @param result defines the Color3 object where to store the result
  76220. */
  76221. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76222. /**
  76223. * Returns a Color3 value containing a red color
  76224. * @returns a new Color3 object
  76225. */
  76226. static Red(): Color3;
  76227. /**
  76228. * Returns a Color3 value containing a green color
  76229. * @returns a new Color3 object
  76230. */
  76231. static Green(): Color3;
  76232. /**
  76233. * Returns a Color3 value containing a blue color
  76234. * @returns a new Color3 object
  76235. */
  76236. static Blue(): Color3;
  76237. /**
  76238. * Returns a Color3 value containing a black color
  76239. * @returns a new Color3 object
  76240. */
  76241. static Black(): Color3;
  76242. /**
  76243. * Gets a Color3 value containing a black color that must not be updated
  76244. */
  76245. static get BlackReadOnly(): DeepImmutable<Color3>;
  76246. /**
  76247. * Returns a Color3 value containing a white color
  76248. * @returns a new Color3 object
  76249. */
  76250. static White(): Color3;
  76251. /**
  76252. * Returns a Color3 value containing a purple color
  76253. * @returns a new Color3 object
  76254. */
  76255. static Purple(): Color3;
  76256. /**
  76257. * Returns a Color3 value containing a magenta color
  76258. * @returns a new Color3 object
  76259. */
  76260. static Magenta(): Color3;
  76261. /**
  76262. * Returns a Color3 value containing a yellow color
  76263. * @returns a new Color3 object
  76264. */
  76265. static Yellow(): Color3;
  76266. /**
  76267. * Returns a Color3 value containing a gray color
  76268. * @returns a new Color3 object
  76269. */
  76270. static Gray(): Color3;
  76271. /**
  76272. * Returns a Color3 value containing a teal color
  76273. * @returns a new Color3 object
  76274. */
  76275. static Teal(): Color3;
  76276. /**
  76277. * Returns a Color3 value containing a random color
  76278. * @returns a new Color3 object
  76279. */
  76280. static Random(): Color3;
  76281. }
  76282. /**
  76283. * Class used to hold a RBGA color
  76284. */
  76285. export class Color4 {
  76286. /**
  76287. * Defines the red component (between 0 and 1, default is 0)
  76288. */
  76289. r: number;
  76290. /**
  76291. * Defines the green component (between 0 and 1, default is 0)
  76292. */
  76293. g: number;
  76294. /**
  76295. * Defines the blue component (between 0 and 1, default is 0)
  76296. */
  76297. b: number;
  76298. /**
  76299. * Defines the alpha component (between 0 and 1, default is 1)
  76300. */
  76301. a: number;
  76302. /**
  76303. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76304. * @param r defines the red component (between 0 and 1, default is 0)
  76305. * @param g defines the green component (between 0 and 1, default is 0)
  76306. * @param b defines the blue component (between 0 and 1, default is 0)
  76307. * @param a defines the alpha component (between 0 and 1, default is 1)
  76308. */
  76309. constructor(
  76310. /**
  76311. * Defines the red component (between 0 and 1, default is 0)
  76312. */
  76313. r?: number,
  76314. /**
  76315. * Defines the green component (between 0 and 1, default is 0)
  76316. */
  76317. g?: number,
  76318. /**
  76319. * Defines the blue component (between 0 and 1, default is 0)
  76320. */
  76321. b?: number,
  76322. /**
  76323. * Defines the alpha component (between 0 and 1, default is 1)
  76324. */
  76325. a?: number);
  76326. /**
  76327. * Adds in place the given Color4 values to the current Color4 object
  76328. * @param right defines the second operand
  76329. * @returns the current updated Color4 object
  76330. */
  76331. addInPlace(right: DeepImmutable<Color4>): Color4;
  76332. /**
  76333. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76334. * @returns the new array
  76335. */
  76336. asArray(): number[];
  76337. /**
  76338. * Stores from the starting index in the given array the Color4 successive values
  76339. * @param array defines the array where to store the r,g,b components
  76340. * @param index defines an optional index in the target array to define where to start storing values
  76341. * @returns the current Color4 object
  76342. */
  76343. toArray(array: number[], index?: number): Color4;
  76344. /**
  76345. * Determines equality between Color4 objects
  76346. * @param otherColor defines the second operand
  76347. * @returns true if the rgba values are equal to the given ones
  76348. */
  76349. equals(otherColor: DeepImmutable<Color4>): boolean;
  76350. /**
  76351. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76352. * @param right defines the second operand
  76353. * @returns a new Color4 object
  76354. */
  76355. add(right: DeepImmutable<Color4>): Color4;
  76356. /**
  76357. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76358. * @param right defines the second operand
  76359. * @returns a new Color4 object
  76360. */
  76361. subtract(right: DeepImmutable<Color4>): Color4;
  76362. /**
  76363. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76364. * @param right defines the second operand
  76365. * @param result defines the Color4 object where to store the result
  76366. * @returns the current Color4 object
  76367. */
  76368. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76369. /**
  76370. * Creates a new Color4 with the current Color4 values multiplied by scale
  76371. * @param scale defines the scaling factor to apply
  76372. * @returns a new Color4 object
  76373. */
  76374. scale(scale: number): Color4;
  76375. /**
  76376. * Multiplies the current Color4 values by scale and stores the result in "result"
  76377. * @param scale defines the scaling factor to apply
  76378. * @param result defines the Color4 object where to store the result
  76379. * @returns the current unmodified Color4
  76380. */
  76381. scaleToRef(scale: number, result: Color4): Color4;
  76382. /**
  76383. * Scale the current Color4 values by a factor and add the result to a given Color4
  76384. * @param scale defines the scale factor
  76385. * @param result defines the Color4 object where to store the result
  76386. * @returns the unmodified current Color4
  76387. */
  76388. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76389. /**
  76390. * Clamps the rgb values by the min and max values and stores the result into "result"
  76391. * @param min defines minimum clamping value (default is 0)
  76392. * @param max defines maximum clamping value (default is 1)
  76393. * @param result defines color to store the result into.
  76394. * @returns the cuurent Color4
  76395. */
  76396. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76397. /**
  76398. * Multipy an Color4 value by another and return a new Color4 object
  76399. * @param color defines the Color4 value to multiply by
  76400. * @returns a new Color4 object
  76401. */
  76402. multiply(color: Color4): Color4;
  76403. /**
  76404. * Multipy a Color4 value by another and push the result in a reference value
  76405. * @param color defines the Color4 value to multiply by
  76406. * @param result defines the Color4 to fill the result in
  76407. * @returns the result Color4
  76408. */
  76409. multiplyToRef(color: Color4, result: Color4): Color4;
  76410. /**
  76411. * Creates a string with the Color4 current values
  76412. * @returns the string representation of the Color4 object
  76413. */
  76414. toString(): string;
  76415. /**
  76416. * Returns the string "Color4"
  76417. * @returns "Color4"
  76418. */
  76419. getClassName(): string;
  76420. /**
  76421. * Compute the Color4 hash code
  76422. * @returns an unique number that can be used to hash Color4 objects
  76423. */
  76424. getHashCode(): number;
  76425. /**
  76426. * Creates a new Color4 copied from the current one
  76427. * @returns a new Color4 object
  76428. */
  76429. clone(): Color4;
  76430. /**
  76431. * Copies the given Color4 values into the current one
  76432. * @param source defines the source Color4 object
  76433. * @returns the current updated Color4 object
  76434. */
  76435. copyFrom(source: Color4): Color4;
  76436. /**
  76437. * Copies the given float values into the current one
  76438. * @param r defines the red component to read from
  76439. * @param g defines the green component to read from
  76440. * @param b defines the blue component to read from
  76441. * @param a defines the alpha component to read from
  76442. * @returns the current updated Color4 object
  76443. */
  76444. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76445. /**
  76446. * Copies the given float values into the current one
  76447. * @param r defines the red component to read from
  76448. * @param g defines the green component to read from
  76449. * @param b defines the blue component to read from
  76450. * @param a defines the alpha component to read from
  76451. * @returns the current updated Color4 object
  76452. */
  76453. set(r: number, g: number, b: number, a: number): Color4;
  76454. /**
  76455. * Compute the Color4 hexadecimal code as a string
  76456. * @returns a string containing the hexadecimal representation of the Color4 object
  76457. */
  76458. toHexString(): string;
  76459. /**
  76460. * Computes a new Color4 converted from the current one to linear space
  76461. * @returns a new Color4 object
  76462. */
  76463. toLinearSpace(): Color4;
  76464. /**
  76465. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76466. * @param convertedColor defines the Color4 object where to store the linear space version
  76467. * @returns the unmodified Color4
  76468. */
  76469. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76470. /**
  76471. * Computes a new Color4 converted from the current one to gamma space
  76472. * @returns a new Color4 object
  76473. */
  76474. toGammaSpace(): Color4;
  76475. /**
  76476. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76477. * @param convertedColor defines the Color4 object where to store the gamma space version
  76478. * @returns the unmodified Color4
  76479. */
  76480. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76481. /**
  76482. * Creates a new Color4 from the string containing valid hexadecimal values
  76483. * @param hex defines a string containing valid hexadecimal values
  76484. * @returns a new Color4 object
  76485. */
  76486. static FromHexString(hex: string): Color4;
  76487. /**
  76488. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76489. * @param left defines the start value
  76490. * @param right defines the end value
  76491. * @param amount defines the gradient factor
  76492. * @returns a new Color4 object
  76493. */
  76494. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76495. /**
  76496. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76497. * @param left defines the start value
  76498. * @param right defines the end value
  76499. * @param amount defines the gradient factor
  76500. * @param result defines the Color4 object where to store data
  76501. */
  76502. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76503. /**
  76504. * Creates a new Color4 from a Color3 and an alpha value
  76505. * @param color3 defines the source Color3 to read from
  76506. * @param alpha defines the alpha component (1.0 by default)
  76507. * @returns a new Color4 object
  76508. */
  76509. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76510. /**
  76511. * Creates a new Color4 from the starting index element of the given array
  76512. * @param array defines the source array to read from
  76513. * @param offset defines the offset in the source array
  76514. * @returns a new Color4 object
  76515. */
  76516. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76517. /**
  76518. * Creates a new Color3 from integer values (< 256)
  76519. * @param r defines the red component to read from (value between 0 and 255)
  76520. * @param g defines the green component to read from (value between 0 and 255)
  76521. * @param b defines the blue component to read from (value between 0 and 255)
  76522. * @param a defines the alpha component to read from (value between 0 and 255)
  76523. * @returns a new Color3 object
  76524. */
  76525. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76526. /**
  76527. * Check the content of a given array and convert it to an array containing RGBA data
  76528. * If the original array was already containing count * 4 values then it is returned directly
  76529. * @param colors defines the array to check
  76530. * @param count defines the number of RGBA data to expect
  76531. * @returns an array containing count * 4 values (RGBA)
  76532. */
  76533. static CheckColors4(colors: number[], count: number): number[];
  76534. }
  76535. /**
  76536. * @hidden
  76537. */
  76538. export class TmpColors {
  76539. static Color3: Color3[];
  76540. static Color4: Color4[];
  76541. }
  76542. }
  76543. declare module BABYLON {
  76544. /**
  76545. * Defines an interface which represents an animation key frame
  76546. */
  76547. export interface IAnimationKey {
  76548. /**
  76549. * Frame of the key frame
  76550. */
  76551. frame: number;
  76552. /**
  76553. * Value at the specifies key frame
  76554. */
  76555. value: any;
  76556. /**
  76557. * The input tangent for the cubic hermite spline
  76558. */
  76559. inTangent?: any;
  76560. /**
  76561. * The output tangent for the cubic hermite spline
  76562. */
  76563. outTangent?: any;
  76564. /**
  76565. * The animation interpolation type
  76566. */
  76567. interpolation?: AnimationKeyInterpolation;
  76568. }
  76569. /**
  76570. * Enum for the animation key frame interpolation type
  76571. */
  76572. export enum AnimationKeyInterpolation {
  76573. /**
  76574. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76575. */
  76576. STEP = 1
  76577. }
  76578. }
  76579. declare module BABYLON {
  76580. /**
  76581. * Represents the range of an animation
  76582. */
  76583. export class AnimationRange {
  76584. /**The name of the animation range**/
  76585. name: string;
  76586. /**The starting frame of the animation */
  76587. from: number;
  76588. /**The ending frame of the animation*/
  76589. to: number;
  76590. /**
  76591. * Initializes the range of an animation
  76592. * @param name The name of the animation range
  76593. * @param from The starting frame of the animation
  76594. * @param to The ending frame of the animation
  76595. */
  76596. constructor(
  76597. /**The name of the animation range**/
  76598. name: string,
  76599. /**The starting frame of the animation */
  76600. from: number,
  76601. /**The ending frame of the animation*/
  76602. to: number);
  76603. /**
  76604. * Makes a copy of the animation range
  76605. * @returns A copy of the animation range
  76606. */
  76607. clone(): AnimationRange;
  76608. }
  76609. }
  76610. declare module BABYLON {
  76611. /**
  76612. * Composed of a frame, and an action function
  76613. */
  76614. export class AnimationEvent {
  76615. /** The frame for which the event is triggered **/
  76616. frame: number;
  76617. /** The event to perform when triggered **/
  76618. action: (currentFrame: number) => void;
  76619. /** Specifies if the event should be triggered only once**/
  76620. onlyOnce?: boolean | undefined;
  76621. /**
  76622. * Specifies if the animation event is done
  76623. */
  76624. isDone: boolean;
  76625. /**
  76626. * Initializes the animation event
  76627. * @param frame The frame for which the event is triggered
  76628. * @param action The event to perform when triggered
  76629. * @param onlyOnce Specifies if the event should be triggered only once
  76630. */
  76631. constructor(
  76632. /** The frame for which the event is triggered **/
  76633. frame: number,
  76634. /** The event to perform when triggered **/
  76635. action: (currentFrame: number) => void,
  76636. /** Specifies if the event should be triggered only once**/
  76637. onlyOnce?: boolean | undefined);
  76638. /** @hidden */
  76639. _clone(): AnimationEvent;
  76640. }
  76641. }
  76642. declare module BABYLON {
  76643. /**
  76644. * Interface used to define a behavior
  76645. */
  76646. export interface Behavior<T> {
  76647. /** gets or sets behavior's name */
  76648. name: string;
  76649. /**
  76650. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76651. */
  76652. init(): void;
  76653. /**
  76654. * Called when the behavior is attached to a target
  76655. * @param target defines the target where the behavior is attached to
  76656. */
  76657. attach(target: T): void;
  76658. /**
  76659. * Called when the behavior is detached from its target
  76660. */
  76661. detach(): void;
  76662. }
  76663. /**
  76664. * Interface implemented by classes supporting behaviors
  76665. */
  76666. export interface IBehaviorAware<T> {
  76667. /**
  76668. * Attach a behavior
  76669. * @param behavior defines the behavior to attach
  76670. * @returns the current host
  76671. */
  76672. addBehavior(behavior: Behavior<T>): T;
  76673. /**
  76674. * Remove a behavior from the current object
  76675. * @param behavior defines the behavior to detach
  76676. * @returns the current host
  76677. */
  76678. removeBehavior(behavior: Behavior<T>): T;
  76679. /**
  76680. * Gets a behavior using its name to search
  76681. * @param name defines the name to search
  76682. * @returns the behavior or null if not found
  76683. */
  76684. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76685. }
  76686. }
  76687. declare module BABYLON {
  76688. /**
  76689. * Defines an array and its length.
  76690. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76691. */
  76692. export interface ISmartArrayLike<T> {
  76693. /**
  76694. * The data of the array.
  76695. */
  76696. data: Array<T>;
  76697. /**
  76698. * The active length of the array.
  76699. */
  76700. length: number;
  76701. }
  76702. /**
  76703. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76704. */
  76705. export class SmartArray<T> implements ISmartArrayLike<T> {
  76706. /**
  76707. * The full set of data from the array.
  76708. */
  76709. data: Array<T>;
  76710. /**
  76711. * The active length of the array.
  76712. */
  76713. length: number;
  76714. protected _id: number;
  76715. /**
  76716. * Instantiates a Smart Array.
  76717. * @param capacity defines the default capacity of the array.
  76718. */
  76719. constructor(capacity: number);
  76720. /**
  76721. * Pushes a value at the end of the active data.
  76722. * @param value defines the object to push in the array.
  76723. */
  76724. push(value: T): void;
  76725. /**
  76726. * Iterates over the active data and apply the lambda to them.
  76727. * @param func defines the action to apply on each value.
  76728. */
  76729. forEach(func: (content: T) => void): void;
  76730. /**
  76731. * Sorts the full sets of data.
  76732. * @param compareFn defines the comparison function to apply.
  76733. */
  76734. sort(compareFn: (a: T, b: T) => number): void;
  76735. /**
  76736. * Resets the active data to an empty array.
  76737. */
  76738. reset(): void;
  76739. /**
  76740. * Releases all the data from the array as well as the array.
  76741. */
  76742. dispose(): void;
  76743. /**
  76744. * Concats the active data with a given array.
  76745. * @param array defines the data to concatenate with.
  76746. */
  76747. concat(array: any): void;
  76748. /**
  76749. * Returns the position of a value in the active data.
  76750. * @param value defines the value to find the index for
  76751. * @returns the index if found in the active data otherwise -1
  76752. */
  76753. indexOf(value: T): number;
  76754. /**
  76755. * Returns whether an element is part of the active data.
  76756. * @param value defines the value to look for
  76757. * @returns true if found in the active data otherwise false
  76758. */
  76759. contains(value: T): boolean;
  76760. private static _GlobalId;
  76761. }
  76762. /**
  76763. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76764. * The data in this array can only be present once
  76765. */
  76766. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76767. private _duplicateId;
  76768. /**
  76769. * Pushes a value at the end of the active data.
  76770. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76771. * @param value defines the object to push in the array.
  76772. */
  76773. push(value: T): void;
  76774. /**
  76775. * Pushes a value at the end of the active data.
  76776. * If the data is already present, it won t be added again
  76777. * @param value defines the object to push in the array.
  76778. * @returns true if added false if it was already present
  76779. */
  76780. pushNoDuplicate(value: T): boolean;
  76781. /**
  76782. * Resets the active data to an empty array.
  76783. */
  76784. reset(): void;
  76785. /**
  76786. * Concats the active data with a given array.
  76787. * This ensures no dupplicate will be present in the result.
  76788. * @param array defines the data to concatenate with.
  76789. */
  76790. concatWithNoDuplicate(array: any): void;
  76791. }
  76792. }
  76793. declare module BABYLON {
  76794. /**
  76795. * @ignore
  76796. * This is a list of all the different input types that are available in the application.
  76797. * Fo instance: ArcRotateCameraGamepadInput...
  76798. */
  76799. export var CameraInputTypes: {};
  76800. /**
  76801. * This is the contract to implement in order to create a new input class.
  76802. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76803. */
  76804. export interface ICameraInput<TCamera extends Camera> {
  76805. /**
  76806. * Defines the camera the input is attached to.
  76807. */
  76808. camera: Nullable<TCamera>;
  76809. /**
  76810. * Gets the class name of the current intput.
  76811. * @returns the class name
  76812. */
  76813. getClassName(): string;
  76814. /**
  76815. * Get the friendly name associated with the input class.
  76816. * @returns the input friendly name
  76817. */
  76818. getSimpleName(): string;
  76819. /**
  76820. * Attach the input controls to a specific dom element to get the input from.
  76821. * @param element Defines the element the controls should be listened from
  76822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76823. */
  76824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76825. /**
  76826. * Detach the current controls from the specified dom element.
  76827. * @param element Defines the element to stop listening the inputs from
  76828. */
  76829. detachControl(element: Nullable<HTMLElement>): void;
  76830. /**
  76831. * Update the current camera state depending on the inputs that have been used this frame.
  76832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76833. */
  76834. checkInputs?: () => void;
  76835. }
  76836. /**
  76837. * Represents a map of input types to input instance or input index to input instance.
  76838. */
  76839. export interface CameraInputsMap<TCamera extends Camera> {
  76840. /**
  76841. * Accessor to the input by input type.
  76842. */
  76843. [name: string]: ICameraInput<TCamera>;
  76844. /**
  76845. * Accessor to the input by input index.
  76846. */
  76847. [idx: number]: ICameraInput<TCamera>;
  76848. }
  76849. /**
  76850. * This represents the input manager used within a camera.
  76851. * It helps dealing with all the different kind of input attached to a camera.
  76852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76853. */
  76854. export class CameraInputsManager<TCamera extends Camera> {
  76855. /**
  76856. * Defines the list of inputs attahed to the camera.
  76857. */
  76858. attached: CameraInputsMap<TCamera>;
  76859. /**
  76860. * Defines the dom element the camera is collecting inputs from.
  76861. * This is null if the controls have not been attached.
  76862. */
  76863. attachedElement: Nullable<HTMLElement>;
  76864. /**
  76865. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76866. */
  76867. noPreventDefault: boolean;
  76868. /**
  76869. * Defined the camera the input manager belongs to.
  76870. */
  76871. camera: TCamera;
  76872. /**
  76873. * Update the current camera state depending on the inputs that have been used this frame.
  76874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76875. */
  76876. checkInputs: () => void;
  76877. /**
  76878. * Instantiate a new Camera Input Manager.
  76879. * @param camera Defines the camera the input manager blongs to
  76880. */
  76881. constructor(camera: TCamera);
  76882. /**
  76883. * Add an input method to a camera
  76884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76885. * @param input camera input method
  76886. */
  76887. add(input: ICameraInput<TCamera>): void;
  76888. /**
  76889. * Remove a specific input method from a camera
  76890. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76891. * @param inputToRemove camera input method
  76892. */
  76893. remove(inputToRemove: ICameraInput<TCamera>): void;
  76894. /**
  76895. * Remove a specific input type from a camera
  76896. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76897. * @param inputType the type of the input to remove
  76898. */
  76899. removeByType(inputType: string): void;
  76900. private _addCheckInputs;
  76901. /**
  76902. * Attach the input controls to the currently attached dom element to listen the events from.
  76903. * @param input Defines the input to attach
  76904. */
  76905. attachInput(input: ICameraInput<TCamera>): void;
  76906. /**
  76907. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76908. * @param element Defines the dom element to collect the events from
  76909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76910. */
  76911. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76912. /**
  76913. * Detach the current manager inputs controls from a specific dom element.
  76914. * @param element Defines the dom element to collect the events from
  76915. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76916. */
  76917. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76918. /**
  76919. * Rebuild the dynamic inputCheck function from the current list of
  76920. * defined inputs in the manager.
  76921. */
  76922. rebuildInputCheck(): void;
  76923. /**
  76924. * Remove all attached input methods from a camera
  76925. */
  76926. clear(): void;
  76927. /**
  76928. * Serialize the current input manager attached to a camera.
  76929. * This ensures than once parsed,
  76930. * the input associated to the camera will be identical to the current ones
  76931. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76932. */
  76933. serialize(serializedCamera: any): void;
  76934. /**
  76935. * Parses an input manager serialized JSON to restore the previous list of inputs
  76936. * and states associated to a camera.
  76937. * @param parsedCamera Defines the JSON to parse
  76938. */
  76939. parse(parsedCamera: any): void;
  76940. }
  76941. }
  76942. declare module BABYLON {
  76943. /**
  76944. * Class used to store data that will be store in GPU memory
  76945. */
  76946. export class Buffer {
  76947. private _engine;
  76948. private _buffer;
  76949. /** @hidden */
  76950. _data: Nullable<DataArray>;
  76951. private _updatable;
  76952. private _instanced;
  76953. private _divisor;
  76954. /**
  76955. * Gets the byte stride.
  76956. */
  76957. readonly byteStride: number;
  76958. /**
  76959. * Constructor
  76960. * @param engine the engine
  76961. * @param data the data to use for this buffer
  76962. * @param updatable whether the data is updatable
  76963. * @param stride the stride (optional)
  76964. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76965. * @param instanced whether the buffer is instanced (optional)
  76966. * @param useBytes set to true if the stride in in bytes (optional)
  76967. * @param divisor sets an optional divisor for instances (1 by default)
  76968. */
  76969. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76970. /**
  76971. * Create a new VertexBuffer based on the current buffer
  76972. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76973. * @param offset defines offset in the buffer (0 by default)
  76974. * @param size defines the size in floats of attributes (position is 3 for instance)
  76975. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76976. * @param instanced defines if the vertex buffer contains indexed data
  76977. * @param useBytes defines if the offset and stride are in bytes *
  76978. * @param divisor sets an optional divisor for instances (1 by default)
  76979. * @returns the new vertex buffer
  76980. */
  76981. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76982. /**
  76983. * Gets a boolean indicating if the Buffer is updatable?
  76984. * @returns true if the buffer is updatable
  76985. */
  76986. isUpdatable(): boolean;
  76987. /**
  76988. * Gets current buffer's data
  76989. * @returns a DataArray or null
  76990. */
  76991. getData(): Nullable<DataArray>;
  76992. /**
  76993. * Gets underlying native buffer
  76994. * @returns underlying native buffer
  76995. */
  76996. getBuffer(): Nullable<DataBuffer>;
  76997. /**
  76998. * Gets the stride in float32 units (i.e. byte stride / 4).
  76999. * May not be an integer if the byte stride is not divisible by 4.
  77000. * @returns the stride in float32 units
  77001. * @deprecated Please use byteStride instead.
  77002. */
  77003. getStrideSize(): number;
  77004. /**
  77005. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77006. * @param data defines the data to store
  77007. */
  77008. create(data?: Nullable<DataArray>): void;
  77009. /** @hidden */
  77010. _rebuild(): void;
  77011. /**
  77012. * Update current buffer data
  77013. * @param data defines the data to store
  77014. */
  77015. update(data: DataArray): void;
  77016. /**
  77017. * Updates the data directly.
  77018. * @param data the new data
  77019. * @param offset the new offset
  77020. * @param vertexCount the vertex count (optional)
  77021. * @param useBytes set to true if the offset is in bytes
  77022. */
  77023. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  77024. /**
  77025. * Release all resources
  77026. */
  77027. dispose(): void;
  77028. }
  77029. /**
  77030. * Specialized buffer used to store vertex data
  77031. */
  77032. export class VertexBuffer {
  77033. /** @hidden */
  77034. _buffer: Buffer;
  77035. private _kind;
  77036. private _size;
  77037. private _ownsBuffer;
  77038. private _instanced;
  77039. private _instanceDivisor;
  77040. /**
  77041. * The byte type.
  77042. */
  77043. static readonly BYTE: number;
  77044. /**
  77045. * The unsigned byte type.
  77046. */
  77047. static readonly UNSIGNED_BYTE: number;
  77048. /**
  77049. * The short type.
  77050. */
  77051. static readonly SHORT: number;
  77052. /**
  77053. * The unsigned short type.
  77054. */
  77055. static readonly UNSIGNED_SHORT: number;
  77056. /**
  77057. * The integer type.
  77058. */
  77059. static readonly INT: number;
  77060. /**
  77061. * The unsigned integer type.
  77062. */
  77063. static readonly UNSIGNED_INT: number;
  77064. /**
  77065. * The float type.
  77066. */
  77067. static readonly FLOAT: number;
  77068. /**
  77069. * Gets or sets the instance divisor when in instanced mode
  77070. */
  77071. get instanceDivisor(): number;
  77072. set instanceDivisor(value: number);
  77073. /**
  77074. * Gets the byte stride.
  77075. */
  77076. readonly byteStride: number;
  77077. /**
  77078. * Gets the byte offset.
  77079. */
  77080. readonly byteOffset: number;
  77081. /**
  77082. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77083. */
  77084. readonly normalized: boolean;
  77085. /**
  77086. * Gets the data type of each component in the array.
  77087. */
  77088. readonly type: number;
  77089. /**
  77090. * Constructor
  77091. * @param engine the engine
  77092. * @param data the data to use for this vertex buffer
  77093. * @param kind the vertex buffer kind
  77094. * @param updatable whether the data is updatable
  77095. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77096. * @param stride the stride (optional)
  77097. * @param instanced whether the buffer is instanced (optional)
  77098. * @param offset the offset of the data (optional)
  77099. * @param size the number of components (optional)
  77100. * @param type the type of the component (optional)
  77101. * @param normalized whether the data contains normalized data (optional)
  77102. * @param useBytes set to true if stride and offset are in bytes (optional)
  77103. * @param divisor defines the instance divisor to use (1 by default)
  77104. */
  77105. 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);
  77106. /** @hidden */
  77107. _rebuild(): void;
  77108. /**
  77109. * Returns the kind of the VertexBuffer (string)
  77110. * @returns a string
  77111. */
  77112. getKind(): string;
  77113. /**
  77114. * Gets a boolean indicating if the VertexBuffer is updatable?
  77115. * @returns true if the buffer is updatable
  77116. */
  77117. isUpdatable(): boolean;
  77118. /**
  77119. * Gets current buffer's data
  77120. * @returns a DataArray or null
  77121. */
  77122. getData(): Nullable<DataArray>;
  77123. /**
  77124. * Gets underlying native buffer
  77125. * @returns underlying native buffer
  77126. */
  77127. getBuffer(): Nullable<DataBuffer>;
  77128. /**
  77129. * Gets the stride in float32 units (i.e. byte stride / 4).
  77130. * May not be an integer if the byte stride is not divisible by 4.
  77131. * @returns the stride in float32 units
  77132. * @deprecated Please use byteStride instead.
  77133. */
  77134. getStrideSize(): number;
  77135. /**
  77136. * Returns the offset as a multiple of the type byte length.
  77137. * @returns the offset in bytes
  77138. * @deprecated Please use byteOffset instead.
  77139. */
  77140. getOffset(): number;
  77141. /**
  77142. * Returns the number of components per vertex attribute (integer)
  77143. * @returns the size in float
  77144. */
  77145. getSize(): number;
  77146. /**
  77147. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77148. * @returns true if this buffer is instanced
  77149. */
  77150. getIsInstanced(): boolean;
  77151. /**
  77152. * Returns the instancing divisor, zero for non-instanced (integer).
  77153. * @returns a number
  77154. */
  77155. getInstanceDivisor(): number;
  77156. /**
  77157. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77158. * @param data defines the data to store
  77159. */
  77160. create(data?: DataArray): void;
  77161. /**
  77162. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77163. * This function will create a new buffer if the current one is not updatable
  77164. * @param data defines the data to store
  77165. */
  77166. update(data: DataArray): void;
  77167. /**
  77168. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77169. * Returns the directly updated WebGLBuffer.
  77170. * @param data the new data
  77171. * @param offset the new offset
  77172. * @param useBytes set to true if the offset is in bytes
  77173. */
  77174. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77175. /**
  77176. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77177. */
  77178. dispose(): void;
  77179. /**
  77180. * Enumerates each value of this vertex buffer as numbers.
  77181. * @param count the number of values to enumerate
  77182. * @param callback the callback function called for each value
  77183. */
  77184. forEach(count: number, callback: (value: number, index: number) => void): void;
  77185. /**
  77186. * Positions
  77187. */
  77188. static readonly PositionKind: string;
  77189. /**
  77190. * Normals
  77191. */
  77192. static readonly NormalKind: string;
  77193. /**
  77194. * Tangents
  77195. */
  77196. static readonly TangentKind: string;
  77197. /**
  77198. * Texture coordinates
  77199. */
  77200. static readonly UVKind: string;
  77201. /**
  77202. * Texture coordinates 2
  77203. */
  77204. static readonly UV2Kind: string;
  77205. /**
  77206. * Texture coordinates 3
  77207. */
  77208. static readonly UV3Kind: string;
  77209. /**
  77210. * Texture coordinates 4
  77211. */
  77212. static readonly UV4Kind: string;
  77213. /**
  77214. * Texture coordinates 5
  77215. */
  77216. static readonly UV5Kind: string;
  77217. /**
  77218. * Texture coordinates 6
  77219. */
  77220. static readonly UV6Kind: string;
  77221. /**
  77222. * Colors
  77223. */
  77224. static readonly ColorKind: string;
  77225. /**
  77226. * Matrix indices (for bones)
  77227. */
  77228. static readonly MatricesIndicesKind: string;
  77229. /**
  77230. * Matrix weights (for bones)
  77231. */
  77232. static readonly MatricesWeightsKind: string;
  77233. /**
  77234. * Additional matrix indices (for bones)
  77235. */
  77236. static readonly MatricesIndicesExtraKind: string;
  77237. /**
  77238. * Additional matrix weights (for bones)
  77239. */
  77240. static readonly MatricesWeightsExtraKind: string;
  77241. /**
  77242. * Deduces the stride given a kind.
  77243. * @param kind The kind string to deduce
  77244. * @returns The deduced stride
  77245. */
  77246. static DeduceStride(kind: string): number;
  77247. /**
  77248. * Gets the byte length of the given type.
  77249. * @param type the type
  77250. * @returns the number of bytes
  77251. */
  77252. static GetTypeByteLength(type: number): number;
  77253. /**
  77254. * Enumerates each value of the given parameters as numbers.
  77255. * @param data the data to enumerate
  77256. * @param byteOffset the byte offset of the data
  77257. * @param byteStride the byte stride of the data
  77258. * @param componentCount the number of components per element
  77259. * @param componentType the type of the component
  77260. * @param count the number of values to enumerate
  77261. * @param normalized whether the data is normalized
  77262. * @param callback the callback function called for each value
  77263. */
  77264. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77265. private static _GetFloatValue;
  77266. }
  77267. }
  77268. declare module BABYLON {
  77269. /**
  77270. * @hidden
  77271. */
  77272. export class IntersectionInfo {
  77273. bu: Nullable<number>;
  77274. bv: Nullable<number>;
  77275. distance: number;
  77276. faceId: number;
  77277. subMeshId: number;
  77278. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77279. }
  77280. }
  77281. declare module BABYLON {
  77282. /**
  77283. * Represens a plane by the equation ax + by + cz + d = 0
  77284. */
  77285. export class Plane {
  77286. private static _TmpMatrix;
  77287. /**
  77288. * Normal of the plane (a,b,c)
  77289. */
  77290. normal: Vector3;
  77291. /**
  77292. * d component of the plane
  77293. */
  77294. d: number;
  77295. /**
  77296. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77297. * @param a a component of the plane
  77298. * @param b b component of the plane
  77299. * @param c c component of the plane
  77300. * @param d d component of the plane
  77301. */
  77302. constructor(a: number, b: number, c: number, d: number);
  77303. /**
  77304. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77305. */
  77306. asArray(): number[];
  77307. /**
  77308. * @returns a new plane copied from the current Plane.
  77309. */
  77310. clone(): Plane;
  77311. /**
  77312. * @returns the string "Plane".
  77313. */
  77314. getClassName(): string;
  77315. /**
  77316. * @returns the Plane hash code.
  77317. */
  77318. getHashCode(): number;
  77319. /**
  77320. * Normalize the current Plane in place.
  77321. * @returns the updated Plane.
  77322. */
  77323. normalize(): Plane;
  77324. /**
  77325. * Applies a transformation the plane and returns the result
  77326. * @param transformation the transformation matrix to be applied to the plane
  77327. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77328. */
  77329. transform(transformation: DeepImmutable<Matrix>): Plane;
  77330. /**
  77331. * Calcualtte the dot product between the point and the plane normal
  77332. * @param point point to calculate the dot product with
  77333. * @returns the dot product (float) of the point coordinates and the plane normal.
  77334. */
  77335. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77336. /**
  77337. * Updates the current Plane from the plane defined by the three given points.
  77338. * @param point1 one of the points used to contruct the plane
  77339. * @param point2 one of the points used to contruct the plane
  77340. * @param point3 one of the points used to contruct the plane
  77341. * @returns the updated Plane.
  77342. */
  77343. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77344. /**
  77345. * Checks if the plane is facing a given direction
  77346. * @param direction the direction to check if the plane is facing
  77347. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77348. * @returns True is the vector "direction" is the same side than the plane normal.
  77349. */
  77350. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77351. /**
  77352. * Calculates the distance to a point
  77353. * @param point point to calculate distance to
  77354. * @returns the signed distance (float) from the given point to the Plane.
  77355. */
  77356. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77357. /**
  77358. * Creates a plane from an array
  77359. * @param array the array to create a plane from
  77360. * @returns a new Plane from the given array.
  77361. */
  77362. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77363. /**
  77364. * Creates a plane from three points
  77365. * @param point1 point used to create the plane
  77366. * @param point2 point used to create the plane
  77367. * @param point3 point used to create the plane
  77368. * @returns a new Plane defined by the three given points.
  77369. */
  77370. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77371. /**
  77372. * Creates a plane from an origin point and a normal
  77373. * @param origin origin of the plane to be constructed
  77374. * @param normal normal of the plane to be constructed
  77375. * @returns a new Plane the normal vector to this plane at the given origin point.
  77376. * Note : the vector "normal" is updated because normalized.
  77377. */
  77378. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77379. /**
  77380. * Calculates the distance from a plane and a point
  77381. * @param origin origin of the plane to be constructed
  77382. * @param normal normal of the plane to be constructed
  77383. * @param point point to calculate distance to
  77384. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77385. */
  77386. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77387. }
  77388. }
  77389. declare module BABYLON {
  77390. /**
  77391. * Class used to store bounding sphere information
  77392. */
  77393. export class BoundingSphere {
  77394. /**
  77395. * Gets the center of the bounding sphere in local space
  77396. */
  77397. readonly center: Vector3;
  77398. /**
  77399. * Radius of the bounding sphere in local space
  77400. */
  77401. radius: number;
  77402. /**
  77403. * Gets the center of the bounding sphere in world space
  77404. */
  77405. readonly centerWorld: Vector3;
  77406. /**
  77407. * Radius of the bounding sphere in world space
  77408. */
  77409. radiusWorld: number;
  77410. /**
  77411. * Gets the minimum vector in local space
  77412. */
  77413. readonly minimum: Vector3;
  77414. /**
  77415. * Gets the maximum vector in local space
  77416. */
  77417. readonly maximum: Vector3;
  77418. private _worldMatrix;
  77419. private static readonly TmpVector3;
  77420. /**
  77421. * Creates a new bounding sphere
  77422. * @param min defines the minimum vector (in local space)
  77423. * @param max defines the maximum vector (in local space)
  77424. * @param worldMatrix defines the new world matrix
  77425. */
  77426. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77427. /**
  77428. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77429. * @param min defines the new minimum vector (in local space)
  77430. * @param max defines the new maximum vector (in local space)
  77431. * @param worldMatrix defines the new world matrix
  77432. */
  77433. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77434. /**
  77435. * Scale the current bounding sphere by applying a scale factor
  77436. * @param factor defines the scale factor to apply
  77437. * @returns the current bounding box
  77438. */
  77439. scale(factor: number): BoundingSphere;
  77440. /**
  77441. * Gets the world matrix of the bounding box
  77442. * @returns a matrix
  77443. */
  77444. getWorldMatrix(): DeepImmutable<Matrix>;
  77445. /** @hidden */
  77446. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77447. /**
  77448. * Tests if the bounding sphere is intersecting the frustum planes
  77449. * @param frustumPlanes defines the frustum planes to test
  77450. * @returns true if there is an intersection
  77451. */
  77452. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77453. /**
  77454. * Tests if the bounding sphere center is in between the frustum planes.
  77455. * Used for optimistic fast inclusion.
  77456. * @param frustumPlanes defines the frustum planes to test
  77457. * @returns true if the sphere center is in between the frustum planes
  77458. */
  77459. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77460. /**
  77461. * Tests if a point is inside the bounding sphere
  77462. * @param point defines the point to test
  77463. * @returns true if the point is inside the bounding sphere
  77464. */
  77465. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77466. /**
  77467. * Checks if two sphere intersct
  77468. * @param sphere0 sphere 0
  77469. * @param sphere1 sphere 1
  77470. * @returns true if the speres intersect
  77471. */
  77472. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77473. }
  77474. }
  77475. declare module BABYLON {
  77476. /**
  77477. * Class used to store bounding box information
  77478. */
  77479. export class BoundingBox implements ICullable {
  77480. /**
  77481. * Gets the 8 vectors representing the bounding box in local space
  77482. */
  77483. readonly vectors: Vector3[];
  77484. /**
  77485. * Gets the center of the bounding box in local space
  77486. */
  77487. readonly center: Vector3;
  77488. /**
  77489. * Gets the center of the bounding box in world space
  77490. */
  77491. readonly centerWorld: Vector3;
  77492. /**
  77493. * Gets the extend size in local space
  77494. */
  77495. readonly extendSize: Vector3;
  77496. /**
  77497. * Gets the extend size in world space
  77498. */
  77499. readonly extendSizeWorld: Vector3;
  77500. /**
  77501. * Gets the OBB (object bounding box) directions
  77502. */
  77503. readonly directions: Vector3[];
  77504. /**
  77505. * Gets the 8 vectors representing the bounding box in world space
  77506. */
  77507. readonly vectorsWorld: Vector3[];
  77508. /**
  77509. * Gets the minimum vector in world space
  77510. */
  77511. readonly minimumWorld: Vector3;
  77512. /**
  77513. * Gets the maximum vector in world space
  77514. */
  77515. readonly maximumWorld: Vector3;
  77516. /**
  77517. * Gets the minimum vector in local space
  77518. */
  77519. readonly minimum: Vector3;
  77520. /**
  77521. * Gets the maximum vector in local space
  77522. */
  77523. readonly maximum: Vector3;
  77524. private _worldMatrix;
  77525. private static readonly TmpVector3;
  77526. /**
  77527. * @hidden
  77528. */
  77529. _tag: number;
  77530. /**
  77531. * Creates a new bounding box
  77532. * @param min defines the minimum vector (in local space)
  77533. * @param max defines the maximum vector (in local space)
  77534. * @param worldMatrix defines the new world matrix
  77535. */
  77536. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77537. /**
  77538. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77539. * @param min defines the new minimum vector (in local space)
  77540. * @param max defines the new maximum vector (in local space)
  77541. * @param worldMatrix defines the new world matrix
  77542. */
  77543. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77544. /**
  77545. * Scale the current bounding box by applying a scale factor
  77546. * @param factor defines the scale factor to apply
  77547. * @returns the current bounding box
  77548. */
  77549. scale(factor: number): BoundingBox;
  77550. /**
  77551. * Gets the world matrix of the bounding box
  77552. * @returns a matrix
  77553. */
  77554. getWorldMatrix(): DeepImmutable<Matrix>;
  77555. /** @hidden */
  77556. _update(world: DeepImmutable<Matrix>): void;
  77557. /**
  77558. * Tests if the bounding box is intersecting the frustum planes
  77559. * @param frustumPlanes defines the frustum planes to test
  77560. * @returns true if there is an intersection
  77561. */
  77562. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77563. /**
  77564. * Tests if the bounding box is entirely inside the frustum planes
  77565. * @param frustumPlanes defines the frustum planes to test
  77566. * @returns true if there is an inclusion
  77567. */
  77568. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77569. /**
  77570. * Tests if a point is inside the bounding box
  77571. * @param point defines the point to test
  77572. * @returns true if the point is inside the bounding box
  77573. */
  77574. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77575. /**
  77576. * Tests if the bounding box intersects with a bounding sphere
  77577. * @param sphere defines the sphere to test
  77578. * @returns true if there is an intersection
  77579. */
  77580. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77581. /**
  77582. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77583. * @param min defines the min vector to use
  77584. * @param max defines the max vector to use
  77585. * @returns true if there is an intersection
  77586. */
  77587. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77588. /**
  77589. * Tests if two bounding boxes are intersections
  77590. * @param box0 defines the first box to test
  77591. * @param box1 defines the second box to test
  77592. * @returns true if there is an intersection
  77593. */
  77594. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77595. /**
  77596. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77597. * @param minPoint defines the minimum vector of the bounding box
  77598. * @param maxPoint defines the maximum vector of the bounding box
  77599. * @param sphereCenter defines the sphere center
  77600. * @param sphereRadius defines the sphere radius
  77601. * @returns true if there is an intersection
  77602. */
  77603. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77604. /**
  77605. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77606. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77607. * @param frustumPlanes defines the frustum planes to test
  77608. * @return true if there is an inclusion
  77609. */
  77610. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77611. /**
  77612. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77613. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77614. * @param frustumPlanes defines the frustum planes to test
  77615. * @return true if there is an intersection
  77616. */
  77617. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77618. }
  77619. }
  77620. declare module BABYLON {
  77621. /** @hidden */
  77622. export class Collider {
  77623. /** Define if a collision was found */
  77624. collisionFound: boolean;
  77625. /**
  77626. * Define last intersection point in local space
  77627. */
  77628. intersectionPoint: Vector3;
  77629. /**
  77630. * Define last collided mesh
  77631. */
  77632. collidedMesh: Nullable<AbstractMesh>;
  77633. private _collisionPoint;
  77634. private _planeIntersectionPoint;
  77635. private _tempVector;
  77636. private _tempVector2;
  77637. private _tempVector3;
  77638. private _tempVector4;
  77639. private _edge;
  77640. private _baseToVertex;
  77641. private _destinationPoint;
  77642. private _slidePlaneNormal;
  77643. private _displacementVector;
  77644. /** @hidden */
  77645. _radius: Vector3;
  77646. /** @hidden */
  77647. _retry: number;
  77648. private _velocity;
  77649. private _basePoint;
  77650. private _epsilon;
  77651. /** @hidden */
  77652. _velocityWorldLength: number;
  77653. /** @hidden */
  77654. _basePointWorld: Vector3;
  77655. private _velocityWorld;
  77656. private _normalizedVelocity;
  77657. /** @hidden */
  77658. _initialVelocity: Vector3;
  77659. /** @hidden */
  77660. _initialPosition: Vector3;
  77661. private _nearestDistance;
  77662. private _collisionMask;
  77663. get collisionMask(): number;
  77664. set collisionMask(mask: number);
  77665. /**
  77666. * Gets the plane normal used to compute the sliding response (in local space)
  77667. */
  77668. get slidePlaneNormal(): Vector3;
  77669. /** @hidden */
  77670. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77671. /** @hidden */
  77672. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77673. /** @hidden */
  77674. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77675. /** @hidden */
  77676. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77677. /** @hidden */
  77678. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77679. /** @hidden */
  77680. _getResponse(pos: Vector3, vel: Vector3): void;
  77681. }
  77682. }
  77683. declare module BABYLON {
  77684. /**
  77685. * Interface for cullable objects
  77686. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77687. */
  77688. export interface ICullable {
  77689. /**
  77690. * Checks if the object or part of the object is in the frustum
  77691. * @param frustumPlanes Camera near/planes
  77692. * @returns true if the object is in frustum otherwise false
  77693. */
  77694. isInFrustum(frustumPlanes: Plane[]): boolean;
  77695. /**
  77696. * Checks if a cullable object (mesh...) is in the camera frustum
  77697. * Unlike isInFrustum this cheks the full bounding box
  77698. * @param frustumPlanes Camera near/planes
  77699. * @returns true if the object is in frustum otherwise false
  77700. */
  77701. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77702. }
  77703. /**
  77704. * Info for a bounding data of a mesh
  77705. */
  77706. export class BoundingInfo implements ICullable {
  77707. /**
  77708. * Bounding box for the mesh
  77709. */
  77710. readonly boundingBox: BoundingBox;
  77711. /**
  77712. * Bounding sphere for the mesh
  77713. */
  77714. readonly boundingSphere: BoundingSphere;
  77715. private _isLocked;
  77716. private static readonly TmpVector3;
  77717. /**
  77718. * Constructs bounding info
  77719. * @param minimum min vector of the bounding box/sphere
  77720. * @param maximum max vector of the bounding box/sphere
  77721. * @param worldMatrix defines the new world matrix
  77722. */
  77723. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77724. /**
  77725. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77726. * @param min defines the new minimum vector (in local space)
  77727. * @param max defines the new maximum vector (in local space)
  77728. * @param worldMatrix defines the new world matrix
  77729. */
  77730. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77731. /**
  77732. * min vector of the bounding box/sphere
  77733. */
  77734. get minimum(): Vector3;
  77735. /**
  77736. * max vector of the bounding box/sphere
  77737. */
  77738. get maximum(): Vector3;
  77739. /**
  77740. * If the info is locked and won't be updated to avoid perf overhead
  77741. */
  77742. get isLocked(): boolean;
  77743. set isLocked(value: boolean);
  77744. /**
  77745. * Updates the bounding sphere and box
  77746. * @param world world matrix to be used to update
  77747. */
  77748. update(world: DeepImmutable<Matrix>): void;
  77749. /**
  77750. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77751. * @param center New center of the bounding info
  77752. * @param extend New extend of the bounding info
  77753. * @returns the current bounding info
  77754. */
  77755. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77756. /**
  77757. * Scale the current bounding info by applying a scale factor
  77758. * @param factor defines the scale factor to apply
  77759. * @returns the current bounding info
  77760. */
  77761. scale(factor: number): BoundingInfo;
  77762. /**
  77763. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77764. * @param frustumPlanes defines the frustum to test
  77765. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77766. * @returns true if the bounding info is in the frustum planes
  77767. */
  77768. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77769. /**
  77770. * Gets the world distance between the min and max points of the bounding box
  77771. */
  77772. get diagonalLength(): number;
  77773. /**
  77774. * Checks if a cullable object (mesh...) is in the camera frustum
  77775. * Unlike isInFrustum this cheks the full bounding box
  77776. * @param frustumPlanes Camera near/planes
  77777. * @returns true if the object is in frustum otherwise false
  77778. */
  77779. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77780. /** @hidden */
  77781. _checkCollision(collider: Collider): boolean;
  77782. /**
  77783. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77784. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77785. * @param point the point to check intersection with
  77786. * @returns if the point intersects
  77787. */
  77788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77789. /**
  77790. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77791. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77792. * @param boundingInfo the bounding info to check intersection with
  77793. * @param precise if the intersection should be done using OBB
  77794. * @returns if the bounding info intersects
  77795. */
  77796. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77797. }
  77798. }
  77799. declare module BABYLON {
  77800. /**
  77801. * Extracts minimum and maximum values from a list of indexed positions
  77802. * @param positions defines the positions to use
  77803. * @param indices defines the indices to the positions
  77804. * @param indexStart defines the start index
  77805. * @param indexCount defines the end index
  77806. * @param bias defines bias value to add to the result
  77807. * @return minimum and maximum values
  77808. */
  77809. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77810. minimum: Vector3;
  77811. maximum: Vector3;
  77812. };
  77813. /**
  77814. * Extracts minimum and maximum values from a list of positions
  77815. * @param positions defines the positions to use
  77816. * @param start defines the start index in the positions array
  77817. * @param count defines the number of positions to handle
  77818. * @param bias defines bias value to add to the result
  77819. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77820. * @return minimum and maximum values
  77821. */
  77822. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77823. minimum: Vector3;
  77824. maximum: Vector3;
  77825. };
  77826. }
  77827. declare module BABYLON {
  77828. /** @hidden */
  77829. export class WebGLDataBuffer extends DataBuffer {
  77830. private _buffer;
  77831. constructor(resource: WebGLBuffer);
  77832. get underlyingResource(): any;
  77833. }
  77834. }
  77835. declare module BABYLON {
  77836. /** @hidden */
  77837. export class WebGLPipelineContext implements IPipelineContext {
  77838. engine: ThinEngine;
  77839. program: Nullable<WebGLProgram>;
  77840. context?: WebGLRenderingContext;
  77841. vertexShader?: WebGLShader;
  77842. fragmentShader?: WebGLShader;
  77843. isParallelCompiled: boolean;
  77844. onCompiled?: () => void;
  77845. transformFeedback?: WebGLTransformFeedback | null;
  77846. vertexCompilationError: Nullable<string>;
  77847. fragmentCompilationError: Nullable<string>;
  77848. programLinkError: Nullable<string>;
  77849. programValidationError: Nullable<string>;
  77850. get isAsync(): boolean;
  77851. get isReady(): boolean;
  77852. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77853. }
  77854. }
  77855. declare module BABYLON {
  77856. interface ThinEngine {
  77857. /**
  77858. * Create an uniform buffer
  77859. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77860. * @param elements defines the content of the uniform buffer
  77861. * @returns the webGL uniform buffer
  77862. */
  77863. createUniformBuffer(elements: FloatArray): DataBuffer;
  77864. /**
  77865. * Create a dynamic uniform buffer
  77866. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77867. * @param elements defines the content of the uniform buffer
  77868. * @returns the webGL uniform buffer
  77869. */
  77870. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77871. /**
  77872. * Update an existing uniform buffer
  77873. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77874. * @param uniformBuffer defines the target uniform buffer
  77875. * @param elements defines the content to update
  77876. * @param offset defines the offset in the uniform buffer where update should start
  77877. * @param count defines the size of the data to update
  77878. */
  77879. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77880. /**
  77881. * Bind an uniform buffer to the current webGL context
  77882. * @param buffer defines the buffer to bind
  77883. */
  77884. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77885. /**
  77886. * Bind a buffer to the current webGL context at a given location
  77887. * @param buffer defines the buffer to bind
  77888. * @param location defines the index where to bind the buffer
  77889. */
  77890. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77891. /**
  77892. * Bind a specific block at a given index in a specific shader program
  77893. * @param pipelineContext defines the pipeline context to use
  77894. * @param blockName defines the block name
  77895. * @param index defines the index where to bind the block
  77896. */
  77897. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77898. }
  77899. }
  77900. declare module BABYLON {
  77901. /**
  77902. * Uniform buffer objects.
  77903. *
  77904. * Handles blocks of uniform on the GPU.
  77905. *
  77906. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77907. *
  77908. * For more information, please refer to :
  77909. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77910. */
  77911. export class UniformBuffer {
  77912. private _engine;
  77913. private _buffer;
  77914. private _data;
  77915. private _bufferData;
  77916. private _dynamic?;
  77917. private _uniformLocations;
  77918. private _uniformSizes;
  77919. private _uniformLocationPointer;
  77920. private _needSync;
  77921. private _noUBO;
  77922. private _currentEffect;
  77923. /** @hidden */
  77924. _alreadyBound: boolean;
  77925. private static _MAX_UNIFORM_SIZE;
  77926. private static _tempBuffer;
  77927. /**
  77928. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77929. * This is dynamic to allow compat with webgl 1 and 2.
  77930. * You will need to pass the name of the uniform as well as the value.
  77931. */
  77932. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77933. /**
  77934. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77935. * This is dynamic to allow compat with webgl 1 and 2.
  77936. * You will need to pass the name of the uniform as well as the value.
  77937. */
  77938. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77939. /**
  77940. * Lambda to Update a single float in a uniform buffer.
  77941. * This is dynamic to allow compat with webgl 1 and 2.
  77942. * You will need to pass the name of the uniform as well as the value.
  77943. */
  77944. updateFloat: (name: string, x: number) => void;
  77945. /**
  77946. * Lambda to Update a vec2 of float in a uniform buffer.
  77947. * This is dynamic to allow compat with webgl 1 and 2.
  77948. * You will need to pass the name of the uniform as well as the value.
  77949. */
  77950. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77951. /**
  77952. * Lambda to Update a vec3 of float in a uniform buffer.
  77953. * This is dynamic to allow compat with webgl 1 and 2.
  77954. * You will need to pass the name of the uniform as well as the value.
  77955. */
  77956. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77957. /**
  77958. * Lambda to Update a vec4 of float in a uniform buffer.
  77959. * This is dynamic to allow compat with webgl 1 and 2.
  77960. * You will need to pass the name of the uniform as well as the value.
  77961. */
  77962. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77963. /**
  77964. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77965. * This is dynamic to allow compat with webgl 1 and 2.
  77966. * You will need to pass the name of the uniform as well as the value.
  77967. */
  77968. updateMatrix: (name: string, mat: Matrix) => void;
  77969. /**
  77970. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77971. * This is dynamic to allow compat with webgl 1 and 2.
  77972. * You will need to pass the name of the uniform as well as the value.
  77973. */
  77974. updateVector3: (name: string, vector: Vector3) => void;
  77975. /**
  77976. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77977. * This is dynamic to allow compat with webgl 1 and 2.
  77978. * You will need to pass the name of the uniform as well as the value.
  77979. */
  77980. updateVector4: (name: string, vector: Vector4) => void;
  77981. /**
  77982. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77983. * This is dynamic to allow compat with webgl 1 and 2.
  77984. * You will need to pass the name of the uniform as well as the value.
  77985. */
  77986. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77987. /**
  77988. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77989. * This is dynamic to allow compat with webgl 1 and 2.
  77990. * You will need to pass the name of the uniform as well as the value.
  77991. */
  77992. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77993. /**
  77994. * Instantiates a new Uniform buffer objects.
  77995. *
  77996. * Handles blocks of uniform on the GPU.
  77997. *
  77998. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77999. *
  78000. * For more information, please refer to :
  78001. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78002. * @param engine Define the engine the buffer is associated with
  78003. * @param data Define the data contained in the buffer
  78004. * @param dynamic Define if the buffer is updatable
  78005. */
  78006. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  78007. /**
  78008. * Indicates if the buffer is using the WebGL2 UBO implementation,
  78009. * or just falling back on setUniformXXX calls.
  78010. */
  78011. get useUbo(): boolean;
  78012. /**
  78013. * Indicates if the WebGL underlying uniform buffer is in sync
  78014. * with the javascript cache data.
  78015. */
  78016. get isSync(): boolean;
  78017. /**
  78018. * Indicates if the WebGL underlying uniform buffer is dynamic.
  78019. * Also, a dynamic UniformBuffer will disable cache verification and always
  78020. * update the underlying WebGL uniform buffer to the GPU.
  78021. * @returns if Dynamic, otherwise false
  78022. */
  78023. isDynamic(): boolean;
  78024. /**
  78025. * The data cache on JS side.
  78026. * @returns the underlying data as a float array
  78027. */
  78028. getData(): Float32Array;
  78029. /**
  78030. * The underlying WebGL Uniform buffer.
  78031. * @returns the webgl buffer
  78032. */
  78033. getBuffer(): Nullable<DataBuffer>;
  78034. /**
  78035. * std140 layout specifies how to align data within an UBO structure.
  78036. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  78037. * for specs.
  78038. */
  78039. private _fillAlignment;
  78040. /**
  78041. * Adds an uniform in the buffer.
  78042. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  78043. * for the layout to be correct !
  78044. * @param name Name of the uniform, as used in the uniform block in the shader.
  78045. * @param size Data size, or data directly.
  78046. */
  78047. addUniform(name: string, size: number | number[]): void;
  78048. /**
  78049. * Adds a Matrix 4x4 to the uniform buffer.
  78050. * @param name Name of the uniform, as used in the uniform block in the shader.
  78051. * @param mat A 4x4 matrix.
  78052. */
  78053. addMatrix(name: string, mat: Matrix): void;
  78054. /**
  78055. * Adds a vec2 to the uniform buffer.
  78056. * @param name Name of the uniform, as used in the uniform block in the shader.
  78057. * @param x Define the x component value of the vec2
  78058. * @param y Define the y component value of the vec2
  78059. */
  78060. addFloat2(name: string, x: number, y: number): void;
  78061. /**
  78062. * Adds a vec3 to the uniform buffer.
  78063. * @param name Name of the uniform, as used in the uniform block in the shader.
  78064. * @param x Define the x component value of the vec3
  78065. * @param y Define the y component value of the vec3
  78066. * @param z Define the z component value of the vec3
  78067. */
  78068. addFloat3(name: string, x: number, y: number, z: number): void;
  78069. /**
  78070. * Adds a vec3 to the uniform buffer.
  78071. * @param name Name of the uniform, as used in the uniform block in the shader.
  78072. * @param color Define the vec3 from a Color
  78073. */
  78074. addColor3(name: string, color: Color3): void;
  78075. /**
  78076. * Adds a vec4 to the uniform buffer.
  78077. * @param name Name of the uniform, as used in the uniform block in the shader.
  78078. * @param color Define the rgb components from a Color
  78079. * @param alpha Define the a component of the vec4
  78080. */
  78081. addColor4(name: string, color: Color3, alpha: number): void;
  78082. /**
  78083. * Adds a vec3 to the uniform buffer.
  78084. * @param name Name of the uniform, as used in the uniform block in the shader.
  78085. * @param vector Define the vec3 components from a Vector
  78086. */
  78087. addVector3(name: string, vector: Vector3): void;
  78088. /**
  78089. * Adds a Matrix 3x3 to the uniform buffer.
  78090. * @param name Name of the uniform, as used in the uniform block in the shader.
  78091. */
  78092. addMatrix3x3(name: string): void;
  78093. /**
  78094. * Adds a Matrix 2x2 to the uniform buffer.
  78095. * @param name Name of the uniform, as used in the uniform block in the shader.
  78096. */
  78097. addMatrix2x2(name: string): void;
  78098. /**
  78099. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78100. */
  78101. create(): void;
  78102. /** @hidden */
  78103. _rebuild(): void;
  78104. /**
  78105. * Updates the WebGL Uniform Buffer on the GPU.
  78106. * If the `dynamic` flag is set to true, no cache comparison is done.
  78107. * Otherwise, the buffer will be updated only if the cache differs.
  78108. */
  78109. update(): void;
  78110. /**
  78111. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78112. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78113. * @param data Define the flattened data
  78114. * @param size Define the size of the data.
  78115. */
  78116. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78117. private _valueCache;
  78118. private _cacheMatrix;
  78119. private _updateMatrix3x3ForUniform;
  78120. private _updateMatrix3x3ForEffect;
  78121. private _updateMatrix2x2ForEffect;
  78122. private _updateMatrix2x2ForUniform;
  78123. private _updateFloatForEffect;
  78124. private _updateFloatForUniform;
  78125. private _updateFloat2ForEffect;
  78126. private _updateFloat2ForUniform;
  78127. private _updateFloat3ForEffect;
  78128. private _updateFloat3ForUniform;
  78129. private _updateFloat4ForEffect;
  78130. private _updateFloat4ForUniform;
  78131. private _updateMatrixForEffect;
  78132. private _updateMatrixForUniform;
  78133. private _updateVector3ForEffect;
  78134. private _updateVector3ForUniform;
  78135. private _updateVector4ForEffect;
  78136. private _updateVector4ForUniform;
  78137. private _updateColor3ForEffect;
  78138. private _updateColor3ForUniform;
  78139. private _updateColor4ForEffect;
  78140. private _updateColor4ForUniform;
  78141. /**
  78142. * Sets a sampler uniform on the effect.
  78143. * @param name Define the name of the sampler.
  78144. * @param texture Define the texture to set in the sampler
  78145. */
  78146. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78147. /**
  78148. * Directly updates the value of the uniform in the cache AND on the GPU.
  78149. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78150. * @param data Define the flattened data
  78151. */
  78152. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78153. /**
  78154. * Binds this uniform buffer to an effect.
  78155. * @param effect Define the effect to bind the buffer to
  78156. * @param name Name of the uniform block in the shader.
  78157. */
  78158. bindToEffect(effect: Effect, name: string): void;
  78159. /**
  78160. * Disposes the uniform buffer.
  78161. */
  78162. dispose(): void;
  78163. }
  78164. }
  78165. declare module BABYLON {
  78166. /**
  78167. * Enum that determines the text-wrapping mode to use.
  78168. */
  78169. export enum InspectableType {
  78170. /**
  78171. * Checkbox for booleans
  78172. */
  78173. Checkbox = 0,
  78174. /**
  78175. * Sliders for numbers
  78176. */
  78177. Slider = 1,
  78178. /**
  78179. * Vector3
  78180. */
  78181. Vector3 = 2,
  78182. /**
  78183. * Quaternions
  78184. */
  78185. Quaternion = 3,
  78186. /**
  78187. * Color3
  78188. */
  78189. Color3 = 4,
  78190. /**
  78191. * String
  78192. */
  78193. String = 5
  78194. }
  78195. /**
  78196. * Interface used to define custom inspectable properties.
  78197. * This interface is used by the inspector to display custom property grids
  78198. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78199. */
  78200. export interface IInspectable {
  78201. /**
  78202. * Gets the label to display
  78203. */
  78204. label: string;
  78205. /**
  78206. * Gets the name of the property to edit
  78207. */
  78208. propertyName: string;
  78209. /**
  78210. * Gets the type of the editor to use
  78211. */
  78212. type: InspectableType;
  78213. /**
  78214. * Gets the minimum value of the property when using in "slider" mode
  78215. */
  78216. min?: number;
  78217. /**
  78218. * Gets the maximum value of the property when using in "slider" mode
  78219. */
  78220. max?: number;
  78221. /**
  78222. * Gets the setp to use when using in "slider" mode
  78223. */
  78224. step?: number;
  78225. }
  78226. }
  78227. declare module BABYLON {
  78228. /**
  78229. * Class used to provide helper for timing
  78230. */
  78231. export class TimingTools {
  78232. /**
  78233. * Polyfill for setImmediate
  78234. * @param action defines the action to execute after the current execution block
  78235. */
  78236. static SetImmediate(action: () => void): void;
  78237. }
  78238. }
  78239. declare module BABYLON {
  78240. /**
  78241. * Class used to enable instatition of objects by class name
  78242. */
  78243. export class InstantiationTools {
  78244. /**
  78245. * Use this object to register external classes like custom textures or material
  78246. * to allow the laoders to instantiate them
  78247. */
  78248. static RegisteredExternalClasses: {
  78249. [key: string]: Object;
  78250. };
  78251. /**
  78252. * Tries to instantiate a new object from a given class name
  78253. * @param className defines the class name to instantiate
  78254. * @returns the new object or null if the system was not able to do the instantiation
  78255. */
  78256. static Instantiate(className: string): any;
  78257. }
  78258. }
  78259. declare module BABYLON {
  78260. /**
  78261. * Define options used to create a depth texture
  78262. */
  78263. export class DepthTextureCreationOptions {
  78264. /** Specifies whether or not a stencil should be allocated in the texture */
  78265. generateStencil?: boolean;
  78266. /** Specifies whether or not bilinear filtering is enable on the texture */
  78267. bilinearFiltering?: boolean;
  78268. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78269. comparisonFunction?: number;
  78270. /** Specifies if the created texture is a cube texture */
  78271. isCube?: boolean;
  78272. }
  78273. }
  78274. declare module BABYLON {
  78275. interface ThinEngine {
  78276. /**
  78277. * Creates a depth stencil cube texture.
  78278. * This is only available in WebGL 2.
  78279. * @param size The size of face edge in the cube texture.
  78280. * @param options The options defining the cube texture.
  78281. * @returns The cube texture
  78282. */
  78283. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78284. /**
  78285. * Creates a cube texture
  78286. * @param rootUrl defines the url where the files to load is located
  78287. * @param scene defines the current scene
  78288. * @param files defines the list of files to load (1 per face)
  78289. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78290. * @param onLoad defines an optional callback raised when the texture is loaded
  78291. * @param onError defines an optional callback raised if there is an issue to load the texture
  78292. * @param format defines the format of the data
  78293. * @param forcedExtension defines the extension to use to pick the right loader
  78294. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78295. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78296. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78297. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78298. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78299. * @returns the cube texture as an InternalTexture
  78300. */
  78301. 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;
  78302. /**
  78303. * Creates a cube texture
  78304. * @param rootUrl defines the url where the files to load is located
  78305. * @param scene defines the current scene
  78306. * @param files defines the list of files to load (1 per face)
  78307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78308. * @param onLoad defines an optional callback raised when the texture is loaded
  78309. * @param onError defines an optional callback raised if there is an issue to load the texture
  78310. * @param format defines the format of the data
  78311. * @param forcedExtension defines the extension to use to pick the right loader
  78312. * @returns the cube texture as an InternalTexture
  78313. */
  78314. 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;
  78315. /**
  78316. * Creates a cube texture
  78317. * @param rootUrl defines the url where the files to load is located
  78318. * @param scene defines the current scene
  78319. * @param files defines the list of files to load (1 per face)
  78320. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78321. * @param onLoad defines an optional callback raised when the texture is loaded
  78322. * @param onError defines an optional callback raised if there is an issue to load the texture
  78323. * @param format defines the format of the data
  78324. * @param forcedExtension defines the extension to use to pick the right loader
  78325. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78328. * @returns the cube texture as an InternalTexture
  78329. */
  78330. 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;
  78331. /** @hidden */
  78332. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78333. /** @hidden */
  78334. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78335. /** @hidden */
  78336. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78337. /** @hidden */
  78338. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78339. /**
  78340. * @hidden
  78341. */
  78342. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78343. }
  78344. }
  78345. declare module BABYLON {
  78346. /**
  78347. * Class for creating a cube texture
  78348. */
  78349. export class CubeTexture extends BaseTexture {
  78350. private _delayedOnLoad;
  78351. /**
  78352. * The url of the texture
  78353. */
  78354. url: string;
  78355. /**
  78356. * Gets or sets the center of the bounding box associated with the cube texture.
  78357. * It must define where the camera used to render the texture was set
  78358. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78359. */
  78360. boundingBoxPosition: Vector3;
  78361. private _boundingBoxSize;
  78362. /**
  78363. * Gets or sets the size of the bounding box associated with the cube texture
  78364. * When defined, the cubemap will switch to local mode
  78365. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78366. * @example https://www.babylonjs-playground.com/#RNASML
  78367. */
  78368. set boundingBoxSize(value: Vector3);
  78369. /**
  78370. * Returns the bounding box size
  78371. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78372. */
  78373. get boundingBoxSize(): Vector3;
  78374. protected _rotationY: number;
  78375. /**
  78376. * Sets texture matrix rotation angle around Y axis in radians.
  78377. */
  78378. set rotationY(value: number);
  78379. /**
  78380. * Gets texture matrix rotation angle around Y axis radians.
  78381. */
  78382. get rotationY(): number;
  78383. /**
  78384. * Are mip maps generated for this texture or not.
  78385. */
  78386. get noMipmap(): boolean;
  78387. private _noMipmap;
  78388. private _files;
  78389. protected _forcedExtension: Nullable<string>;
  78390. private _extensions;
  78391. private _textureMatrix;
  78392. private _format;
  78393. private _createPolynomials;
  78394. /** @hidden */
  78395. _prefiltered: boolean;
  78396. /**
  78397. * Creates a cube texture from an array of image urls
  78398. * @param files defines an array of image urls
  78399. * @param scene defines the hosting scene
  78400. * @param noMipmap specifies if mip maps are not used
  78401. * @returns a cube texture
  78402. */
  78403. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78404. /**
  78405. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78406. * @param url defines the url of the prefiltered texture
  78407. * @param scene defines the scene the texture is attached to
  78408. * @param forcedExtension defines the extension of the file if different from the url
  78409. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78410. * @return the prefiltered texture
  78411. */
  78412. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78413. /**
  78414. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78415. * as prefiltered data.
  78416. * @param rootUrl defines the url of the texture or the root name of the six images
  78417. * @param scene defines the scene the texture is attached to
  78418. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78419. * @param noMipmap defines if mipmaps should be created or not
  78420. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78421. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78422. * @param onError defines a callback triggered in case of error during load
  78423. * @param format defines the internal format to use for the texture once loaded
  78424. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78425. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78426. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78427. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78428. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78429. * @return the cube texture
  78430. */
  78431. 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);
  78432. /**
  78433. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78434. */
  78435. get isPrefiltered(): boolean;
  78436. /**
  78437. * Get the current class name of the texture useful for serialization or dynamic coding.
  78438. * @returns "CubeTexture"
  78439. */
  78440. getClassName(): string;
  78441. /**
  78442. * Update the url (and optional buffer) of this texture if url was null during construction.
  78443. * @param url the url of the texture
  78444. * @param forcedExtension defines the extension to use
  78445. * @param onLoad callback called when the texture is loaded (defaults to null)
  78446. * @param prefiltered Defines whether the updated texture is prefiltered or not
  78447. */
  78448. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  78449. /**
  78450. * Delays loading of the cube texture
  78451. * @param forcedExtension defines the extension to use
  78452. */
  78453. delayLoad(forcedExtension?: string): void;
  78454. /**
  78455. * Returns the reflection texture matrix
  78456. * @returns the reflection texture matrix
  78457. */
  78458. getReflectionTextureMatrix(): Matrix;
  78459. /**
  78460. * Sets the reflection texture matrix
  78461. * @param value Reflection texture matrix
  78462. */
  78463. setReflectionTextureMatrix(value: Matrix): void;
  78464. /**
  78465. * Parses text to create a cube texture
  78466. * @param parsedTexture define the serialized text to read from
  78467. * @param scene defines the hosting scene
  78468. * @param rootUrl defines the root url of the cube texture
  78469. * @returns a cube texture
  78470. */
  78471. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78472. /**
  78473. * Makes a clone, or deep copy, of the cube texture
  78474. * @returns a new cube texture
  78475. */
  78476. clone(): CubeTexture;
  78477. }
  78478. }
  78479. declare module BABYLON {
  78480. /**
  78481. * Manages the defines for the Material
  78482. */
  78483. export class MaterialDefines {
  78484. /** @hidden */
  78485. protected _keys: string[];
  78486. private _isDirty;
  78487. /** @hidden */
  78488. _renderId: number;
  78489. /** @hidden */
  78490. _areLightsDirty: boolean;
  78491. /** @hidden */
  78492. _areLightsDisposed: boolean;
  78493. /** @hidden */
  78494. _areAttributesDirty: boolean;
  78495. /** @hidden */
  78496. _areTexturesDirty: boolean;
  78497. /** @hidden */
  78498. _areFresnelDirty: boolean;
  78499. /** @hidden */
  78500. _areMiscDirty: boolean;
  78501. /** @hidden */
  78502. _areImageProcessingDirty: boolean;
  78503. /** @hidden */
  78504. _normals: boolean;
  78505. /** @hidden */
  78506. _uvs: boolean;
  78507. /** @hidden */
  78508. _needNormals: boolean;
  78509. /** @hidden */
  78510. _needUVs: boolean;
  78511. [id: string]: any;
  78512. /**
  78513. * Specifies if the material needs to be re-calculated
  78514. */
  78515. get isDirty(): boolean;
  78516. /**
  78517. * Marks the material to indicate that it has been re-calculated
  78518. */
  78519. markAsProcessed(): void;
  78520. /**
  78521. * Marks the material to indicate that it needs to be re-calculated
  78522. */
  78523. markAsUnprocessed(): void;
  78524. /**
  78525. * Marks the material to indicate all of its defines need to be re-calculated
  78526. */
  78527. markAllAsDirty(): void;
  78528. /**
  78529. * Marks the material to indicate that image processing needs to be re-calculated
  78530. */
  78531. markAsImageProcessingDirty(): void;
  78532. /**
  78533. * Marks the material to indicate the lights need to be re-calculated
  78534. * @param disposed Defines whether the light is dirty due to dispose or not
  78535. */
  78536. markAsLightDirty(disposed?: boolean): void;
  78537. /**
  78538. * Marks the attribute state as changed
  78539. */
  78540. markAsAttributesDirty(): void;
  78541. /**
  78542. * Marks the texture state as changed
  78543. */
  78544. markAsTexturesDirty(): void;
  78545. /**
  78546. * Marks the fresnel state as changed
  78547. */
  78548. markAsFresnelDirty(): void;
  78549. /**
  78550. * Marks the misc state as changed
  78551. */
  78552. markAsMiscDirty(): void;
  78553. /**
  78554. * Rebuilds the material defines
  78555. */
  78556. rebuild(): void;
  78557. /**
  78558. * Specifies if two material defines are equal
  78559. * @param other - A material define instance to compare to
  78560. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78561. */
  78562. isEqual(other: MaterialDefines): boolean;
  78563. /**
  78564. * Clones this instance's defines to another instance
  78565. * @param other - material defines to clone values to
  78566. */
  78567. cloneTo(other: MaterialDefines): void;
  78568. /**
  78569. * Resets the material define values
  78570. */
  78571. reset(): void;
  78572. /**
  78573. * Converts the material define values to a string
  78574. * @returns - String of material define information
  78575. */
  78576. toString(): string;
  78577. }
  78578. }
  78579. declare module BABYLON {
  78580. /**
  78581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78583. * 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;
  78584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78585. */
  78586. export class ColorCurves {
  78587. private _dirty;
  78588. private _tempColor;
  78589. private _globalCurve;
  78590. private _highlightsCurve;
  78591. private _midtonesCurve;
  78592. private _shadowsCurve;
  78593. private _positiveCurve;
  78594. private _negativeCurve;
  78595. private _globalHue;
  78596. private _globalDensity;
  78597. private _globalSaturation;
  78598. private _globalExposure;
  78599. /**
  78600. * Gets 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. get globalHue(): number;
  78604. /**
  78605. * Sets the global Hue value.
  78606. * 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).
  78607. */
  78608. set globalHue(value: number);
  78609. /**
  78610. * Gets the global Density value.
  78611. * 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.
  78612. * Values less than zero provide a filter of opposite hue.
  78613. */
  78614. get globalDensity(): number;
  78615. /**
  78616. * Sets the global Density value.
  78617. * 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.
  78618. * Values less than zero provide a filter of opposite hue.
  78619. */
  78620. set globalDensity(value: number);
  78621. /**
  78622. * Gets 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. get globalSaturation(): number;
  78626. /**
  78627. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  78629. */
  78630. set globalSaturation(value: number);
  78631. /**
  78632. * Gets 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. get globalExposure(): number;
  78636. /**
  78637. * Sets the global Exposure value.
  78638. * 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.
  78639. */
  78640. set globalExposure(value: number);
  78641. private _highlightsHue;
  78642. private _highlightsDensity;
  78643. private _highlightsSaturation;
  78644. private _highlightsExposure;
  78645. /**
  78646. * Gets 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. get highlightsHue(): number;
  78650. /**
  78651. * Sets the highlights Hue value.
  78652. * 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).
  78653. */
  78654. set highlightsHue(value: number);
  78655. /**
  78656. * Gets the highlights Density value.
  78657. * 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.
  78658. * Values less than zero provide a filter of opposite hue.
  78659. */
  78660. get highlightsDensity(): number;
  78661. /**
  78662. * Sets the highlights Density value.
  78663. * 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.
  78664. * Values less than zero provide a filter of opposite hue.
  78665. */
  78666. set highlightsDensity(value: number);
  78667. /**
  78668. * Gets 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. get highlightsSaturation(): number;
  78672. /**
  78673. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  78675. */
  78676. set highlightsSaturation(value: number);
  78677. /**
  78678. * Gets 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. get highlightsExposure(): number;
  78682. /**
  78683. * Sets the highlights Exposure value.
  78684. * 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.
  78685. */
  78686. set highlightsExposure(value: number);
  78687. private _midtonesHue;
  78688. private _midtonesDensity;
  78689. private _midtonesSaturation;
  78690. private _midtonesExposure;
  78691. /**
  78692. * Gets 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. get midtonesHue(): number;
  78696. /**
  78697. * Sets the midtones Hue value.
  78698. * 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).
  78699. */
  78700. set midtonesHue(value: number);
  78701. /**
  78702. * Gets the midtones Density value.
  78703. * 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.
  78704. * Values less than zero provide a filter of opposite hue.
  78705. */
  78706. get midtonesDensity(): number;
  78707. /**
  78708. * Sets the midtones Density value.
  78709. * 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.
  78710. * Values less than zero provide a filter of opposite hue.
  78711. */
  78712. set midtonesDensity(value: number);
  78713. /**
  78714. * Gets 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. get midtonesSaturation(): number;
  78718. /**
  78719. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  78721. */
  78722. set midtonesSaturation(value: number);
  78723. /**
  78724. * Gets 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. get midtonesExposure(): number;
  78728. /**
  78729. * Sets the midtones Exposure value.
  78730. * 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.
  78731. */
  78732. set midtonesExposure(value: number);
  78733. private _shadowsHue;
  78734. private _shadowsDensity;
  78735. private _shadowsSaturation;
  78736. private _shadowsExposure;
  78737. /**
  78738. * Gets 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. get shadowsHue(): number;
  78742. /**
  78743. * Sets the shadows Hue value.
  78744. * 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).
  78745. */
  78746. set shadowsHue(value: number);
  78747. /**
  78748. * Gets the shadows Density value.
  78749. * 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.
  78750. * Values less than zero provide a filter of opposite hue.
  78751. */
  78752. get shadowsDensity(): number;
  78753. /**
  78754. * Sets the shadows Density value.
  78755. * 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.
  78756. * Values less than zero provide a filter of opposite hue.
  78757. */
  78758. set shadowsDensity(value: number);
  78759. /**
  78760. * Gets 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. get shadowsSaturation(): number;
  78764. /**
  78765. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  78767. */
  78768. set shadowsSaturation(value: number);
  78769. /**
  78770. * Gets 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. get shadowsExposure(): number;
  78774. /**
  78775. * Sets the shadows Exposure value.
  78776. * 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.
  78777. */
  78778. set shadowsExposure(value: number);
  78779. /**
  78780. * Returns the class name
  78781. * @returns The class name
  78782. */
  78783. getClassName(): string;
  78784. /**
  78785. * Binds the color curves to the shader.
  78786. * @param colorCurves The color curve to bind
  78787. * @param effect The effect to bind to
  78788. * @param positiveUniform The positive uniform shader parameter
  78789. * @param neutralUniform The neutral uniform shader parameter
  78790. * @param negativeUniform The negative uniform shader parameter
  78791. */
  78792. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78793. /**
  78794. * Prepare the list of uniforms associated with the ColorCurves effects.
  78795. * @param uniformsList The list of uniforms used in the effect
  78796. */
  78797. static PrepareUniforms(uniformsList: string[]): void;
  78798. /**
  78799. * Returns color grading data based on a hue, density, saturation and exposure value.
  78800. * @param filterHue The hue of the color filter.
  78801. * @param filterDensity The density of the color filter.
  78802. * @param saturation The saturation.
  78803. * @param exposure The exposure.
  78804. * @param result The result data container.
  78805. */
  78806. private getColorGradingDataToRef;
  78807. /**
  78808. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78809. * @param value The input slider value in range [-100,100].
  78810. * @returns Adjusted value.
  78811. */
  78812. private static applyColorGradingSliderNonlinear;
  78813. /**
  78814. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78815. * @param hue The hue (H) input.
  78816. * @param saturation The saturation (S) input.
  78817. * @param brightness The brightness (B) input.
  78818. * @result An RGBA color represented as Vector4.
  78819. */
  78820. private static fromHSBToRef;
  78821. /**
  78822. * Returns a value clamped between min and max
  78823. * @param value The value to clamp
  78824. * @param min The minimum of value
  78825. * @param max The maximum of value
  78826. * @returns The clamped value.
  78827. */
  78828. private static clamp;
  78829. /**
  78830. * Clones the current color curve instance.
  78831. * @return The cloned curves
  78832. */
  78833. clone(): ColorCurves;
  78834. /**
  78835. * Serializes the current color curve instance to a json representation.
  78836. * @return a JSON representation
  78837. */
  78838. serialize(): any;
  78839. /**
  78840. * Parses the color curve from a json representation.
  78841. * @param source the JSON source to parse
  78842. * @return The parsed curves
  78843. */
  78844. static Parse(source: any): ColorCurves;
  78845. }
  78846. }
  78847. declare module BABYLON {
  78848. /**
  78849. * Interface to follow in your material defines to integrate easily the
  78850. * Image proccessing functions.
  78851. * @hidden
  78852. */
  78853. export interface IImageProcessingConfigurationDefines {
  78854. IMAGEPROCESSING: boolean;
  78855. VIGNETTE: boolean;
  78856. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78857. VIGNETTEBLENDMODEOPAQUE: boolean;
  78858. TONEMAPPING: boolean;
  78859. TONEMAPPING_ACES: boolean;
  78860. CONTRAST: boolean;
  78861. EXPOSURE: boolean;
  78862. COLORCURVES: boolean;
  78863. COLORGRADING: boolean;
  78864. COLORGRADING3D: boolean;
  78865. SAMPLER3DGREENDEPTH: boolean;
  78866. SAMPLER3DBGRMAP: boolean;
  78867. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78868. }
  78869. /**
  78870. * @hidden
  78871. */
  78872. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78873. IMAGEPROCESSING: boolean;
  78874. VIGNETTE: boolean;
  78875. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78876. VIGNETTEBLENDMODEOPAQUE: boolean;
  78877. TONEMAPPING: boolean;
  78878. TONEMAPPING_ACES: boolean;
  78879. CONTRAST: boolean;
  78880. COLORCURVES: boolean;
  78881. COLORGRADING: boolean;
  78882. COLORGRADING3D: boolean;
  78883. SAMPLER3DGREENDEPTH: boolean;
  78884. SAMPLER3DBGRMAP: boolean;
  78885. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78886. EXPOSURE: boolean;
  78887. constructor();
  78888. }
  78889. /**
  78890. * This groups together the common properties used for image processing either in direct forward pass
  78891. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78892. * or not.
  78893. */
  78894. export class ImageProcessingConfiguration {
  78895. /**
  78896. * Default tone mapping applied in BabylonJS.
  78897. */
  78898. static readonly TONEMAPPING_STANDARD: number;
  78899. /**
  78900. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78901. * to other engines rendering to increase portability.
  78902. */
  78903. static readonly TONEMAPPING_ACES: number;
  78904. /**
  78905. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78906. */
  78907. colorCurves: Nullable<ColorCurves>;
  78908. private _colorCurvesEnabled;
  78909. /**
  78910. * Gets wether the color curves effect is enabled.
  78911. */
  78912. get colorCurvesEnabled(): boolean;
  78913. /**
  78914. * Sets wether the color curves effect is enabled.
  78915. */
  78916. set colorCurvesEnabled(value: boolean);
  78917. private _colorGradingTexture;
  78918. /**
  78919. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78920. */
  78921. get colorGradingTexture(): Nullable<BaseTexture>;
  78922. /**
  78923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78924. */
  78925. set colorGradingTexture(value: Nullable<BaseTexture>);
  78926. private _colorGradingEnabled;
  78927. /**
  78928. * Gets wether the color grading effect is enabled.
  78929. */
  78930. get colorGradingEnabled(): boolean;
  78931. /**
  78932. * Sets wether the color grading effect is enabled.
  78933. */
  78934. set colorGradingEnabled(value: boolean);
  78935. private _colorGradingWithGreenDepth;
  78936. /**
  78937. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78938. */
  78939. get colorGradingWithGreenDepth(): boolean;
  78940. /**
  78941. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78942. */
  78943. set colorGradingWithGreenDepth(value: boolean);
  78944. private _colorGradingBGR;
  78945. /**
  78946. * Gets wether the color grading texture contains BGR values.
  78947. */
  78948. get colorGradingBGR(): boolean;
  78949. /**
  78950. * Sets wether the color grading texture contains BGR values.
  78951. */
  78952. set colorGradingBGR(value: boolean);
  78953. /** @hidden */
  78954. _exposure: number;
  78955. /**
  78956. * Gets the Exposure used in the effect.
  78957. */
  78958. get exposure(): number;
  78959. /**
  78960. * Sets the Exposure used in the effect.
  78961. */
  78962. set exposure(value: number);
  78963. private _toneMappingEnabled;
  78964. /**
  78965. * Gets wether the tone mapping effect is enabled.
  78966. */
  78967. get toneMappingEnabled(): boolean;
  78968. /**
  78969. * Sets wether the tone mapping effect is enabled.
  78970. */
  78971. set toneMappingEnabled(value: boolean);
  78972. private _toneMappingType;
  78973. /**
  78974. * Gets the type of tone mapping effect.
  78975. */
  78976. get toneMappingType(): number;
  78977. /**
  78978. * Sets the type of tone mapping effect used in BabylonJS.
  78979. */
  78980. set toneMappingType(value: number);
  78981. protected _contrast: number;
  78982. /**
  78983. * Gets the contrast used in the effect.
  78984. */
  78985. get contrast(): number;
  78986. /**
  78987. * Sets the contrast used in the effect.
  78988. */
  78989. set contrast(value: number);
  78990. /**
  78991. * Vignette stretch size.
  78992. */
  78993. vignetteStretch: number;
  78994. /**
  78995. * Vignette centre X Offset.
  78996. */
  78997. vignetteCentreX: number;
  78998. /**
  78999. * Vignette centre Y Offset.
  79000. */
  79001. vignetteCentreY: number;
  79002. /**
  79003. * Vignette weight or intensity of the vignette effect.
  79004. */
  79005. vignetteWeight: number;
  79006. /**
  79007. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  79008. * if vignetteEnabled is set to true.
  79009. */
  79010. vignetteColor: Color4;
  79011. /**
  79012. * Camera field of view used by the Vignette effect.
  79013. */
  79014. vignetteCameraFov: number;
  79015. private _vignetteBlendMode;
  79016. /**
  79017. * Gets the vignette blend mode allowing different kind of effect.
  79018. */
  79019. get vignetteBlendMode(): number;
  79020. /**
  79021. * Sets the vignette blend mode allowing different kind of effect.
  79022. */
  79023. set vignetteBlendMode(value: number);
  79024. private _vignetteEnabled;
  79025. /**
  79026. * Gets wether the vignette effect is enabled.
  79027. */
  79028. get vignetteEnabled(): boolean;
  79029. /**
  79030. * Sets wether the vignette effect is enabled.
  79031. */
  79032. set vignetteEnabled(value: boolean);
  79033. private _applyByPostProcess;
  79034. /**
  79035. * Gets wether the image processing is applied through a post process or not.
  79036. */
  79037. get applyByPostProcess(): boolean;
  79038. /**
  79039. * Sets wether the image processing is applied through a post process or not.
  79040. */
  79041. set applyByPostProcess(value: boolean);
  79042. private _isEnabled;
  79043. /**
  79044. * Gets wether the image processing is enabled or not.
  79045. */
  79046. get isEnabled(): boolean;
  79047. /**
  79048. * Sets wether the image processing is enabled or not.
  79049. */
  79050. set isEnabled(value: boolean);
  79051. /**
  79052. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79053. */
  79054. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79055. /**
  79056. * Method called each time the image processing information changes requires to recompile the effect.
  79057. */
  79058. protected _updateParameters(): void;
  79059. /**
  79060. * Gets the current class name.
  79061. * @return "ImageProcessingConfiguration"
  79062. */
  79063. getClassName(): string;
  79064. /**
  79065. * Prepare the list of uniforms associated with the Image Processing effects.
  79066. * @param uniforms The list of uniforms used in the effect
  79067. * @param defines the list of defines currently in use
  79068. */
  79069. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79070. /**
  79071. * Prepare the list of samplers associated with the Image Processing effects.
  79072. * @param samplersList The list of uniforms used in the effect
  79073. * @param defines the list of defines currently in use
  79074. */
  79075. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79076. /**
  79077. * Prepare the list of defines associated to the shader.
  79078. * @param defines the list of defines to complete
  79079. * @param forPostProcess Define if we are currently in post process mode or not
  79080. */
  79081. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79082. /**
  79083. * Returns true if all the image processing information are ready.
  79084. * @returns True if ready, otherwise, false
  79085. */
  79086. isReady(): boolean;
  79087. /**
  79088. * Binds the image processing to the shader.
  79089. * @param effect The effect to bind to
  79090. * @param overrideAspectRatio Override the aspect ratio of the effect
  79091. */
  79092. bind(effect: Effect, overrideAspectRatio?: number): void;
  79093. /**
  79094. * Clones the current image processing instance.
  79095. * @return The cloned image processing
  79096. */
  79097. clone(): ImageProcessingConfiguration;
  79098. /**
  79099. * Serializes the current image processing instance to a json representation.
  79100. * @return a JSON representation
  79101. */
  79102. serialize(): any;
  79103. /**
  79104. * Parses the image processing from a json representation.
  79105. * @param source the JSON source to parse
  79106. * @return The parsed image processing
  79107. */
  79108. static Parse(source: any): ImageProcessingConfiguration;
  79109. private static _VIGNETTEMODE_MULTIPLY;
  79110. private static _VIGNETTEMODE_OPAQUE;
  79111. /**
  79112. * Used to apply the vignette as a mix with the pixel color.
  79113. */
  79114. static get VIGNETTEMODE_MULTIPLY(): number;
  79115. /**
  79116. * Used to apply the vignette as a replacement of the pixel color.
  79117. */
  79118. static get VIGNETTEMODE_OPAQUE(): number;
  79119. }
  79120. }
  79121. declare module BABYLON {
  79122. /** @hidden */
  79123. export var postprocessVertexShader: {
  79124. name: string;
  79125. shader: string;
  79126. };
  79127. }
  79128. declare module BABYLON {
  79129. interface ThinEngine {
  79130. /**
  79131. * Creates a new render target texture
  79132. * @param size defines the size of the texture
  79133. * @param options defines the options used to create the texture
  79134. * @returns a new render target texture stored in an InternalTexture
  79135. */
  79136. createRenderTargetTexture(size: number | {
  79137. width: number;
  79138. height: number;
  79139. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79140. /**
  79141. * Creates a depth stencil texture.
  79142. * This is only available in WebGL 2 or with the depth texture extension available.
  79143. * @param size The size of face edge in the texture.
  79144. * @param options The options defining the texture.
  79145. * @returns The texture
  79146. */
  79147. createDepthStencilTexture(size: number | {
  79148. width: number;
  79149. height: number;
  79150. }, options: DepthTextureCreationOptions): InternalTexture;
  79151. /** @hidden */
  79152. _createDepthStencilTexture(size: number | {
  79153. width: number;
  79154. height: number;
  79155. }, options: DepthTextureCreationOptions): InternalTexture;
  79156. }
  79157. }
  79158. declare module BABYLON {
  79159. /** Defines supported spaces */
  79160. export enum Space {
  79161. /** Local (object) space */
  79162. LOCAL = 0,
  79163. /** World space */
  79164. WORLD = 1,
  79165. /** Bone space */
  79166. BONE = 2
  79167. }
  79168. /** Defines the 3 main axes */
  79169. export class Axis {
  79170. /** X axis */
  79171. static X: Vector3;
  79172. /** Y axis */
  79173. static Y: Vector3;
  79174. /** Z axis */
  79175. static Z: Vector3;
  79176. }
  79177. }
  79178. declare module BABYLON {
  79179. /**
  79180. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79181. * This is the base of the follow, arc rotate cameras and Free camera
  79182. * @see http://doc.babylonjs.com/features/cameras
  79183. */
  79184. export class TargetCamera extends Camera {
  79185. private static _RigCamTransformMatrix;
  79186. private static _TargetTransformMatrix;
  79187. private static _TargetFocalPoint;
  79188. /**
  79189. * Define the current direction the camera is moving to
  79190. */
  79191. cameraDirection: Vector3;
  79192. /**
  79193. * Define the current rotation the camera is rotating to
  79194. */
  79195. cameraRotation: Vector2;
  79196. /**
  79197. * When set, the up vector of the camera will be updated by the rotation of the camera
  79198. */
  79199. updateUpVectorFromRotation: boolean;
  79200. private _tmpQuaternion;
  79201. /**
  79202. * Define the current rotation of the camera
  79203. */
  79204. rotation: Vector3;
  79205. /**
  79206. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79207. */
  79208. rotationQuaternion: Quaternion;
  79209. /**
  79210. * Define the current speed of the camera
  79211. */
  79212. speed: number;
  79213. /**
  79214. * Add constraint to the camera to prevent it to move freely in all directions and
  79215. * around all axis.
  79216. */
  79217. noRotationConstraint: boolean;
  79218. /**
  79219. * Define the current target of the camera as an object or a position.
  79220. */
  79221. lockedTarget: any;
  79222. /** @hidden */
  79223. _currentTarget: Vector3;
  79224. /** @hidden */
  79225. _initialFocalDistance: number;
  79226. /** @hidden */
  79227. _viewMatrix: Matrix;
  79228. /** @hidden */
  79229. _camMatrix: Matrix;
  79230. /** @hidden */
  79231. _cameraTransformMatrix: Matrix;
  79232. /** @hidden */
  79233. _cameraRotationMatrix: Matrix;
  79234. /** @hidden */
  79235. _referencePoint: Vector3;
  79236. /** @hidden */
  79237. _transformedReferencePoint: Vector3;
  79238. protected _globalCurrentTarget: Vector3;
  79239. protected _globalCurrentUpVector: Vector3;
  79240. /** @hidden */
  79241. _reset: () => void;
  79242. private _defaultUp;
  79243. /**
  79244. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79245. * This is the base of the follow, arc rotate cameras and Free camera
  79246. * @see http://doc.babylonjs.com/features/cameras
  79247. * @param name Defines the name of the camera in the scene
  79248. * @param position Defines the start position of the camera in the scene
  79249. * @param scene Defines the scene the camera belongs to
  79250. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79251. */
  79252. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79253. /**
  79254. * Gets the position in front of the camera at a given distance.
  79255. * @param distance The distance from the camera we want the position to be
  79256. * @returns the position
  79257. */
  79258. getFrontPosition(distance: number): Vector3;
  79259. /** @hidden */
  79260. _getLockedTargetPosition(): Nullable<Vector3>;
  79261. private _storedPosition;
  79262. private _storedRotation;
  79263. private _storedRotationQuaternion;
  79264. /**
  79265. * Store current camera state of the camera (fov, position, rotation, etc..)
  79266. * @returns the camera
  79267. */
  79268. storeState(): Camera;
  79269. /**
  79270. * Restored camera state. You must call storeState() first
  79271. * @returns whether it was successful or not
  79272. * @hidden
  79273. */
  79274. _restoreStateValues(): boolean;
  79275. /** @hidden */
  79276. _initCache(): void;
  79277. /** @hidden */
  79278. _updateCache(ignoreParentClass?: boolean): void;
  79279. /** @hidden */
  79280. _isSynchronizedViewMatrix(): boolean;
  79281. /** @hidden */
  79282. _computeLocalCameraSpeed(): number;
  79283. /**
  79284. * Defines the target the camera should look at.
  79285. * @param target Defines the new target as a Vector or a mesh
  79286. */
  79287. setTarget(target: Vector3): void;
  79288. /**
  79289. * Return the current target position of the camera. This value is expressed in local space.
  79290. * @returns the target position
  79291. */
  79292. getTarget(): Vector3;
  79293. /** @hidden */
  79294. _decideIfNeedsToMove(): boolean;
  79295. /** @hidden */
  79296. _updatePosition(): void;
  79297. /** @hidden */
  79298. _checkInputs(): void;
  79299. protected _updateCameraRotationMatrix(): void;
  79300. /**
  79301. * 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)
  79302. * @returns the current camera
  79303. */
  79304. private _rotateUpVectorWithCameraRotationMatrix;
  79305. private _cachedRotationZ;
  79306. private _cachedQuaternionRotationZ;
  79307. /** @hidden */
  79308. _getViewMatrix(): Matrix;
  79309. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79310. /**
  79311. * @hidden
  79312. */
  79313. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79314. /**
  79315. * @hidden
  79316. */
  79317. _updateRigCameras(): void;
  79318. private _getRigCamPositionAndTarget;
  79319. /**
  79320. * Gets the current object class name.
  79321. * @return the class name
  79322. */
  79323. getClassName(): string;
  79324. }
  79325. }
  79326. declare module BABYLON {
  79327. /**
  79328. * Gather the list of keyboard event types as constants.
  79329. */
  79330. export class KeyboardEventTypes {
  79331. /**
  79332. * The keydown event is fired when a key becomes active (pressed).
  79333. */
  79334. static readonly KEYDOWN: number;
  79335. /**
  79336. * The keyup event is fired when a key has been released.
  79337. */
  79338. static readonly KEYUP: number;
  79339. }
  79340. /**
  79341. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79342. */
  79343. export class KeyboardInfo {
  79344. /**
  79345. * Defines the type of event (KeyboardEventTypes)
  79346. */
  79347. type: number;
  79348. /**
  79349. * Defines the related dom event
  79350. */
  79351. event: KeyboardEvent;
  79352. /**
  79353. * Instantiates a new keyboard info.
  79354. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79355. * @param type Defines the type of event (KeyboardEventTypes)
  79356. * @param event Defines the related dom event
  79357. */
  79358. constructor(
  79359. /**
  79360. * Defines the type of event (KeyboardEventTypes)
  79361. */
  79362. type: number,
  79363. /**
  79364. * Defines the related dom event
  79365. */
  79366. event: KeyboardEvent);
  79367. }
  79368. /**
  79369. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79370. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79371. */
  79372. export class KeyboardInfoPre extends KeyboardInfo {
  79373. /**
  79374. * Defines the type of event (KeyboardEventTypes)
  79375. */
  79376. type: number;
  79377. /**
  79378. * Defines the related dom event
  79379. */
  79380. event: KeyboardEvent;
  79381. /**
  79382. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79383. */
  79384. skipOnPointerObservable: boolean;
  79385. /**
  79386. * Instantiates a new keyboard pre info.
  79387. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79388. * @param type Defines the type of event (KeyboardEventTypes)
  79389. * @param event Defines the related dom event
  79390. */
  79391. constructor(
  79392. /**
  79393. * Defines the type of event (KeyboardEventTypes)
  79394. */
  79395. type: number,
  79396. /**
  79397. * Defines the related dom event
  79398. */
  79399. event: KeyboardEvent);
  79400. }
  79401. }
  79402. declare module BABYLON {
  79403. /**
  79404. * Manage the keyboard inputs to control the movement of a free camera.
  79405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79406. */
  79407. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79408. /**
  79409. * Defines the camera the input is attached to.
  79410. */
  79411. camera: FreeCamera;
  79412. /**
  79413. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79414. */
  79415. keysUp: number[];
  79416. /**
  79417. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79418. */
  79419. keysDown: number[];
  79420. /**
  79421. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79422. */
  79423. keysLeft: number[];
  79424. /**
  79425. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79426. */
  79427. keysRight: number[];
  79428. private _keys;
  79429. private _onCanvasBlurObserver;
  79430. private _onKeyboardObserver;
  79431. private _engine;
  79432. private _scene;
  79433. /**
  79434. * Attach the input controls to a specific dom element to get the input from.
  79435. * @param element Defines the element the controls should be listened from
  79436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79437. */
  79438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79439. /**
  79440. * Detach the current controls from the specified dom element.
  79441. * @param element Defines the element to stop listening the inputs from
  79442. */
  79443. detachControl(element: Nullable<HTMLElement>): void;
  79444. /**
  79445. * Update the current camera state depending on the inputs that have been used this frame.
  79446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79447. */
  79448. checkInputs(): void;
  79449. /**
  79450. * Gets the class name of the current intput.
  79451. * @returns the class name
  79452. */
  79453. getClassName(): string;
  79454. /** @hidden */
  79455. _onLostFocus(): void;
  79456. /**
  79457. * Get the friendly name associated with the input class.
  79458. * @returns the input friendly name
  79459. */
  79460. getSimpleName(): string;
  79461. }
  79462. }
  79463. declare module BABYLON {
  79464. /**
  79465. * Interface describing all the common properties and methods a shadow light needs to implement.
  79466. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79467. * as well as binding the different shadow properties to the effects.
  79468. */
  79469. export interface IShadowLight extends Light {
  79470. /**
  79471. * The light id in the scene (used in scene.findLighById for instance)
  79472. */
  79473. id: string;
  79474. /**
  79475. * The position the shdow will be casted from.
  79476. */
  79477. position: Vector3;
  79478. /**
  79479. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79480. */
  79481. direction: Vector3;
  79482. /**
  79483. * The transformed position. Position of the light in world space taking parenting in account.
  79484. */
  79485. transformedPosition: Vector3;
  79486. /**
  79487. * The transformed direction. Direction of the light in world space taking parenting in account.
  79488. */
  79489. transformedDirection: Vector3;
  79490. /**
  79491. * The friendly name of the light in the scene.
  79492. */
  79493. name: string;
  79494. /**
  79495. * Defines the shadow projection clipping minimum z value.
  79496. */
  79497. shadowMinZ: number;
  79498. /**
  79499. * Defines the shadow projection clipping maximum z value.
  79500. */
  79501. shadowMaxZ: number;
  79502. /**
  79503. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79504. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79505. */
  79506. computeTransformedInformation(): boolean;
  79507. /**
  79508. * Gets the scene the light belongs to.
  79509. * @returns The scene
  79510. */
  79511. getScene(): Scene;
  79512. /**
  79513. * Callback defining a custom Projection Matrix Builder.
  79514. * This can be used to override the default projection matrix computation.
  79515. */
  79516. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79517. /**
  79518. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79519. * @param matrix The materix to updated with the projection information
  79520. * @param viewMatrix The transform matrix of the light
  79521. * @param renderList The list of mesh to render in the map
  79522. * @returns The current light
  79523. */
  79524. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79525. /**
  79526. * Gets the current depth scale used in ESM.
  79527. * @returns The scale
  79528. */
  79529. getDepthScale(): number;
  79530. /**
  79531. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79532. * @returns true if a cube texture needs to be use
  79533. */
  79534. needCube(): boolean;
  79535. /**
  79536. * Detects if the projection matrix requires to be recomputed this frame.
  79537. * @returns true if it requires to be recomputed otherwise, false.
  79538. */
  79539. needProjectionMatrixCompute(): boolean;
  79540. /**
  79541. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79542. */
  79543. forceProjectionMatrixCompute(): void;
  79544. /**
  79545. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79546. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79547. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79548. */
  79549. getShadowDirection(faceIndex?: number): Vector3;
  79550. /**
  79551. * Gets the minZ used for shadow according to both the scene and the light.
  79552. * @param activeCamera The camera we are returning the min for
  79553. * @returns the depth min z
  79554. */
  79555. getDepthMinZ(activeCamera: Camera): number;
  79556. /**
  79557. * Gets the maxZ used for shadow according to both the scene and the light.
  79558. * @param activeCamera The camera we are returning the max for
  79559. * @returns the depth max z
  79560. */
  79561. getDepthMaxZ(activeCamera: Camera): number;
  79562. }
  79563. /**
  79564. * Base implementation IShadowLight
  79565. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79566. */
  79567. export abstract class ShadowLight extends Light implements IShadowLight {
  79568. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79569. protected _position: Vector3;
  79570. protected _setPosition(value: Vector3): void;
  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. get position(): Vector3;
  79576. /**
  79577. * Sets the position the shadow will be casted from. Also use as the light position for both
  79578. * point and spot lights.
  79579. */
  79580. set position(value: Vector3);
  79581. protected _direction: Vector3;
  79582. protected _setDirection(value: Vector3): void;
  79583. /**
  79584. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79585. * Also use as the light direction on spot and directional lights.
  79586. */
  79587. get direction(): Vector3;
  79588. /**
  79589. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79590. * Also use as the light direction on spot and directional lights.
  79591. */
  79592. set direction(value: Vector3);
  79593. protected _shadowMinZ: number;
  79594. /**
  79595. * Gets the shadow projection clipping minimum z value.
  79596. */
  79597. get shadowMinZ(): number;
  79598. /**
  79599. * Sets the shadow projection clipping minimum z value.
  79600. */
  79601. set shadowMinZ(value: number);
  79602. protected _shadowMaxZ: number;
  79603. /**
  79604. * Sets the shadow projection clipping maximum z value.
  79605. */
  79606. get shadowMaxZ(): number;
  79607. /**
  79608. * Gets the shadow projection clipping maximum z value.
  79609. */
  79610. set shadowMaxZ(value: number);
  79611. /**
  79612. * Callback defining a custom Projection Matrix Builder.
  79613. * This can be used to override the default projection matrix computation.
  79614. */
  79615. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79616. /**
  79617. * The transformed position. Position of the light in world space taking parenting in account.
  79618. */
  79619. transformedPosition: Vector3;
  79620. /**
  79621. * The transformed direction. Direction of the light in world space taking parenting in account.
  79622. */
  79623. transformedDirection: Vector3;
  79624. private _needProjectionMatrixCompute;
  79625. /**
  79626. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79627. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79628. */
  79629. computeTransformedInformation(): boolean;
  79630. /**
  79631. * Return the depth scale used for the shadow map.
  79632. * @returns the depth scale.
  79633. */
  79634. getDepthScale(): number;
  79635. /**
  79636. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79637. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79638. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79639. */
  79640. getShadowDirection(faceIndex?: number): Vector3;
  79641. /**
  79642. * Returns the ShadowLight absolute position in the World.
  79643. * @returns the position vector in world space
  79644. */
  79645. getAbsolutePosition(): Vector3;
  79646. /**
  79647. * Sets the ShadowLight direction toward the passed target.
  79648. * @param target The point to target in local space
  79649. * @returns the updated ShadowLight direction
  79650. */
  79651. setDirectionToTarget(target: Vector3): Vector3;
  79652. /**
  79653. * Returns the light rotation in euler definition.
  79654. * @returns the x y z rotation in local space.
  79655. */
  79656. getRotation(): Vector3;
  79657. /**
  79658. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79659. * @returns true if a cube texture needs to be use
  79660. */
  79661. needCube(): boolean;
  79662. /**
  79663. * Detects if the projection matrix requires to be recomputed this frame.
  79664. * @returns true if it requires to be recomputed otherwise, false.
  79665. */
  79666. needProjectionMatrixCompute(): boolean;
  79667. /**
  79668. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79669. */
  79670. forceProjectionMatrixCompute(): void;
  79671. /** @hidden */
  79672. _initCache(): void;
  79673. /** @hidden */
  79674. _isSynchronized(): boolean;
  79675. /**
  79676. * Computes the world matrix of the node
  79677. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79678. * @returns the world matrix
  79679. */
  79680. computeWorldMatrix(force?: boolean): Matrix;
  79681. /**
  79682. * Gets the minZ used for shadow according to both the scene and the light.
  79683. * @param activeCamera The camera we are returning the min for
  79684. * @returns the depth min z
  79685. */
  79686. getDepthMinZ(activeCamera: Camera): number;
  79687. /**
  79688. * Gets the maxZ used for shadow according to both the scene and the light.
  79689. * @param activeCamera The camera we are returning the max for
  79690. * @returns the depth max z
  79691. */
  79692. getDepthMaxZ(activeCamera: Camera): number;
  79693. /**
  79694. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79695. * @param matrix The materix to updated with the projection information
  79696. * @param viewMatrix The transform matrix of the light
  79697. * @param renderList The list of mesh to render in the map
  79698. * @returns The current light
  79699. */
  79700. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79701. }
  79702. }
  79703. declare module BABYLON {
  79704. /**
  79705. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79706. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79707. */
  79708. export class EffectFallbacks implements IEffectFallbacks {
  79709. private _defines;
  79710. private _currentRank;
  79711. private _maxRank;
  79712. private _mesh;
  79713. /**
  79714. * Removes the fallback from the bound mesh.
  79715. */
  79716. unBindMesh(): void;
  79717. /**
  79718. * Adds a fallback on the specified property.
  79719. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79720. * @param define The name of the define in the shader
  79721. */
  79722. addFallback(rank: number, define: string): void;
  79723. /**
  79724. * Sets the mesh to use CPU skinning when needing to fallback.
  79725. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79726. * @param mesh The mesh to use the fallbacks.
  79727. */
  79728. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79729. /**
  79730. * Checks to see if more fallbacks are still availible.
  79731. */
  79732. get hasMoreFallbacks(): boolean;
  79733. /**
  79734. * Removes the defines that should be removed when falling back.
  79735. * @param currentDefines defines the current define statements for the shader.
  79736. * @param effect defines the current effect we try to compile
  79737. * @returns The resulting defines with defines of the current rank removed.
  79738. */
  79739. reduce(currentDefines: string, effect: Effect): string;
  79740. }
  79741. }
  79742. declare module BABYLON {
  79743. /**
  79744. * "Static Class" containing the most commonly used helper while dealing with material for
  79745. * rendering purpose.
  79746. *
  79747. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79748. *
  79749. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79750. */
  79751. export class MaterialHelper {
  79752. /**
  79753. * Bind the current view position to an effect.
  79754. * @param effect The effect to be bound
  79755. * @param scene The scene the eyes position is used from
  79756. */
  79757. static BindEyePosition(effect: Effect, scene: Scene): void;
  79758. /**
  79759. * Helps preparing the defines values about the UVs in used in the effect.
  79760. * UVs are shared as much as we can accross channels in the shaders.
  79761. * @param texture The texture we are preparing the UVs for
  79762. * @param defines The defines to update
  79763. * @param key The channel key "diffuse", "specular"... used in the shader
  79764. */
  79765. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79766. /**
  79767. * Binds a texture matrix value to its corrsponding uniform
  79768. * @param texture The texture to bind the matrix for
  79769. * @param uniformBuffer The uniform buffer receivin the data
  79770. * @param key The channel key "diffuse", "specular"... used in the shader
  79771. */
  79772. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79773. /**
  79774. * Gets the current status of the fog (should it be enabled?)
  79775. * @param mesh defines the mesh to evaluate for fog support
  79776. * @param scene defines the hosting scene
  79777. * @returns true if fog must be enabled
  79778. */
  79779. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79780. /**
  79781. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79782. * @param mesh defines the current mesh
  79783. * @param scene defines the current scene
  79784. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79785. * @param pointsCloud defines if point cloud rendering has to be turned on
  79786. * @param fogEnabled defines if fog has to be turned on
  79787. * @param alphaTest defines if alpha testing has to be turned on
  79788. * @param defines defines the current list of defines
  79789. */
  79790. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79791. /**
  79792. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79793. * @param scene defines the current scene
  79794. * @param engine defines the current engine
  79795. * @param defines specifies the list of active defines
  79796. * @param useInstances defines if instances have to be turned on
  79797. * @param useClipPlane defines if clip plane have to be turned on
  79798. */
  79799. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79800. /**
  79801. * Prepares the defines for bones
  79802. * @param mesh The mesh containing the geometry data we will draw
  79803. * @param defines The defines to update
  79804. */
  79805. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79806. /**
  79807. * Prepares the defines for morph targets
  79808. * @param mesh The mesh containing the geometry data we will draw
  79809. * @param defines The defines to update
  79810. */
  79811. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79812. /**
  79813. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79814. * @param mesh The mesh containing the geometry data we will draw
  79815. * @param defines The defines to update
  79816. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79817. * @param useBones Precise whether bones should be used or not (override mesh info)
  79818. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79819. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79820. * @returns false if defines are considered not dirty and have not been checked
  79821. */
  79822. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79823. /**
  79824. * Prepares the defines related to multiview
  79825. * @param scene The scene we are intending to draw
  79826. * @param defines The defines to update
  79827. */
  79828. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79829. /**
  79830. * Prepares the defines related to the light information passed in parameter
  79831. * @param scene The scene we are intending to draw
  79832. * @param mesh The mesh the effect is compiling for
  79833. * @param light The light the effect is compiling for
  79834. * @param lightIndex The index of the light
  79835. * @param defines The defines to update
  79836. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79837. * @param state Defines the current state regarding what is needed (normals, etc...)
  79838. */
  79839. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79840. needNormals: boolean;
  79841. needRebuild: boolean;
  79842. shadowEnabled: boolean;
  79843. specularEnabled: boolean;
  79844. lightmapMode: boolean;
  79845. }): void;
  79846. /**
  79847. * Prepares the defines related to the light information passed in parameter
  79848. * @param scene The scene we are intending to draw
  79849. * @param mesh The mesh the effect is compiling for
  79850. * @param defines The defines to update
  79851. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79852. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79853. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79854. * @returns true if normals will be required for the rest of the effect
  79855. */
  79856. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79857. /**
  79858. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79859. * @param lightIndex defines the light index
  79860. * @param uniformsList The uniform list
  79861. * @param samplersList The sampler list
  79862. * @param projectedLightTexture defines if projected texture must be used
  79863. * @param uniformBuffersList defines an optional list of uniform buffers
  79864. */
  79865. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79866. /**
  79867. * Prepares the uniforms and samplers list to be used in the effect
  79868. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79869. * @param samplersList The sampler list
  79870. * @param defines The defines helping in the list generation
  79871. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79872. */
  79873. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79874. /**
  79875. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79876. * @param defines The defines to update while falling back
  79877. * @param fallbacks The authorized effect fallbacks
  79878. * @param maxSimultaneousLights The maximum number of lights allowed
  79879. * @param rank the current rank of the Effect
  79880. * @returns The newly affected rank
  79881. */
  79882. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79883. private static _TmpMorphInfluencers;
  79884. /**
  79885. * Prepares the list of attributes required for morph targets according to the effect defines.
  79886. * @param attribs The current list of supported attribs
  79887. * @param mesh The mesh to prepare the morph targets attributes for
  79888. * @param influencers The number of influencers
  79889. */
  79890. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79891. /**
  79892. * Prepares the list of attributes required for morph targets according to the effect defines.
  79893. * @param attribs The current list of supported attribs
  79894. * @param mesh The mesh to prepare the morph targets attributes for
  79895. * @param defines The current Defines of the effect
  79896. */
  79897. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79898. /**
  79899. * Prepares the list of attributes required for bones according to the effect defines.
  79900. * @param attribs The current list of supported attribs
  79901. * @param mesh The mesh to prepare the bones attributes for
  79902. * @param defines The current Defines of the effect
  79903. * @param fallbacks The current efffect fallback strategy
  79904. */
  79905. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79906. /**
  79907. * Check and prepare the list of attributes required for instances according to the effect defines.
  79908. * @param attribs The current list of supported attribs
  79909. * @param defines The current MaterialDefines of the effect
  79910. */
  79911. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79912. /**
  79913. * Add the list of attributes required for instances to the attribs array.
  79914. * @param attribs The current list of supported attribs
  79915. */
  79916. static PushAttributesForInstances(attribs: string[]): void;
  79917. /**
  79918. * Binds the light information to the effect.
  79919. * @param light The light containing the generator
  79920. * @param effect The effect we are binding the data to
  79921. * @param lightIndex The light index in the effect used to render
  79922. */
  79923. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79924. /**
  79925. * Binds the lights information from the scene to the effect for the given mesh.
  79926. * @param light Light to bind
  79927. * @param lightIndex Light index
  79928. * @param scene The scene where the light belongs to
  79929. * @param effect The effect we are binding the data to
  79930. * @param useSpecular Defines if specular is supported
  79931. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79932. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79933. */
  79934. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79935. /**
  79936. * Binds the lights information from the scene to the effect for the given mesh.
  79937. * @param scene The scene the lights belongs to
  79938. * @param mesh The mesh we are binding the information to render
  79939. * @param effect The effect we are binding the data to
  79940. * @param defines The generated defines for the effect
  79941. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79942. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79943. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79944. */
  79945. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79946. private static _tempFogColor;
  79947. /**
  79948. * Binds the fog information from the scene to the effect for the given mesh.
  79949. * @param scene The scene the lights belongs to
  79950. * @param mesh The mesh we are binding the information to render
  79951. * @param effect The effect we are binding the data to
  79952. * @param linearSpace Defines if the fog effect is applied in linear space
  79953. */
  79954. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79955. /**
  79956. * Binds the bones information from the mesh to the effect.
  79957. * @param mesh The mesh we are binding the information to render
  79958. * @param effect The effect we are binding the data to
  79959. */
  79960. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79961. /**
  79962. * Binds the morph targets information from the mesh to the effect.
  79963. * @param abstractMesh The mesh we are binding the information to render
  79964. * @param effect The effect we are binding the data to
  79965. */
  79966. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79967. /**
  79968. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79969. * @param defines The generated defines used in the effect
  79970. * @param effect The effect we are binding the data to
  79971. * @param scene The scene we are willing to render with logarithmic scale for
  79972. */
  79973. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79974. /**
  79975. * Binds the clip plane information from the scene to the effect.
  79976. * @param scene The scene the clip plane information are extracted from
  79977. * @param effect The effect we are binding the data to
  79978. */
  79979. static BindClipPlane(effect: Effect, scene: Scene): void;
  79980. }
  79981. }
  79982. declare module BABYLON {
  79983. /** @hidden */
  79984. export var packingFunctions: {
  79985. name: string;
  79986. shader: string;
  79987. };
  79988. }
  79989. declare module BABYLON {
  79990. /** @hidden */
  79991. export var shadowMapPixelShader: {
  79992. name: string;
  79993. shader: string;
  79994. };
  79995. }
  79996. declare module BABYLON {
  79997. /** @hidden */
  79998. export var bonesDeclaration: {
  79999. name: string;
  80000. shader: string;
  80001. };
  80002. }
  80003. declare module BABYLON {
  80004. /** @hidden */
  80005. export var morphTargetsVertexGlobalDeclaration: {
  80006. name: string;
  80007. shader: string;
  80008. };
  80009. }
  80010. declare module BABYLON {
  80011. /** @hidden */
  80012. export var morphTargetsVertexDeclaration: {
  80013. name: string;
  80014. shader: string;
  80015. };
  80016. }
  80017. declare module BABYLON {
  80018. /** @hidden */
  80019. export var instancesDeclaration: {
  80020. name: string;
  80021. shader: string;
  80022. };
  80023. }
  80024. declare module BABYLON {
  80025. /** @hidden */
  80026. export var helperFunctions: {
  80027. name: string;
  80028. shader: string;
  80029. };
  80030. }
  80031. declare module BABYLON {
  80032. /** @hidden */
  80033. export var morphTargetsVertex: {
  80034. name: string;
  80035. shader: string;
  80036. };
  80037. }
  80038. declare module BABYLON {
  80039. /** @hidden */
  80040. export var instancesVertex: {
  80041. name: string;
  80042. shader: string;
  80043. };
  80044. }
  80045. declare module BABYLON {
  80046. /** @hidden */
  80047. export var bonesVertex: {
  80048. name: string;
  80049. shader: string;
  80050. };
  80051. }
  80052. declare module BABYLON {
  80053. /** @hidden */
  80054. export var shadowMapVertexShader: {
  80055. name: string;
  80056. shader: string;
  80057. };
  80058. }
  80059. declare module BABYLON {
  80060. /** @hidden */
  80061. export var depthBoxBlurPixelShader: {
  80062. name: string;
  80063. shader: string;
  80064. };
  80065. }
  80066. declare module BABYLON {
  80067. /**
  80068. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80069. */
  80070. export interface ICustomShaderOptions {
  80071. /**
  80072. * Gets or sets the custom shader name to use
  80073. */
  80074. shaderName: string;
  80075. /**
  80076. * The list of attribute names used in the shader
  80077. */
  80078. attributes?: string[];
  80079. /**
  80080. * The list of unifrom names used in the shader
  80081. */
  80082. uniforms?: string[];
  80083. /**
  80084. * The list of sampler names used in the shader
  80085. */
  80086. samplers?: string[];
  80087. /**
  80088. * The list of defines used in the shader
  80089. */
  80090. defines?: string[];
  80091. }
  80092. /**
  80093. * Interface to implement to create a shadow generator compatible with BJS.
  80094. */
  80095. export interface IShadowGenerator {
  80096. /**
  80097. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80098. * @returns The render target texture if present otherwise, null
  80099. */
  80100. getShadowMap(): Nullable<RenderTargetTexture>;
  80101. /**
  80102. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80103. * @returns The render target texture if the shadow map is present otherwise, null
  80104. */
  80105. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80106. /**
  80107. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80108. * @param subMesh The submesh we want to render in the shadow map
  80109. * @param useInstances Defines wether will draw in the map using instances
  80110. * @returns true if ready otherwise, false
  80111. */
  80112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80113. /**
  80114. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80115. * @param defines Defines of the material we want to update
  80116. * @param lightIndex Index of the light in the enabled light list of the material
  80117. */
  80118. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80119. /**
  80120. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80121. * defined in the generator but impacting the effect).
  80122. * It implies the unifroms available on the materials are the standard BJS ones.
  80123. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80124. * @param effect The effect we are binfing the information for
  80125. */
  80126. bindShadowLight(lightIndex: string, effect: Effect): void;
  80127. /**
  80128. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80129. * (eq to shadow prjection matrix * light transform matrix)
  80130. * @returns The transform matrix used to create the shadow map
  80131. */
  80132. getTransformMatrix(): Matrix;
  80133. /**
  80134. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80135. * Cube and 2D textures for instance.
  80136. */
  80137. recreateShadowMap(): void;
  80138. /**
  80139. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80140. * @param onCompiled Callback triggered at the and of the effects compilation
  80141. * @param options Sets of optional options forcing the compilation with different modes
  80142. */
  80143. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80144. useInstances: boolean;
  80145. }>): void;
  80146. /**
  80147. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80148. * @param options Sets of optional options forcing the compilation with different modes
  80149. * @returns A promise that resolves when the compilation completes
  80150. */
  80151. forceCompilationAsync(options?: Partial<{
  80152. useInstances: boolean;
  80153. }>): Promise<void>;
  80154. /**
  80155. * Serializes the shadow generator setup to a json object.
  80156. * @returns The serialized JSON object
  80157. */
  80158. serialize(): any;
  80159. /**
  80160. * Disposes the Shadow map and related Textures and effects.
  80161. */
  80162. dispose(): void;
  80163. }
  80164. /**
  80165. * Default implementation IShadowGenerator.
  80166. * This is the main object responsible of generating shadows in the framework.
  80167. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80168. */
  80169. export class ShadowGenerator implements IShadowGenerator {
  80170. /**
  80171. * Shadow generator mode None: no filtering applied.
  80172. */
  80173. static readonly FILTER_NONE: number;
  80174. /**
  80175. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80176. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80177. */
  80178. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80179. /**
  80180. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80181. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80182. */
  80183. static readonly FILTER_POISSONSAMPLING: number;
  80184. /**
  80185. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80186. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80187. */
  80188. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80189. /**
  80190. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80191. * edge artifacts on steep falloff.
  80192. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80193. */
  80194. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80195. /**
  80196. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80197. * edge artifacts on steep falloff.
  80198. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80199. */
  80200. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80201. /**
  80202. * Shadow generator mode PCF: Percentage Closer Filtering
  80203. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80204. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80205. */
  80206. static readonly FILTER_PCF: number;
  80207. /**
  80208. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80209. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80210. * Contact Hardening
  80211. */
  80212. static readonly FILTER_PCSS: number;
  80213. /**
  80214. * Reserved for PCF and PCSS
  80215. * Highest Quality.
  80216. *
  80217. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80218. *
  80219. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80220. */
  80221. static readonly QUALITY_HIGH: number;
  80222. /**
  80223. * Reserved for PCF and PCSS
  80224. * Good tradeoff for quality/perf cross devices
  80225. *
  80226. * Execute PCF on a 3*3 kernel.
  80227. *
  80228. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80229. */
  80230. static readonly QUALITY_MEDIUM: number;
  80231. /**
  80232. * Reserved for PCF and PCSS
  80233. * The lowest quality but the fastest.
  80234. *
  80235. * Execute PCF on a 1*1 kernel.
  80236. *
  80237. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80238. */
  80239. static readonly QUALITY_LOW: number;
  80240. /** Gets or sets the custom shader name to use */
  80241. customShaderOptions: ICustomShaderOptions;
  80242. /**
  80243. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80244. */
  80245. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80246. /**
  80247. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80248. */
  80249. onAfterShadowMapRenderObservable: Observable<Effect>;
  80250. /**
  80251. * Observable triggered before a mesh is rendered in the shadow map.
  80252. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80253. */
  80254. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80255. /**
  80256. * Observable triggered after a mesh is rendered in the shadow map.
  80257. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80258. */
  80259. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80260. private _bias;
  80261. /**
  80262. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80263. */
  80264. get bias(): number;
  80265. /**
  80266. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80267. */
  80268. set bias(bias: number);
  80269. private _normalBias;
  80270. /**
  80271. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80272. */
  80273. get normalBias(): number;
  80274. /**
  80275. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80276. */
  80277. set normalBias(normalBias: number);
  80278. private _blurBoxOffset;
  80279. /**
  80280. * Gets the blur box offset: offset applied during the blur pass.
  80281. * Only useful if useKernelBlur = false
  80282. */
  80283. get blurBoxOffset(): number;
  80284. /**
  80285. * Sets the blur box offset: offset applied during the blur pass.
  80286. * Only useful if useKernelBlur = false
  80287. */
  80288. set blurBoxOffset(value: number);
  80289. private _blurScale;
  80290. /**
  80291. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80292. * 2 means half of the size.
  80293. */
  80294. get blurScale(): number;
  80295. /**
  80296. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80297. * 2 means half of the size.
  80298. */
  80299. set blurScale(value: number);
  80300. private _blurKernel;
  80301. /**
  80302. * Gets the blur kernel: kernel size of the blur pass.
  80303. * Only useful if useKernelBlur = true
  80304. */
  80305. get blurKernel(): number;
  80306. /**
  80307. * Sets the blur kernel: kernel size of the blur pass.
  80308. * Only useful if useKernelBlur = true
  80309. */
  80310. set blurKernel(value: number);
  80311. private _useKernelBlur;
  80312. /**
  80313. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80314. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80315. */
  80316. get useKernelBlur(): boolean;
  80317. /**
  80318. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80319. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80320. */
  80321. set useKernelBlur(value: boolean);
  80322. private _depthScale;
  80323. /**
  80324. * Gets the depth scale used in ESM mode.
  80325. */
  80326. get depthScale(): number;
  80327. /**
  80328. * Sets the depth scale used in ESM mode.
  80329. * This can override the scale stored on the light.
  80330. */
  80331. set depthScale(value: number);
  80332. private _filter;
  80333. /**
  80334. * Gets 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. get filter(): number;
  80338. /**
  80339. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80340. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80341. */
  80342. set filter(value: number);
  80343. /**
  80344. * Gets if the current filter is set to Poisson Sampling.
  80345. */
  80346. get usePoissonSampling(): boolean;
  80347. /**
  80348. * Sets the current filter to Poisson Sampling.
  80349. */
  80350. set usePoissonSampling(value: boolean);
  80351. /**
  80352. * Gets if the current filter is set to ESM.
  80353. */
  80354. get useExponentialShadowMap(): boolean;
  80355. /**
  80356. * Sets the current filter is to ESM.
  80357. */
  80358. set useExponentialShadowMap(value: boolean);
  80359. /**
  80360. * Gets if the current filter is set to filtered ESM.
  80361. */
  80362. get useBlurExponentialShadowMap(): boolean;
  80363. /**
  80364. * Gets if the current filter is set to filtered ESM.
  80365. */
  80366. set useBlurExponentialShadowMap(value: boolean);
  80367. /**
  80368. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80369. * exponential to prevent steep falloff artifacts).
  80370. */
  80371. get useCloseExponentialShadowMap(): boolean;
  80372. /**
  80373. * Sets the current filter to "close ESM" (using the inverse of the
  80374. * exponential to prevent steep falloff artifacts).
  80375. */
  80376. set useCloseExponentialShadowMap(value: boolean);
  80377. /**
  80378. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80379. * exponential to prevent steep falloff artifacts).
  80380. */
  80381. get useBlurCloseExponentialShadowMap(): boolean;
  80382. /**
  80383. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80384. * exponential to prevent steep falloff artifacts).
  80385. */
  80386. set useBlurCloseExponentialShadowMap(value: boolean);
  80387. /**
  80388. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80389. */
  80390. get usePercentageCloserFiltering(): boolean;
  80391. /**
  80392. * Sets the current filter to "PCF" (percentage closer filtering).
  80393. */
  80394. set usePercentageCloserFiltering(value: boolean);
  80395. private _filteringQuality;
  80396. /**
  80397. * Gets the PCF or PCSS Quality.
  80398. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80399. */
  80400. get filteringQuality(): number;
  80401. /**
  80402. * Sets the PCF or PCSS Quality.
  80403. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80404. */
  80405. set filteringQuality(filteringQuality: number);
  80406. /**
  80407. * Gets if the current filter is set to "PCSS" (contact hardening).
  80408. */
  80409. get useContactHardeningShadow(): boolean;
  80410. /**
  80411. * Sets the current filter to "PCSS" (contact hardening).
  80412. */
  80413. set useContactHardeningShadow(value: boolean);
  80414. private _contactHardeningLightSizeUVRatio;
  80415. /**
  80416. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80417. * Using a ratio helps keeping shape stability independently of the map size.
  80418. *
  80419. * It does not account for the light projection as it was having too much
  80420. * instability during the light setup or during light position changes.
  80421. *
  80422. * Only valid if useContactHardeningShadow is true.
  80423. */
  80424. get contactHardeningLightSizeUVRatio(): number;
  80425. /**
  80426. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80427. * Using a ratio helps keeping shape stability independently of the map size.
  80428. *
  80429. * It does not account for the light projection as it was having too much
  80430. * instability during the light setup or during light position changes.
  80431. *
  80432. * Only valid if useContactHardeningShadow is true.
  80433. */
  80434. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80435. private _darkness;
  80436. /** Gets or sets the actual darkness of a shadow */
  80437. get darkness(): number;
  80438. set darkness(value: number);
  80439. /**
  80440. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80441. * 0 means strongest and 1 would means no shadow.
  80442. * @returns the darkness.
  80443. */
  80444. getDarkness(): number;
  80445. /**
  80446. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80447. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80448. * @returns the shadow generator allowing fluent coding.
  80449. */
  80450. setDarkness(darkness: number): ShadowGenerator;
  80451. private _transparencyShadow;
  80452. /** Gets or sets the ability to have transparent shadow */
  80453. get transparencyShadow(): boolean;
  80454. set transparencyShadow(value: boolean);
  80455. /**
  80456. * Sets the ability to have transparent shadow (boolean).
  80457. * @param transparent True if transparent else False
  80458. * @returns the shadow generator allowing fluent coding
  80459. */
  80460. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80461. private _shadowMap;
  80462. private _shadowMap2;
  80463. /**
  80464. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80465. * @returns The render target texture if present otherwise, null
  80466. */
  80467. getShadowMap(): Nullable<RenderTargetTexture>;
  80468. /**
  80469. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80470. * @returns The render target texture if the shadow map is present otherwise, null
  80471. */
  80472. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80473. /**
  80474. * Gets the class name of that object
  80475. * @returns "ShadowGenerator"
  80476. */
  80477. getClassName(): string;
  80478. /**
  80479. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80480. * @param mesh Mesh to add
  80481. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80482. * @returns the Shadow Generator itself
  80483. */
  80484. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80485. /**
  80486. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80487. * @param mesh Mesh to remove
  80488. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80489. * @returns the Shadow Generator itself
  80490. */
  80491. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80492. /**
  80493. * Controls the extent to which the shadows fade out at the edge of the frustum
  80494. * Used only by directionals and spots
  80495. */
  80496. frustumEdgeFalloff: number;
  80497. private _light;
  80498. /**
  80499. * Returns the associated light object.
  80500. * @returns the light generating the shadow
  80501. */
  80502. getLight(): IShadowLight;
  80503. /**
  80504. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80505. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80506. * It might on the other hand introduce peter panning.
  80507. */
  80508. forceBackFacesOnly: boolean;
  80509. private _scene;
  80510. private _lightDirection;
  80511. private _effect;
  80512. private _viewMatrix;
  80513. private _projectionMatrix;
  80514. private _transformMatrix;
  80515. private _cachedPosition;
  80516. private _cachedDirection;
  80517. private _cachedDefines;
  80518. private _currentRenderID;
  80519. private _boxBlurPostprocess;
  80520. private _kernelBlurXPostprocess;
  80521. private _kernelBlurYPostprocess;
  80522. private _blurPostProcesses;
  80523. private _mapSize;
  80524. private _currentFaceIndex;
  80525. private _currentFaceIndexCache;
  80526. private _textureType;
  80527. private _defaultTextureMatrix;
  80528. private _storedUniqueId;
  80529. /** @hidden */
  80530. static _SceneComponentInitialization: (scene: Scene) => void;
  80531. /**
  80532. * Creates a ShadowGenerator object.
  80533. * A ShadowGenerator is the required tool to use the shadows.
  80534. * Each light casting shadows needs to use its own ShadowGenerator.
  80535. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80536. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80537. * @param light The light object generating the shadows.
  80538. * @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.
  80539. */
  80540. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80541. private _initializeGenerator;
  80542. private _initializeShadowMap;
  80543. private _initializeBlurRTTAndPostProcesses;
  80544. private _renderForShadowMap;
  80545. private _renderSubMeshForShadowMap;
  80546. private _applyFilterValues;
  80547. /**
  80548. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80549. * @param onCompiled Callback triggered at the and of the effects compilation
  80550. * @param options Sets of optional options forcing the compilation with different modes
  80551. */
  80552. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80553. useInstances: boolean;
  80554. }>): void;
  80555. /**
  80556. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80557. * @param options Sets of optional options forcing the compilation with different modes
  80558. * @returns A promise that resolves when the compilation completes
  80559. */
  80560. forceCompilationAsync(options?: Partial<{
  80561. useInstances: boolean;
  80562. }>): Promise<void>;
  80563. /**
  80564. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80565. * @param subMesh The submesh we want to render in the shadow map
  80566. * @param useInstances Defines wether will draw in the map using instances
  80567. * @returns true if ready otherwise, false
  80568. */
  80569. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80570. /**
  80571. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80572. * @param defines Defines of the material we want to update
  80573. * @param lightIndex Index of the light in the enabled light list of the material
  80574. */
  80575. prepareDefines(defines: any, lightIndex: number): void;
  80576. /**
  80577. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80578. * defined in the generator but impacting the effect).
  80579. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80580. * @param effect The effect we are binfing the information for
  80581. */
  80582. bindShadowLight(lightIndex: string, effect: Effect): void;
  80583. /**
  80584. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80585. * (eq to shadow prjection matrix * light transform matrix)
  80586. * @returns The transform matrix used to create the shadow map
  80587. */
  80588. getTransformMatrix(): Matrix;
  80589. /**
  80590. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80591. * Cube and 2D textures for instance.
  80592. */
  80593. recreateShadowMap(): void;
  80594. private _disposeBlurPostProcesses;
  80595. private _disposeRTTandPostProcesses;
  80596. /**
  80597. * Disposes the ShadowGenerator.
  80598. * Returns nothing.
  80599. */
  80600. dispose(): void;
  80601. /**
  80602. * Serializes the shadow generator setup to a json object.
  80603. * @returns The serialized JSON object
  80604. */
  80605. serialize(): any;
  80606. /**
  80607. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80608. * @param parsedShadowGenerator The JSON object to parse
  80609. * @param scene The scene to create the shadow map for
  80610. * @returns The parsed shadow generator
  80611. */
  80612. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80613. }
  80614. }
  80615. declare module BABYLON {
  80616. /**
  80617. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80618. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80619. * 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.
  80620. */
  80621. export abstract class Light extends Node {
  80622. /**
  80623. * Falloff Default: light is falling off following the material specification:
  80624. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80625. */
  80626. static readonly FALLOFF_DEFAULT: number;
  80627. /**
  80628. * Falloff Physical: light is falling off following the inverse squared distance law.
  80629. */
  80630. static readonly FALLOFF_PHYSICAL: number;
  80631. /**
  80632. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80633. * to enhance interoperability with other engines.
  80634. */
  80635. static readonly FALLOFF_GLTF: number;
  80636. /**
  80637. * Falloff Standard: light is falling off like in the standard material
  80638. * to enhance interoperability with other materials.
  80639. */
  80640. static readonly FALLOFF_STANDARD: number;
  80641. /**
  80642. * If every light affecting the material is in this lightmapMode,
  80643. * material.lightmapTexture adds or multiplies
  80644. * (depends on material.useLightmapAsShadowmap)
  80645. * after every other light calculations.
  80646. */
  80647. static readonly LIGHTMAP_DEFAULT: number;
  80648. /**
  80649. * material.lightmapTexture as only diffuse lighting from this light
  80650. * adds only specular lighting from this light
  80651. * adds dynamic shadows
  80652. */
  80653. static readonly LIGHTMAP_SPECULAR: number;
  80654. /**
  80655. * material.lightmapTexture as only lighting
  80656. * no light calculation from this light
  80657. * only adds dynamic shadows from this light
  80658. */
  80659. static readonly LIGHTMAP_SHADOWSONLY: number;
  80660. /**
  80661. * Each light type uses the default quantity according to its type:
  80662. * point/spot lights use luminous intensity
  80663. * directional lights use illuminance
  80664. */
  80665. static readonly INTENSITYMODE_AUTOMATIC: number;
  80666. /**
  80667. * lumen (lm)
  80668. */
  80669. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80670. /**
  80671. * candela (lm/sr)
  80672. */
  80673. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80674. /**
  80675. * lux (lm/m^2)
  80676. */
  80677. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80678. /**
  80679. * nit (cd/m^2)
  80680. */
  80681. static readonly INTENSITYMODE_LUMINANCE: number;
  80682. /**
  80683. * Light type const id of the point light.
  80684. */
  80685. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80686. /**
  80687. * Light type const id of the directional light.
  80688. */
  80689. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80690. /**
  80691. * Light type const id of the spot light.
  80692. */
  80693. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80694. /**
  80695. * Light type const id of the hemispheric light.
  80696. */
  80697. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80698. /**
  80699. * Diffuse gives the basic color to an object.
  80700. */
  80701. diffuse: Color3;
  80702. /**
  80703. * Specular produces a highlight color on an object.
  80704. * Note: This is note affecting PBR materials.
  80705. */
  80706. specular: Color3;
  80707. /**
  80708. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80709. * falling off base on range or angle.
  80710. * This can be set to any values in Light.FALLOFF_x.
  80711. *
  80712. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80713. * other types of materials.
  80714. */
  80715. falloffType: number;
  80716. /**
  80717. * Strength of the light.
  80718. * Note: By default it is define in the framework own unit.
  80719. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80720. */
  80721. intensity: number;
  80722. private _range;
  80723. protected _inverseSquaredRange: 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. get range(): number;
  80729. /**
  80730. * Defines how far from the source the light is impacting in scene units.
  80731. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80732. */
  80733. set range(value: number);
  80734. /**
  80735. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80736. * of light.
  80737. */
  80738. private _photometricScale;
  80739. private _intensityMode;
  80740. /**
  80741. * Gets 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. get intensityMode(): number;
  80745. /**
  80746. * Sets the photometric scale used to interpret the intensity.
  80747. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80748. */
  80749. set intensityMode(value: number);
  80750. private _radius;
  80751. /**
  80752. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80753. */
  80754. get radius(): number;
  80755. /**
  80756. * sets the light radius used by PBR Materials to simulate soft area lights.
  80757. */
  80758. set radius(value: number);
  80759. private _renderPriority;
  80760. /**
  80761. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80762. * exceeding the number allowed of the materials.
  80763. */
  80764. renderPriority: number;
  80765. private _shadowEnabled;
  80766. /**
  80767. * Gets 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. get shadowEnabled(): boolean;
  80771. /**
  80772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80773. * the current shadow generator.
  80774. */
  80775. set shadowEnabled(value: boolean);
  80776. private _includedOnlyMeshes;
  80777. /**
  80778. * Gets the only meshes impacted by this light.
  80779. */
  80780. get includedOnlyMeshes(): AbstractMesh[];
  80781. /**
  80782. * Sets the only meshes impacted by this light.
  80783. */
  80784. set includedOnlyMeshes(value: AbstractMesh[]);
  80785. private _excludedMeshes;
  80786. /**
  80787. * Gets the meshes not impacted by this light.
  80788. */
  80789. get excludedMeshes(): AbstractMesh[];
  80790. /**
  80791. * Sets the meshes not impacted by this light.
  80792. */
  80793. set excludedMeshes(value: AbstractMesh[]);
  80794. private _excludeWithLayerMask;
  80795. /**
  80796. * Gets the layer id use to find what meshes are not impacted by the light.
  80797. * Inactive if 0
  80798. */
  80799. get excludeWithLayerMask(): number;
  80800. /**
  80801. * Sets the layer id use to find what meshes are not impacted by the light.
  80802. * Inactive if 0
  80803. */
  80804. set excludeWithLayerMask(value: number);
  80805. private _includeOnlyWithLayerMask;
  80806. /**
  80807. * Gets the layer id use to find what meshes are impacted by the light.
  80808. * Inactive if 0
  80809. */
  80810. get includeOnlyWithLayerMask(): number;
  80811. /**
  80812. * Sets the layer id use to find what meshes are impacted by the light.
  80813. * Inactive if 0
  80814. */
  80815. set includeOnlyWithLayerMask(value: number);
  80816. private _lightmapMode;
  80817. /**
  80818. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80819. */
  80820. get lightmapMode(): number;
  80821. /**
  80822. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80823. */
  80824. set lightmapMode(value: number);
  80825. /**
  80826. * Shadow generator associted to the light.
  80827. * @hidden Internal use only.
  80828. */
  80829. _shadowGenerator: Nullable<IShadowGenerator>;
  80830. /**
  80831. * @hidden Internal use only.
  80832. */
  80833. _excludedMeshesIds: string[];
  80834. /**
  80835. * @hidden Internal use only.
  80836. */
  80837. _includedOnlyMeshesIds: string[];
  80838. /**
  80839. * The current light unifom buffer.
  80840. * @hidden Internal use only.
  80841. */
  80842. _uniformBuffer: UniformBuffer;
  80843. /** @hidden */
  80844. _renderId: number;
  80845. /**
  80846. * Creates a Light object in the scene.
  80847. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80848. * @param name The firendly name of the light
  80849. * @param scene The scene the light belongs too
  80850. */
  80851. constructor(name: string, scene: Scene);
  80852. protected abstract _buildUniformLayout(): void;
  80853. /**
  80854. * Sets the passed Effect "effect" with the Light information.
  80855. * @param effect The effect to update
  80856. * @param lightIndex The index of the light in the effect to update
  80857. * @returns The light
  80858. */
  80859. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80860. /**
  80861. * Sets the passed Effect "effect" with the Light textures.
  80862. * @param effect The effect to update
  80863. * @param lightIndex The index of the light in the effect to update
  80864. * @returns The light
  80865. */
  80866. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80867. /**
  80868. * Binds the lights information from the scene to the effect for the given mesh.
  80869. * @param lightIndex Light index
  80870. * @param scene The scene where the light belongs to
  80871. * @param effect The effect we are binding the data to
  80872. * @param useSpecular Defines if specular is supported
  80873. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80874. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80875. */
  80876. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80877. /**
  80878. * Sets the passed Effect "effect" with the Light information.
  80879. * @param effect The effect to update
  80880. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80881. * @returns The light
  80882. */
  80883. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80884. /**
  80885. * Returns the string "Light".
  80886. * @returns the class name
  80887. */
  80888. getClassName(): string;
  80889. /** @hidden */
  80890. readonly _isLight: boolean;
  80891. /**
  80892. * Converts the light information to a readable string for debug purpose.
  80893. * @param fullDetails Supports for multiple levels of logging within scene loading
  80894. * @returns the human readable light info
  80895. */
  80896. toString(fullDetails?: boolean): string;
  80897. /** @hidden */
  80898. protected _syncParentEnabledState(): void;
  80899. /**
  80900. * Set the enabled state of this node.
  80901. * @param value - the new enabled state
  80902. */
  80903. setEnabled(value: boolean): void;
  80904. /**
  80905. * Returns the Light associated shadow generator if any.
  80906. * @return the associated shadow generator.
  80907. */
  80908. getShadowGenerator(): Nullable<IShadowGenerator>;
  80909. /**
  80910. * Returns a Vector3, the absolute light position in the World.
  80911. * @returns the world space position of the light
  80912. */
  80913. getAbsolutePosition(): Vector3;
  80914. /**
  80915. * Specifies if the light will affect the passed mesh.
  80916. * @param mesh The mesh to test against the light
  80917. * @return true the mesh is affected otherwise, false.
  80918. */
  80919. canAffectMesh(mesh: AbstractMesh): boolean;
  80920. /**
  80921. * Sort function to order lights for rendering.
  80922. * @param a First Light object to compare to second.
  80923. * @param b Second Light object to compare first.
  80924. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80925. */
  80926. static CompareLightsPriority(a: Light, b: Light): number;
  80927. /**
  80928. * Releases resources associated with this node.
  80929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80931. */
  80932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80933. /**
  80934. * Returns the light type ID (integer).
  80935. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80936. */
  80937. getTypeID(): number;
  80938. /**
  80939. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80940. * @returns the scaled intensity in intensity mode unit
  80941. */
  80942. getScaledIntensity(): number;
  80943. /**
  80944. * Returns a new Light object, named "name", from the current one.
  80945. * @param name The name of the cloned light
  80946. * @returns the new created light
  80947. */
  80948. clone(name: string): Nullable<Light>;
  80949. /**
  80950. * Serializes the current light into a Serialization object.
  80951. * @returns the serialized object.
  80952. */
  80953. serialize(): any;
  80954. /**
  80955. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80956. * This new light is named "name" and added to the passed scene.
  80957. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80958. * @param name The friendly name of the light
  80959. * @param scene The scene the new light will belong to
  80960. * @returns the constructor function
  80961. */
  80962. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80963. /**
  80964. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80965. * @param parsedLight The JSON representation of the light
  80966. * @param scene The scene to create the parsed light in
  80967. * @returns the created light after parsing
  80968. */
  80969. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80970. private _hookArrayForExcluded;
  80971. private _hookArrayForIncludedOnly;
  80972. private _resyncMeshes;
  80973. /**
  80974. * Forces the meshes to update their light related information in their rendering used effects
  80975. * @hidden Internal Use Only
  80976. */
  80977. _markMeshesAsLightDirty(): void;
  80978. /**
  80979. * Recomputes the cached photometric scale if needed.
  80980. */
  80981. private _computePhotometricScale;
  80982. /**
  80983. * Returns the Photometric Scale according to the light type and intensity mode.
  80984. */
  80985. private _getPhotometricScale;
  80986. /**
  80987. * Reorder the light in the scene according to their defined priority.
  80988. * @hidden Internal Use Only
  80989. */
  80990. _reorderLightsInScene(): void;
  80991. /**
  80992. * Prepares the list of defines specific to the light type.
  80993. * @param defines the list of defines
  80994. * @param lightIndex defines the index of the light for the effect
  80995. */
  80996. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80997. }
  80998. }
  80999. declare module BABYLON {
  81000. /**
  81001. * Interface used to define Action
  81002. */
  81003. export interface IAction {
  81004. /**
  81005. * Trigger for the action
  81006. */
  81007. trigger: number;
  81008. /** Options of the trigger */
  81009. triggerOptions: any;
  81010. /**
  81011. * Gets the trigger parameters
  81012. * @returns the trigger parameters
  81013. */
  81014. getTriggerParameter(): any;
  81015. /**
  81016. * Internal only - executes current action event
  81017. * @hidden
  81018. */
  81019. _executeCurrent(evt?: ActionEvent): void;
  81020. /**
  81021. * Serialize placeholder for child classes
  81022. * @param parent of child
  81023. * @returns the serialized object
  81024. */
  81025. serialize(parent: any): any;
  81026. /**
  81027. * Internal only
  81028. * @hidden
  81029. */
  81030. _prepare(): void;
  81031. /**
  81032. * Internal only - manager for action
  81033. * @hidden
  81034. */
  81035. _actionManager: AbstractActionManager;
  81036. /**
  81037. * Adds action to chain of actions, may be a DoNothingAction
  81038. * @param action defines the next action to execute
  81039. * @returns The action passed in
  81040. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81041. */
  81042. then(action: IAction): IAction;
  81043. }
  81044. /**
  81045. * The action to be carried out following a trigger
  81046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  81047. */
  81048. export class Action implements IAction {
  81049. /** the trigger, with or without parameters, for the action */
  81050. triggerOptions: any;
  81051. /**
  81052. * Trigger for the action
  81053. */
  81054. trigger: number;
  81055. /**
  81056. * Internal only - manager for action
  81057. * @hidden
  81058. */
  81059. _actionManager: ActionManager;
  81060. private _nextActiveAction;
  81061. private _child;
  81062. private _condition?;
  81063. private _triggerParameter;
  81064. /**
  81065. * An event triggered prior to action being executed.
  81066. */
  81067. onBeforeExecuteObservable: Observable<Action>;
  81068. /**
  81069. * Creates a new Action
  81070. * @param triggerOptions the trigger, with or without parameters, for the action
  81071. * @param condition an optional determinant of action
  81072. */
  81073. constructor(
  81074. /** the trigger, with or without parameters, for the action */
  81075. triggerOptions: any, condition?: Condition);
  81076. /**
  81077. * Internal only
  81078. * @hidden
  81079. */
  81080. _prepare(): void;
  81081. /**
  81082. * Gets the trigger parameters
  81083. * @returns the trigger parameters
  81084. */
  81085. getTriggerParameter(): any;
  81086. /**
  81087. * Internal only - executes current action event
  81088. * @hidden
  81089. */
  81090. _executeCurrent(evt?: ActionEvent): void;
  81091. /**
  81092. * Execute placeholder for child classes
  81093. * @param evt optional action event
  81094. */
  81095. execute(evt?: ActionEvent): void;
  81096. /**
  81097. * Skips to next active action
  81098. */
  81099. skipToNextActiveAction(): void;
  81100. /**
  81101. * Adds action to chain of actions, may be a DoNothingAction
  81102. * @param action defines the next action to execute
  81103. * @returns The action passed in
  81104. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81105. */
  81106. then(action: Action): Action;
  81107. /**
  81108. * Internal only
  81109. * @hidden
  81110. */
  81111. _getProperty(propertyPath: string): string;
  81112. /**
  81113. * Internal only
  81114. * @hidden
  81115. */
  81116. _getEffectiveTarget(target: any, propertyPath: string): any;
  81117. /**
  81118. * Serialize placeholder for child classes
  81119. * @param parent of child
  81120. * @returns the serialized object
  81121. */
  81122. serialize(parent: any): any;
  81123. /**
  81124. * Internal only called by serialize
  81125. * @hidden
  81126. */
  81127. protected _serialize(serializedAction: any, parent?: any): any;
  81128. /**
  81129. * Internal only
  81130. * @hidden
  81131. */
  81132. static _SerializeValueAsString: (value: any) => string;
  81133. /**
  81134. * Internal only
  81135. * @hidden
  81136. */
  81137. static _GetTargetProperty: (target: Node | Scene) => {
  81138. name: string;
  81139. targetType: string;
  81140. value: string;
  81141. };
  81142. }
  81143. }
  81144. declare module BABYLON {
  81145. /**
  81146. * A Condition applied to an Action
  81147. */
  81148. export class Condition {
  81149. /**
  81150. * Internal only - manager for action
  81151. * @hidden
  81152. */
  81153. _actionManager: ActionManager;
  81154. /**
  81155. * Internal only
  81156. * @hidden
  81157. */
  81158. _evaluationId: number;
  81159. /**
  81160. * Internal only
  81161. * @hidden
  81162. */
  81163. _currentResult: boolean;
  81164. /**
  81165. * Creates a new Condition
  81166. * @param actionManager the manager of the action the condition is applied to
  81167. */
  81168. constructor(actionManager: ActionManager);
  81169. /**
  81170. * Check if the current condition is valid
  81171. * @returns a boolean
  81172. */
  81173. isValid(): boolean;
  81174. /**
  81175. * Internal only
  81176. * @hidden
  81177. */
  81178. _getProperty(propertyPath: string): string;
  81179. /**
  81180. * Internal only
  81181. * @hidden
  81182. */
  81183. _getEffectiveTarget(target: any, propertyPath: string): any;
  81184. /**
  81185. * Serialize placeholder for child classes
  81186. * @returns the serialized object
  81187. */
  81188. serialize(): any;
  81189. /**
  81190. * Internal only
  81191. * @hidden
  81192. */
  81193. protected _serialize(serializedCondition: any): any;
  81194. }
  81195. /**
  81196. * Defines specific conditional operators as extensions of Condition
  81197. */
  81198. export class ValueCondition extends Condition {
  81199. /** path to specify the property of the target the conditional operator uses */
  81200. propertyPath: string;
  81201. /** the value compared by the conditional operator against the current value of the property */
  81202. value: any;
  81203. /** the conditional operator, default ValueCondition.IsEqual */
  81204. operator: number;
  81205. /**
  81206. * Internal only
  81207. * @hidden
  81208. */
  81209. private static _IsEqual;
  81210. /**
  81211. * Internal only
  81212. * @hidden
  81213. */
  81214. private static _IsDifferent;
  81215. /**
  81216. * Internal only
  81217. * @hidden
  81218. */
  81219. private static _IsGreater;
  81220. /**
  81221. * Internal only
  81222. * @hidden
  81223. */
  81224. private static _IsLesser;
  81225. /**
  81226. * returns the number for IsEqual
  81227. */
  81228. static get IsEqual(): number;
  81229. /**
  81230. * Returns the number for IsDifferent
  81231. */
  81232. static get IsDifferent(): number;
  81233. /**
  81234. * Returns the number for IsGreater
  81235. */
  81236. static get IsGreater(): number;
  81237. /**
  81238. * Returns the number for IsLesser
  81239. */
  81240. static get IsLesser(): number;
  81241. /**
  81242. * Internal only The action manager for the condition
  81243. * @hidden
  81244. */
  81245. _actionManager: ActionManager;
  81246. /**
  81247. * Internal only
  81248. * @hidden
  81249. */
  81250. private _target;
  81251. /**
  81252. * Internal only
  81253. * @hidden
  81254. */
  81255. private _effectiveTarget;
  81256. /**
  81257. * Internal only
  81258. * @hidden
  81259. */
  81260. private _property;
  81261. /**
  81262. * Creates a new ValueCondition
  81263. * @param actionManager manager for the action the condition applies to
  81264. * @param target for the action
  81265. * @param propertyPath path to specify the property of the target the conditional operator uses
  81266. * @param value the value compared by the conditional operator against the current value of the property
  81267. * @param operator the conditional operator, default ValueCondition.IsEqual
  81268. */
  81269. constructor(actionManager: ActionManager, target: any,
  81270. /** path to specify the property of the target the conditional operator uses */
  81271. propertyPath: string,
  81272. /** the value compared by the conditional operator against the current value of the property */
  81273. value: any,
  81274. /** the conditional operator, default ValueCondition.IsEqual */
  81275. operator?: number);
  81276. /**
  81277. * Compares the given value with the property value for the specified conditional operator
  81278. * @returns the result of the comparison
  81279. */
  81280. isValid(): boolean;
  81281. /**
  81282. * Serialize the ValueCondition into a JSON compatible object
  81283. * @returns serialization object
  81284. */
  81285. serialize(): any;
  81286. /**
  81287. * Gets the name of the conditional operator for the ValueCondition
  81288. * @param operator the conditional operator
  81289. * @returns the name
  81290. */
  81291. static GetOperatorName(operator: number): string;
  81292. }
  81293. /**
  81294. * Defines a predicate condition as an extension of Condition
  81295. */
  81296. export class PredicateCondition extends Condition {
  81297. /** defines the predicate function used to validate the condition */
  81298. predicate: () => boolean;
  81299. /**
  81300. * Internal only - manager for action
  81301. * @hidden
  81302. */
  81303. _actionManager: ActionManager;
  81304. /**
  81305. * Creates a new PredicateCondition
  81306. * @param actionManager manager for the action the condition applies to
  81307. * @param predicate defines the predicate function used to validate the condition
  81308. */
  81309. constructor(actionManager: ActionManager,
  81310. /** defines the predicate function used to validate the condition */
  81311. predicate: () => boolean);
  81312. /**
  81313. * @returns the validity of the predicate condition
  81314. */
  81315. isValid(): boolean;
  81316. }
  81317. /**
  81318. * Defines a state condition as an extension of Condition
  81319. */
  81320. export class StateCondition extends Condition {
  81321. /** Value to compare with target state */
  81322. value: string;
  81323. /**
  81324. * Internal only - manager for action
  81325. * @hidden
  81326. */
  81327. _actionManager: ActionManager;
  81328. /**
  81329. * Internal only
  81330. * @hidden
  81331. */
  81332. private _target;
  81333. /**
  81334. * Creates a new StateCondition
  81335. * @param actionManager manager for the action the condition applies to
  81336. * @param target of the condition
  81337. * @param value to compare with target state
  81338. */
  81339. constructor(actionManager: ActionManager, target: any,
  81340. /** Value to compare with target state */
  81341. value: string);
  81342. /**
  81343. * Gets a boolean indicating if the current condition is met
  81344. * @returns the validity of the state
  81345. */
  81346. isValid(): boolean;
  81347. /**
  81348. * Serialize the StateCondition into a JSON compatible object
  81349. * @returns serialization object
  81350. */
  81351. serialize(): any;
  81352. }
  81353. }
  81354. declare module BABYLON {
  81355. /**
  81356. * This defines an action responsible to toggle a boolean once triggered.
  81357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81358. */
  81359. export class SwitchBooleanAction extends Action {
  81360. /**
  81361. * The path to the boolean property in the target object
  81362. */
  81363. propertyPath: string;
  81364. private _target;
  81365. private _effectiveTarget;
  81366. private _property;
  81367. /**
  81368. * Instantiate the action
  81369. * @param triggerOptions defines the trigger options
  81370. * @param target defines the object containing the boolean
  81371. * @param propertyPath defines the path to the boolean property in the target object
  81372. * @param condition defines the trigger related conditions
  81373. */
  81374. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81375. /** @hidden */
  81376. _prepare(): void;
  81377. /**
  81378. * Execute the action toggle the boolean value.
  81379. */
  81380. execute(): void;
  81381. /**
  81382. * Serializes the actions and its related information.
  81383. * @param parent defines the object to serialize in
  81384. * @returns the serialized object
  81385. */
  81386. serialize(parent: any): any;
  81387. }
  81388. /**
  81389. * This defines an action responsible to set a the state field of the target
  81390. * to a desired value once triggered.
  81391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81392. */
  81393. export class SetStateAction extends Action {
  81394. /**
  81395. * The value to store in the state field.
  81396. */
  81397. value: string;
  81398. private _target;
  81399. /**
  81400. * Instantiate the action
  81401. * @param triggerOptions defines the trigger options
  81402. * @param target defines the object containing the state property
  81403. * @param value defines the value to store in the state field
  81404. * @param condition defines the trigger related conditions
  81405. */
  81406. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81407. /**
  81408. * Execute the action and store the value on the target state property.
  81409. */
  81410. execute(): void;
  81411. /**
  81412. * Serializes the actions and its related information.
  81413. * @param parent defines the object to serialize in
  81414. * @returns the serialized object
  81415. */
  81416. serialize(parent: any): any;
  81417. }
  81418. /**
  81419. * This defines an action responsible to set a property of the target
  81420. * to a desired value once triggered.
  81421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81422. */
  81423. export class SetValueAction extends Action {
  81424. /**
  81425. * The path of the property to set in the target.
  81426. */
  81427. propertyPath: string;
  81428. /**
  81429. * The value to set in the property
  81430. */
  81431. value: any;
  81432. private _target;
  81433. private _effectiveTarget;
  81434. private _property;
  81435. /**
  81436. * Instantiate the action
  81437. * @param triggerOptions defines the trigger options
  81438. * @param target defines the object containing the property
  81439. * @param propertyPath defines the path of the property to set in the target
  81440. * @param value defines the value to set in the property
  81441. * @param condition defines the trigger related conditions
  81442. */
  81443. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81444. /** @hidden */
  81445. _prepare(): void;
  81446. /**
  81447. * Execute the action and set the targetted property to the desired value.
  81448. */
  81449. execute(): void;
  81450. /**
  81451. * Serializes the actions and its related information.
  81452. * @param parent defines the object to serialize in
  81453. * @returns the serialized object
  81454. */
  81455. serialize(parent: any): any;
  81456. }
  81457. /**
  81458. * This defines an action responsible to increment the target value
  81459. * to a desired value once triggered.
  81460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81461. */
  81462. export class IncrementValueAction extends Action {
  81463. /**
  81464. * The path of the property to increment in the target.
  81465. */
  81466. propertyPath: string;
  81467. /**
  81468. * The value we should increment the property by.
  81469. */
  81470. value: any;
  81471. private _target;
  81472. private _effectiveTarget;
  81473. private _property;
  81474. /**
  81475. * Instantiate the action
  81476. * @param triggerOptions defines the trigger options
  81477. * @param target defines the object containing the property
  81478. * @param propertyPath defines the path of the property to increment in the target
  81479. * @param value defines the value value we should increment the property by
  81480. * @param condition defines the trigger related conditions
  81481. */
  81482. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81483. /** @hidden */
  81484. _prepare(): void;
  81485. /**
  81486. * Execute the action and increment the target of the value amount.
  81487. */
  81488. execute(): void;
  81489. /**
  81490. * Serializes the actions and its related information.
  81491. * @param parent defines the object to serialize in
  81492. * @returns the serialized object
  81493. */
  81494. serialize(parent: any): any;
  81495. }
  81496. /**
  81497. * This defines an action responsible to start an animation once triggered.
  81498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81499. */
  81500. export class PlayAnimationAction extends Action {
  81501. /**
  81502. * Where the animation should start (animation frame)
  81503. */
  81504. from: number;
  81505. /**
  81506. * Where the animation should stop (animation frame)
  81507. */
  81508. to: number;
  81509. /**
  81510. * Define if the animation should loop or stop after the first play.
  81511. */
  81512. loop?: boolean;
  81513. private _target;
  81514. /**
  81515. * Instantiate the action
  81516. * @param triggerOptions defines the trigger options
  81517. * @param target defines the target animation or animation name
  81518. * @param from defines from where the animation should start (animation frame)
  81519. * @param end defines where the animation should stop (animation frame)
  81520. * @param loop defines if the animation should loop or stop after the first play
  81521. * @param condition defines the trigger related conditions
  81522. */
  81523. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81524. /** @hidden */
  81525. _prepare(): void;
  81526. /**
  81527. * Execute the action and play the animation.
  81528. */
  81529. execute(): void;
  81530. /**
  81531. * Serializes the actions and its related information.
  81532. * @param parent defines the object to serialize in
  81533. * @returns the serialized object
  81534. */
  81535. serialize(parent: any): any;
  81536. }
  81537. /**
  81538. * This defines an action responsible to stop an animation once triggered.
  81539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81540. */
  81541. export class StopAnimationAction extends Action {
  81542. private _target;
  81543. /**
  81544. * Instantiate the action
  81545. * @param triggerOptions defines the trigger options
  81546. * @param target defines the target animation or animation name
  81547. * @param condition defines the trigger related conditions
  81548. */
  81549. constructor(triggerOptions: any, target: any, condition?: Condition);
  81550. /** @hidden */
  81551. _prepare(): void;
  81552. /**
  81553. * Execute the action and stop the animation.
  81554. */
  81555. execute(): void;
  81556. /**
  81557. * Serializes the actions and its related information.
  81558. * @param parent defines the object to serialize in
  81559. * @returns the serialized object
  81560. */
  81561. serialize(parent: any): any;
  81562. }
  81563. /**
  81564. * This defines an action responsible that does nothing once triggered.
  81565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81566. */
  81567. export class DoNothingAction extends Action {
  81568. /**
  81569. * Instantiate the action
  81570. * @param triggerOptions defines the trigger options
  81571. * @param condition defines the trigger related conditions
  81572. */
  81573. constructor(triggerOptions?: any, condition?: Condition);
  81574. /**
  81575. * Execute the action and do nothing.
  81576. */
  81577. execute(): void;
  81578. /**
  81579. * Serializes the actions and its related information.
  81580. * @param parent defines the object to serialize in
  81581. * @returns the serialized object
  81582. */
  81583. serialize(parent: any): any;
  81584. }
  81585. /**
  81586. * This defines an action responsible to trigger several actions once triggered.
  81587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81588. */
  81589. export class CombineAction extends Action {
  81590. /**
  81591. * The list of aggregated animations to run.
  81592. */
  81593. children: Action[];
  81594. /**
  81595. * Instantiate the action
  81596. * @param triggerOptions defines the trigger options
  81597. * @param children defines the list of aggregated animations to run
  81598. * @param condition defines the trigger related conditions
  81599. */
  81600. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81601. /** @hidden */
  81602. _prepare(): void;
  81603. /**
  81604. * Execute the action and executes all the aggregated actions.
  81605. */
  81606. execute(evt: ActionEvent): void;
  81607. /**
  81608. * Serializes the actions and its related information.
  81609. * @param parent defines the object to serialize in
  81610. * @returns the serialized object
  81611. */
  81612. serialize(parent: any): any;
  81613. }
  81614. /**
  81615. * This defines an action responsible to run code (external event) once triggered.
  81616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81617. */
  81618. export class ExecuteCodeAction extends Action {
  81619. /**
  81620. * The callback function to run.
  81621. */
  81622. func: (evt: ActionEvent) => void;
  81623. /**
  81624. * Instantiate the action
  81625. * @param triggerOptions defines the trigger options
  81626. * @param func defines the callback function to run
  81627. * @param condition defines the trigger related conditions
  81628. */
  81629. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81630. /**
  81631. * Execute the action and run the attached code.
  81632. */
  81633. execute(evt: ActionEvent): void;
  81634. }
  81635. /**
  81636. * This defines an action responsible to set the parent property of the target once triggered.
  81637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81638. */
  81639. export class SetParentAction extends Action {
  81640. private _parent;
  81641. private _target;
  81642. /**
  81643. * Instantiate the action
  81644. * @param triggerOptions defines the trigger options
  81645. * @param target defines the target containing the parent property
  81646. * @param parent defines from where the animation should start (animation frame)
  81647. * @param condition defines the trigger related conditions
  81648. */
  81649. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81650. /** @hidden */
  81651. _prepare(): void;
  81652. /**
  81653. * Execute the action and set the parent property.
  81654. */
  81655. execute(): void;
  81656. /**
  81657. * Serializes the actions and its related information.
  81658. * @param parent defines the object to serialize in
  81659. * @returns the serialized object
  81660. */
  81661. serialize(parent: any): any;
  81662. }
  81663. }
  81664. declare module BABYLON {
  81665. /**
  81666. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81667. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81669. */
  81670. export class ActionManager extends AbstractActionManager {
  81671. /**
  81672. * Nothing
  81673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81674. */
  81675. static readonly NothingTrigger: number;
  81676. /**
  81677. * On pick
  81678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81679. */
  81680. static readonly OnPickTrigger: number;
  81681. /**
  81682. * On left pick
  81683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81684. */
  81685. static readonly OnLeftPickTrigger: number;
  81686. /**
  81687. * On right pick
  81688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81689. */
  81690. static readonly OnRightPickTrigger: number;
  81691. /**
  81692. * On center pick
  81693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81694. */
  81695. static readonly OnCenterPickTrigger: number;
  81696. /**
  81697. * On pick down
  81698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81699. */
  81700. static readonly OnPickDownTrigger: number;
  81701. /**
  81702. * On double pick
  81703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81704. */
  81705. static readonly OnDoublePickTrigger: number;
  81706. /**
  81707. * On pick up
  81708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81709. */
  81710. static readonly OnPickUpTrigger: number;
  81711. /**
  81712. * On pick out.
  81713. * This trigger will only be raised if you also declared a OnPickDown
  81714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81715. */
  81716. static readonly OnPickOutTrigger: number;
  81717. /**
  81718. * On long press
  81719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81720. */
  81721. static readonly OnLongPressTrigger: number;
  81722. /**
  81723. * On pointer over
  81724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81725. */
  81726. static readonly OnPointerOverTrigger: number;
  81727. /**
  81728. * On pointer out
  81729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81730. */
  81731. static readonly OnPointerOutTrigger: number;
  81732. /**
  81733. * On every frame
  81734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81735. */
  81736. static readonly OnEveryFrameTrigger: number;
  81737. /**
  81738. * On intersection enter
  81739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81740. */
  81741. static readonly OnIntersectionEnterTrigger: number;
  81742. /**
  81743. * On intersection exit
  81744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81745. */
  81746. static readonly OnIntersectionExitTrigger: number;
  81747. /**
  81748. * On key down
  81749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81750. */
  81751. static readonly OnKeyDownTrigger: number;
  81752. /**
  81753. * On key up
  81754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81755. */
  81756. static readonly OnKeyUpTrigger: number;
  81757. private _scene;
  81758. /**
  81759. * Creates a new action manager
  81760. * @param scene defines the hosting scene
  81761. */
  81762. constructor(scene: Scene);
  81763. /**
  81764. * Releases all associated resources
  81765. */
  81766. dispose(): void;
  81767. /**
  81768. * Gets hosting scene
  81769. * @returns the hosting scene
  81770. */
  81771. getScene(): Scene;
  81772. /**
  81773. * Does this action manager handles actions of any of the given triggers
  81774. * @param triggers defines the triggers to be tested
  81775. * @return a boolean indicating whether one (or more) of the triggers is handled
  81776. */
  81777. hasSpecificTriggers(triggers: number[]): boolean;
  81778. /**
  81779. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81780. * speed.
  81781. * @param triggerA defines the trigger to be tested
  81782. * @param triggerB defines the trigger to be tested
  81783. * @return a boolean indicating whether one (or more) of the triggers is handled
  81784. */
  81785. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81786. /**
  81787. * Does this action manager handles actions of a given trigger
  81788. * @param trigger defines the trigger to be tested
  81789. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81790. * @return whether the trigger is handled
  81791. */
  81792. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81793. /**
  81794. * Does this action manager has pointer triggers
  81795. */
  81796. get hasPointerTriggers(): boolean;
  81797. /**
  81798. * Does this action manager has pick triggers
  81799. */
  81800. get hasPickTriggers(): boolean;
  81801. /**
  81802. * Registers an action to this action manager
  81803. * @param action defines the action to be registered
  81804. * @return the action amended (prepared) after registration
  81805. */
  81806. registerAction(action: IAction): Nullable<IAction>;
  81807. /**
  81808. * Unregisters an action to this action manager
  81809. * @param action defines the action to be unregistered
  81810. * @return a boolean indicating whether the action has been unregistered
  81811. */
  81812. unregisterAction(action: IAction): Boolean;
  81813. /**
  81814. * Process a specific trigger
  81815. * @param trigger defines the trigger to process
  81816. * @param evt defines the event details to be processed
  81817. */
  81818. processTrigger(trigger: number, evt?: IActionEvent): void;
  81819. /** @hidden */
  81820. _getEffectiveTarget(target: any, propertyPath: string): any;
  81821. /** @hidden */
  81822. _getProperty(propertyPath: string): string;
  81823. /**
  81824. * Serialize this manager to a JSON object
  81825. * @param name defines the property name to store this manager
  81826. * @returns a JSON representation of this manager
  81827. */
  81828. serialize(name: string): any;
  81829. /**
  81830. * Creates a new ActionManager from a JSON data
  81831. * @param parsedActions defines the JSON data to read from
  81832. * @param object defines the hosting mesh
  81833. * @param scene defines the hosting scene
  81834. */
  81835. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81836. /**
  81837. * Get a trigger name by index
  81838. * @param trigger defines the trigger index
  81839. * @returns a trigger name
  81840. */
  81841. static GetTriggerName(trigger: number): string;
  81842. }
  81843. }
  81844. declare module BABYLON {
  81845. /**
  81846. * Class representing a ray with position and direction
  81847. */
  81848. export class Ray {
  81849. /** origin point */
  81850. origin: Vector3;
  81851. /** direction */
  81852. direction: Vector3;
  81853. /** length of the ray */
  81854. length: number;
  81855. private static readonly TmpVector3;
  81856. private _tmpRay;
  81857. /**
  81858. * Creates a new ray
  81859. * @param origin origin point
  81860. * @param direction direction
  81861. * @param length length of the ray
  81862. */
  81863. constructor(
  81864. /** origin point */
  81865. origin: Vector3,
  81866. /** direction */
  81867. direction: Vector3,
  81868. /** length of the ray */
  81869. length?: number);
  81870. /**
  81871. * Checks if the ray intersects a box
  81872. * @param minimum bound of the box
  81873. * @param maximum bound of the box
  81874. * @param intersectionTreshold extra extend to be added to the box in all direction
  81875. * @returns if the box was hit
  81876. */
  81877. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81878. /**
  81879. * Checks if the ray intersects a box
  81880. * @param box the bounding box to check
  81881. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81882. * @returns if the box was hit
  81883. */
  81884. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81885. /**
  81886. * If the ray hits a sphere
  81887. * @param sphere the bounding sphere to check
  81888. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81889. * @returns true if it hits the sphere
  81890. */
  81891. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81892. /**
  81893. * If the ray hits a triange
  81894. * @param vertex0 triangle vertex
  81895. * @param vertex1 triangle vertex
  81896. * @param vertex2 triangle vertex
  81897. * @returns intersection information if hit
  81898. */
  81899. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81900. /**
  81901. * Checks if ray intersects a plane
  81902. * @param plane the plane to check
  81903. * @returns the distance away it was hit
  81904. */
  81905. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81906. /**
  81907. * Calculate the intercept of a ray on a given axis
  81908. * @param axis to check 'x' | 'y' | 'z'
  81909. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81910. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81911. */
  81912. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81913. /**
  81914. * Checks if ray intersects a mesh
  81915. * @param mesh the mesh to check
  81916. * @param fastCheck if only the bounding box should checked
  81917. * @returns picking info of the intersecton
  81918. */
  81919. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81920. /**
  81921. * Checks if ray intersects a mesh
  81922. * @param meshes the meshes to check
  81923. * @param fastCheck if only the bounding box should checked
  81924. * @param results array to store result in
  81925. * @returns Array of picking infos
  81926. */
  81927. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81928. private _comparePickingInfo;
  81929. private static smallnum;
  81930. private static rayl;
  81931. /**
  81932. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81933. * @param sega the first point of the segment to test the intersection against
  81934. * @param segb the second point of the segment to test the intersection against
  81935. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81936. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81937. */
  81938. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81939. /**
  81940. * Update the ray from viewport position
  81941. * @param x position
  81942. * @param y y position
  81943. * @param viewportWidth viewport width
  81944. * @param viewportHeight viewport height
  81945. * @param world world matrix
  81946. * @param view view matrix
  81947. * @param projection projection matrix
  81948. * @returns this ray updated
  81949. */
  81950. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81951. /**
  81952. * Creates a ray with origin and direction of 0,0,0
  81953. * @returns the new ray
  81954. */
  81955. static Zero(): Ray;
  81956. /**
  81957. * Creates a new ray from screen space and viewport
  81958. * @param x position
  81959. * @param y y position
  81960. * @param viewportWidth viewport width
  81961. * @param viewportHeight viewport height
  81962. * @param world world matrix
  81963. * @param view view matrix
  81964. * @param projection projection matrix
  81965. * @returns new ray
  81966. */
  81967. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81968. /**
  81969. * 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
  81970. * transformed to the given world matrix.
  81971. * @param origin The origin point
  81972. * @param end The end point
  81973. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81974. * @returns the new ray
  81975. */
  81976. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81977. /**
  81978. * Transforms a ray by a matrix
  81979. * @param ray ray to transform
  81980. * @param matrix matrix to apply
  81981. * @returns the resulting new ray
  81982. */
  81983. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81984. /**
  81985. * Transforms a ray by a matrix
  81986. * @param ray ray to transform
  81987. * @param matrix matrix to apply
  81988. * @param result ray to store result in
  81989. */
  81990. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81991. /**
  81992. * Unproject a ray from screen space to object space
  81993. * @param sourceX defines the screen space x coordinate to use
  81994. * @param sourceY defines the screen space y coordinate to use
  81995. * @param viewportWidth defines the current width of the viewport
  81996. * @param viewportHeight defines the current height of the viewport
  81997. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81998. * @param view defines the view matrix to use
  81999. * @param projection defines the projection matrix to use
  82000. */
  82001. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82002. }
  82003. /**
  82004. * Type used to define predicate used to select faces when a mesh intersection is detected
  82005. */
  82006. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82007. interface Scene {
  82008. /** @hidden */
  82009. _tempPickingRay: Nullable<Ray>;
  82010. /** @hidden */
  82011. _cachedRayForTransform: Ray;
  82012. /** @hidden */
  82013. _pickWithRayInverseMatrix: Matrix;
  82014. /** @hidden */
  82015. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82016. /** @hidden */
  82017. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82018. }
  82019. }
  82020. declare module BABYLON {
  82021. /**
  82022. * Groups all the scene component constants in one place to ease maintenance.
  82023. * @hidden
  82024. */
  82025. export class SceneComponentConstants {
  82026. static readonly NAME_EFFECTLAYER: string;
  82027. static readonly NAME_LAYER: string;
  82028. static readonly NAME_LENSFLARESYSTEM: string;
  82029. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82030. static readonly NAME_PARTICLESYSTEM: string;
  82031. static readonly NAME_GAMEPAD: string;
  82032. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82033. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82034. static readonly NAME_DEPTHRENDERER: string;
  82035. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82036. static readonly NAME_SPRITE: string;
  82037. static readonly NAME_OUTLINERENDERER: string;
  82038. static readonly NAME_PROCEDURALTEXTURE: string;
  82039. static readonly NAME_SHADOWGENERATOR: string;
  82040. static readonly NAME_OCTREE: string;
  82041. static readonly NAME_PHYSICSENGINE: string;
  82042. static readonly NAME_AUDIO: string;
  82043. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82044. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82045. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82046. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82047. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82048. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82049. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82050. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82051. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82052. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82053. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82054. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82055. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82056. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82057. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82058. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82059. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82060. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82061. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82062. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82063. static readonly STEP_AFTERRENDER_AUDIO: number;
  82064. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82065. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82066. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82067. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82068. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82069. static readonly STEP_POINTERMOVE_SPRITE: number;
  82070. static readonly STEP_POINTERDOWN_SPRITE: number;
  82071. static readonly STEP_POINTERUP_SPRITE: number;
  82072. }
  82073. /**
  82074. * This represents a scene component.
  82075. *
  82076. * This is used to decouple the dependency the scene is having on the different workloads like
  82077. * layers, post processes...
  82078. */
  82079. export interface ISceneComponent {
  82080. /**
  82081. * The name of the component. Each component must have a unique name.
  82082. */
  82083. name: string;
  82084. /**
  82085. * The scene the component belongs to.
  82086. */
  82087. scene: Scene;
  82088. /**
  82089. * Register the component to one instance of a scene.
  82090. */
  82091. register(): void;
  82092. /**
  82093. * Rebuilds the elements related to this component in case of
  82094. * context lost for instance.
  82095. */
  82096. rebuild(): void;
  82097. /**
  82098. * Disposes the component and the associated ressources.
  82099. */
  82100. dispose(): void;
  82101. }
  82102. /**
  82103. * This represents a SERIALIZABLE scene component.
  82104. *
  82105. * This extends Scene Component to add Serialization methods on top.
  82106. */
  82107. export interface ISceneSerializableComponent extends ISceneComponent {
  82108. /**
  82109. * Adds all the elements from the container to the scene
  82110. * @param container the container holding the elements
  82111. */
  82112. addFromContainer(container: AbstractScene): void;
  82113. /**
  82114. * Removes all the elements in the container from the scene
  82115. * @param container contains the elements to remove
  82116. * @param dispose if the removed element should be disposed (default: false)
  82117. */
  82118. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82119. /**
  82120. * Serializes the component data to the specified json object
  82121. * @param serializationObject The object to serialize to
  82122. */
  82123. serialize(serializationObject: any): void;
  82124. }
  82125. /**
  82126. * Strong typing of a Mesh related stage step action
  82127. */
  82128. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82129. /**
  82130. * Strong typing of a Evaluate Sub Mesh related stage step action
  82131. */
  82132. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82133. /**
  82134. * Strong typing of a Active Mesh related stage step action
  82135. */
  82136. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82137. /**
  82138. * Strong typing of a Camera related stage step action
  82139. */
  82140. export type CameraStageAction = (camera: Camera) => void;
  82141. /**
  82142. * Strong typing of a Camera Frame buffer related stage step action
  82143. */
  82144. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82145. /**
  82146. * Strong typing of a Render Target related stage step action
  82147. */
  82148. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82149. /**
  82150. * Strong typing of a RenderingGroup related stage step action
  82151. */
  82152. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82153. /**
  82154. * Strong typing of a Mesh Render related stage step action
  82155. */
  82156. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82157. /**
  82158. * Strong typing of a simple stage step action
  82159. */
  82160. export type SimpleStageAction = () => void;
  82161. /**
  82162. * Strong typing of a render target action.
  82163. */
  82164. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82165. /**
  82166. * Strong typing of a pointer move action.
  82167. */
  82168. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82169. /**
  82170. * Strong typing of a pointer up/down action.
  82171. */
  82172. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82173. /**
  82174. * Representation of a stage in the scene (Basically a list of ordered steps)
  82175. * @hidden
  82176. */
  82177. export class Stage<T extends Function> extends Array<{
  82178. index: number;
  82179. component: ISceneComponent;
  82180. action: T;
  82181. }> {
  82182. /**
  82183. * Hide ctor from the rest of the world.
  82184. * @param items The items to add.
  82185. */
  82186. private constructor();
  82187. /**
  82188. * Creates a new Stage.
  82189. * @returns A new instance of a Stage
  82190. */
  82191. static Create<T extends Function>(): Stage<T>;
  82192. /**
  82193. * Registers a step in an ordered way in the targeted stage.
  82194. * @param index Defines the position to register the step in
  82195. * @param component Defines the component attached to the step
  82196. * @param action Defines the action to launch during the step
  82197. */
  82198. registerStep(index: number, component: ISceneComponent, action: T): void;
  82199. /**
  82200. * Clears all the steps from the stage.
  82201. */
  82202. clear(): void;
  82203. }
  82204. }
  82205. declare module BABYLON {
  82206. interface Scene {
  82207. /** @hidden */
  82208. _pointerOverSprite: Nullable<Sprite>;
  82209. /** @hidden */
  82210. _pickedDownSprite: Nullable<Sprite>;
  82211. /** @hidden */
  82212. _tempSpritePickingRay: Nullable<Ray>;
  82213. /**
  82214. * All of the sprite managers added to this scene
  82215. * @see http://doc.babylonjs.com/babylon101/sprites
  82216. */
  82217. spriteManagers: Array<ISpriteManager>;
  82218. /**
  82219. * An event triggered when sprites rendering is about to start
  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. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82223. /**
  82224. * An event triggered when sprites rendering is done
  82225. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82226. */
  82227. onAfterSpritesRenderingObservable: Observable<Scene>;
  82228. /** @hidden */
  82229. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82230. /** Launch a ray to try to pick a sprite in the scene
  82231. * @param x position on screen
  82232. * @param y position on screen
  82233. * @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
  82234. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82235. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82236. * @returns a PickingInfo
  82237. */
  82238. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82239. /** Use the given ray to pick a sprite in the scene
  82240. * @param ray The ray (in world space) to use to pick meshes
  82241. * @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
  82242. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82243. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82244. * @returns a PickingInfo
  82245. */
  82246. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82247. /** @hidden */
  82248. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82249. /** Launch a ray to try to pick sprites in the scene
  82250. * @param x position on screen
  82251. * @param y position on screen
  82252. * @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
  82253. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82254. * @returns a PickingInfo array
  82255. */
  82256. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82257. /** Use the given ray to pick sprites in the scene
  82258. * @param ray The ray (in world space) to use to pick meshes
  82259. * @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
  82260. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82261. * @returns a PickingInfo array
  82262. */
  82263. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82264. /**
  82265. * Force the sprite under the pointer
  82266. * @param sprite defines the sprite to use
  82267. */
  82268. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82269. /**
  82270. * Gets the sprite under the pointer
  82271. * @returns a Sprite or null if no sprite is under the pointer
  82272. */
  82273. getPointerOverSprite(): Nullable<Sprite>;
  82274. }
  82275. /**
  82276. * Defines the sprite scene component responsible to manage sprites
  82277. * in a given scene.
  82278. */
  82279. export class SpriteSceneComponent implements ISceneComponent {
  82280. /**
  82281. * The component name helpfull to identify the component in the list of scene components.
  82282. */
  82283. readonly name: string;
  82284. /**
  82285. * The scene the component belongs to.
  82286. */
  82287. scene: Scene;
  82288. /** @hidden */
  82289. private _spritePredicate;
  82290. /**
  82291. * Creates a new instance of the component for the given scene
  82292. * @param scene Defines the scene to register the component in
  82293. */
  82294. constructor(scene: Scene);
  82295. /**
  82296. * Registers the component in a given scene
  82297. */
  82298. register(): void;
  82299. /**
  82300. * Rebuilds the elements related to this component in case of
  82301. * context lost for instance.
  82302. */
  82303. rebuild(): void;
  82304. /**
  82305. * Disposes the component and the associated ressources.
  82306. */
  82307. dispose(): void;
  82308. private _pickSpriteButKeepRay;
  82309. private _pointerMove;
  82310. private _pointerDown;
  82311. private _pointerUp;
  82312. }
  82313. }
  82314. declare module BABYLON {
  82315. /** @hidden */
  82316. export var fogFragmentDeclaration: {
  82317. name: string;
  82318. shader: string;
  82319. };
  82320. }
  82321. declare module BABYLON {
  82322. /** @hidden */
  82323. export var fogFragment: {
  82324. name: string;
  82325. shader: string;
  82326. };
  82327. }
  82328. declare module BABYLON {
  82329. /** @hidden */
  82330. export var spritesPixelShader: {
  82331. name: string;
  82332. shader: string;
  82333. };
  82334. }
  82335. declare module BABYLON {
  82336. /** @hidden */
  82337. export var fogVertexDeclaration: {
  82338. name: string;
  82339. shader: string;
  82340. };
  82341. }
  82342. declare module BABYLON {
  82343. /** @hidden */
  82344. export var spritesVertexShader: {
  82345. name: string;
  82346. shader: string;
  82347. };
  82348. }
  82349. declare module BABYLON {
  82350. /**
  82351. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82352. */
  82353. export interface ISpriteManager extends IDisposable {
  82354. /**
  82355. * Restricts the camera to viewing objects with the same layerMask.
  82356. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82357. */
  82358. layerMask: number;
  82359. /**
  82360. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82361. */
  82362. isPickable: boolean;
  82363. /**
  82364. * Specifies the rendering group id for this mesh (0 by default)
  82365. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82366. */
  82367. renderingGroupId: number;
  82368. /**
  82369. * Defines the list of sprites managed by the manager.
  82370. */
  82371. sprites: Array<Sprite>;
  82372. /**
  82373. * Tests the intersection of a sprite with a specific ray.
  82374. * @param ray The ray we are sending to test the collision
  82375. * @param camera The camera space we are sending rays in
  82376. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82377. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82378. * @returns picking info or null.
  82379. */
  82380. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82381. /**
  82382. * Intersects the sprites with a ray
  82383. * @param ray defines the ray to intersect with
  82384. * @param camera defines the current active camera
  82385. * @param predicate defines a predicate used to select candidate sprites
  82386. * @returns null if no hit or a PickingInfo array
  82387. */
  82388. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82389. /**
  82390. * Renders the list of sprites on screen.
  82391. */
  82392. render(): void;
  82393. }
  82394. /**
  82395. * Class used to manage multiple sprites on the same spritesheet
  82396. * @see http://doc.babylonjs.com/babylon101/sprites
  82397. */
  82398. export class SpriteManager implements ISpriteManager {
  82399. /** defines the manager's name */
  82400. name: string;
  82401. /** Gets the list of sprites */
  82402. sprites: Sprite[];
  82403. /** Gets or sets the rendering group id (0 by default) */
  82404. renderingGroupId: number;
  82405. /** Gets or sets camera layer mask */
  82406. layerMask: number;
  82407. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82408. fogEnabled: boolean;
  82409. /** Gets or sets a boolean indicating if the sprites are pickable */
  82410. isPickable: boolean;
  82411. /** Defines the default width of a cell in the spritesheet */
  82412. cellWidth: number;
  82413. /** Defines the default height of a cell in the spritesheet */
  82414. cellHeight: number;
  82415. /** Associative array from JSON sprite data file */
  82416. private _cellData;
  82417. /** Array of sprite names from JSON sprite data file */
  82418. private _spriteMap;
  82419. /** True when packed cell data from JSON file is ready*/
  82420. private _packedAndReady;
  82421. /**
  82422. * An event triggered when the manager is disposed.
  82423. */
  82424. onDisposeObservable: Observable<SpriteManager>;
  82425. private _onDisposeObserver;
  82426. /**
  82427. * Callback called when the manager is disposed
  82428. */
  82429. set onDispose(callback: () => void);
  82430. private _capacity;
  82431. private _fromPacked;
  82432. private _spriteTexture;
  82433. private _epsilon;
  82434. private _scene;
  82435. private _vertexData;
  82436. private _buffer;
  82437. private _vertexBuffers;
  82438. private _indexBuffer;
  82439. private _effectBase;
  82440. private _effectFog;
  82441. /**
  82442. * Gets or sets the spritesheet texture
  82443. */
  82444. get texture(): Texture;
  82445. set texture(value: Texture);
  82446. /**
  82447. * Creates a new sprite manager
  82448. * @param name defines the manager's name
  82449. * @param imgUrl defines the sprite sheet url
  82450. * @param capacity defines the maximum allowed number of sprites
  82451. * @param cellSize defines the size of a sprite cell
  82452. * @param scene defines the hosting scene
  82453. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82454. * @param samplingMode defines the smapling mode to use with spritesheet
  82455. * @param fromPacked set to false; do not alter
  82456. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82457. */
  82458. constructor(
  82459. /** defines the manager's name */
  82460. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82461. private _makePacked;
  82462. private _appendSpriteVertex;
  82463. /**
  82464. * Intersects the sprites with a ray
  82465. * @param ray defines the ray to intersect with
  82466. * @param camera defines the current active camera
  82467. * @param predicate defines a predicate used to select candidate sprites
  82468. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82469. * @returns null if no hit or a PickingInfo
  82470. */
  82471. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82472. /**
  82473. * Intersects the sprites with a ray
  82474. * @param ray defines the ray to intersect with
  82475. * @param camera defines the current active camera
  82476. * @param predicate defines a predicate used to select candidate sprites
  82477. * @returns null if no hit or a PickingInfo array
  82478. */
  82479. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82480. /**
  82481. * Render all child sprites
  82482. */
  82483. render(): void;
  82484. /**
  82485. * Release associated resources
  82486. */
  82487. dispose(): void;
  82488. }
  82489. }
  82490. declare module BABYLON {
  82491. /**
  82492. * Class used to represent a sprite
  82493. * @see http://doc.babylonjs.com/babylon101/sprites
  82494. */
  82495. export class Sprite {
  82496. /** defines the name */
  82497. name: string;
  82498. /** Gets or sets the current world position */
  82499. position: Vector3;
  82500. /** Gets or sets the main color */
  82501. color: Color4;
  82502. /** Gets or sets the width */
  82503. width: number;
  82504. /** Gets or sets the height */
  82505. height: number;
  82506. /** Gets or sets rotation angle */
  82507. angle: number;
  82508. /** Gets or sets the cell index in the sprite sheet */
  82509. cellIndex: number;
  82510. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82511. cellRef: string;
  82512. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82513. invertU: number;
  82514. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82515. invertV: number;
  82516. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82517. disposeWhenFinishedAnimating: boolean;
  82518. /** Gets the list of attached animations */
  82519. animations: Animation[];
  82520. /** Gets or sets a boolean indicating if the sprite can be picked */
  82521. isPickable: boolean;
  82522. /**
  82523. * Gets or sets the associated action manager
  82524. */
  82525. actionManager: Nullable<ActionManager>;
  82526. private _animationStarted;
  82527. private _loopAnimation;
  82528. private _fromIndex;
  82529. private _toIndex;
  82530. private _delay;
  82531. private _direction;
  82532. private _manager;
  82533. private _time;
  82534. private _onAnimationEnd;
  82535. /**
  82536. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82537. */
  82538. isVisible: boolean;
  82539. /**
  82540. * Gets or sets the sprite size
  82541. */
  82542. get size(): number;
  82543. set size(value: number);
  82544. /**
  82545. * Creates a new Sprite
  82546. * @param name defines the name
  82547. * @param manager defines the manager
  82548. */
  82549. constructor(
  82550. /** defines the name */
  82551. name: string, manager: ISpriteManager);
  82552. /**
  82553. * Starts an animation
  82554. * @param from defines the initial key
  82555. * @param to defines the end key
  82556. * @param loop defines if the animation must loop
  82557. * @param delay defines the start delay (in ms)
  82558. * @param onAnimationEnd defines a callback to call when animation ends
  82559. */
  82560. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82561. /** Stops current animation (if any) */
  82562. stopAnimation(): void;
  82563. /** @hidden */
  82564. _animate(deltaTime: number): void;
  82565. /** Release associated resources */
  82566. dispose(): void;
  82567. }
  82568. }
  82569. declare module BABYLON {
  82570. /**
  82571. * Information about the result of picking within a scene
  82572. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82573. */
  82574. export class PickingInfo {
  82575. /** @hidden */
  82576. _pickingUnavailable: boolean;
  82577. /**
  82578. * If the pick collided with an object
  82579. */
  82580. hit: boolean;
  82581. /**
  82582. * Distance away where the pick collided
  82583. */
  82584. distance: number;
  82585. /**
  82586. * The location of pick collision
  82587. */
  82588. pickedPoint: Nullable<Vector3>;
  82589. /**
  82590. * The mesh corresponding the the pick collision
  82591. */
  82592. pickedMesh: Nullable<AbstractMesh>;
  82593. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82594. bu: number;
  82595. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82596. bv: number;
  82597. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82598. faceId: number;
  82599. /** Id of the the submesh that was picked */
  82600. subMeshId: number;
  82601. /** If a sprite was picked, this will be the sprite the pick collided with */
  82602. pickedSprite: Nullable<Sprite>;
  82603. /**
  82604. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82605. */
  82606. originMesh: Nullable<AbstractMesh>;
  82607. /**
  82608. * The ray that was used to perform the picking.
  82609. */
  82610. ray: Nullable<Ray>;
  82611. /**
  82612. * Gets the normal correspodning to the face the pick collided with
  82613. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82614. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82615. * @returns The normal correspodning to the face the pick collided with
  82616. */
  82617. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82618. /**
  82619. * Gets the texture coordinates of where the pick occured
  82620. * @returns the vector containing the coordnates of the texture
  82621. */
  82622. getTextureCoordinates(): Nullable<Vector2>;
  82623. }
  82624. }
  82625. declare module BABYLON {
  82626. /**
  82627. * Gather the list of pointer event types as constants.
  82628. */
  82629. export class PointerEventTypes {
  82630. /**
  82631. * 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.
  82632. */
  82633. static readonly POINTERDOWN: number;
  82634. /**
  82635. * The pointerup event is fired when a pointer is no longer active.
  82636. */
  82637. static readonly POINTERUP: number;
  82638. /**
  82639. * The pointermove event is fired when a pointer changes coordinates.
  82640. */
  82641. static readonly POINTERMOVE: number;
  82642. /**
  82643. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82644. */
  82645. static readonly POINTERWHEEL: number;
  82646. /**
  82647. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82648. */
  82649. static readonly POINTERPICK: number;
  82650. /**
  82651. * The pointertap event is fired when a the object has been touched and released without drag.
  82652. */
  82653. static readonly POINTERTAP: number;
  82654. /**
  82655. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82656. */
  82657. static readonly POINTERDOUBLETAP: number;
  82658. }
  82659. /**
  82660. * Base class of pointer info types.
  82661. */
  82662. export class PointerInfoBase {
  82663. /**
  82664. * Defines the type of event (PointerEventTypes)
  82665. */
  82666. type: number;
  82667. /**
  82668. * Defines the related dom event
  82669. */
  82670. event: PointerEvent | MouseWheelEvent;
  82671. /**
  82672. * Instantiates the base class of pointers info.
  82673. * @param type Defines the type of event (PointerEventTypes)
  82674. * @param event Defines the related dom event
  82675. */
  82676. constructor(
  82677. /**
  82678. * Defines the type of event (PointerEventTypes)
  82679. */
  82680. type: number,
  82681. /**
  82682. * Defines the related dom event
  82683. */
  82684. event: PointerEvent | MouseWheelEvent);
  82685. }
  82686. /**
  82687. * This class is used to store pointer related info for the onPrePointerObservable event.
  82688. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82689. */
  82690. export class PointerInfoPre extends PointerInfoBase {
  82691. /**
  82692. * Ray from a pointer if availible (eg. 6dof controller)
  82693. */
  82694. ray: Nullable<Ray>;
  82695. /**
  82696. * Defines the local position of the pointer on the canvas.
  82697. */
  82698. localPosition: Vector2;
  82699. /**
  82700. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82701. */
  82702. skipOnPointerObservable: boolean;
  82703. /**
  82704. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82705. * @param type Defines the type of event (PointerEventTypes)
  82706. * @param event Defines the related dom event
  82707. * @param localX Defines the local x coordinates of the pointer when the event occured
  82708. * @param localY Defines the local y coordinates of the pointer when the event occured
  82709. */
  82710. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82711. }
  82712. /**
  82713. * This type contains all the data related to a pointer event in Babylon.js.
  82714. * 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.
  82715. */
  82716. export class PointerInfo extends PointerInfoBase {
  82717. /**
  82718. * Defines the picking info associated to the info (if any)\
  82719. */
  82720. pickInfo: Nullable<PickingInfo>;
  82721. /**
  82722. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82723. * @param type Defines the type of event (PointerEventTypes)
  82724. * @param event Defines the related dom event
  82725. * @param pickInfo Defines the picking info associated to the info (if any)\
  82726. */
  82727. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82728. /**
  82729. * Defines the picking info associated to the info (if any)\
  82730. */
  82731. pickInfo: Nullable<PickingInfo>);
  82732. }
  82733. /**
  82734. * Data relating to a touch event on the screen.
  82735. */
  82736. export interface PointerTouch {
  82737. /**
  82738. * X coordinate of touch.
  82739. */
  82740. x: number;
  82741. /**
  82742. * Y coordinate of touch.
  82743. */
  82744. y: number;
  82745. /**
  82746. * Id of touch. Unique for each finger.
  82747. */
  82748. pointerId: number;
  82749. /**
  82750. * Event type passed from DOM.
  82751. */
  82752. type: any;
  82753. }
  82754. }
  82755. declare module BABYLON {
  82756. /**
  82757. * Manage the mouse inputs to control the movement of a free camera.
  82758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82759. */
  82760. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82761. /**
  82762. * Define if touch is enabled in the mouse input
  82763. */
  82764. touchEnabled: boolean;
  82765. /**
  82766. * Defines the camera the input is attached to.
  82767. */
  82768. camera: FreeCamera;
  82769. /**
  82770. * Defines the buttons associated with the input to handle camera move.
  82771. */
  82772. buttons: number[];
  82773. /**
  82774. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82775. */
  82776. angularSensibility: number;
  82777. private _pointerInput;
  82778. private _onMouseMove;
  82779. private _observer;
  82780. private previousPosition;
  82781. /**
  82782. * Observable for when a pointer move event occurs containing the move offset
  82783. */
  82784. onPointerMovedObservable: Observable<{
  82785. offsetX: number;
  82786. offsetY: number;
  82787. }>;
  82788. /**
  82789. * @hidden
  82790. * If the camera should be rotated automatically based on pointer movement
  82791. */
  82792. _allowCameraRotation: boolean;
  82793. /**
  82794. * Manage the mouse inputs to control the movement of a free camera.
  82795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82796. * @param touchEnabled Defines if touch is enabled or not
  82797. */
  82798. constructor(
  82799. /**
  82800. * Define if touch is enabled in the mouse input
  82801. */
  82802. touchEnabled?: boolean);
  82803. /**
  82804. * Attach the input controls to a specific dom element to get the input from.
  82805. * @param element Defines the element the controls should be listened from
  82806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82807. */
  82808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82809. /**
  82810. * Called on JS contextmenu event.
  82811. * Override this method to provide functionality.
  82812. */
  82813. protected onContextMenu(evt: PointerEvent): void;
  82814. /**
  82815. * Detach the current controls from the specified dom element.
  82816. * @param element Defines the element to stop listening the inputs from
  82817. */
  82818. detachControl(element: Nullable<HTMLElement>): void;
  82819. /**
  82820. * Gets the class name of the current intput.
  82821. * @returns the class name
  82822. */
  82823. getClassName(): string;
  82824. /**
  82825. * Get the friendly name associated with the input class.
  82826. * @returns the input friendly name
  82827. */
  82828. getSimpleName(): string;
  82829. }
  82830. }
  82831. declare module BABYLON {
  82832. /**
  82833. * Manage the touch inputs to control the movement of a free camera.
  82834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82835. */
  82836. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82837. /**
  82838. * Defines the camera the input is attached to.
  82839. */
  82840. camera: FreeCamera;
  82841. /**
  82842. * Defines the touch sensibility for rotation.
  82843. * The higher the faster.
  82844. */
  82845. touchAngularSensibility: number;
  82846. /**
  82847. * Defines the touch sensibility for move.
  82848. * The higher the faster.
  82849. */
  82850. touchMoveSensibility: number;
  82851. private _offsetX;
  82852. private _offsetY;
  82853. private _pointerPressed;
  82854. private _pointerInput;
  82855. private _observer;
  82856. private _onLostFocus;
  82857. /**
  82858. * Attach the input controls to a specific dom element to get the input from.
  82859. * @param element Defines the element the controls should be listened from
  82860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82861. */
  82862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82863. /**
  82864. * Detach the current controls from the specified dom element.
  82865. * @param element Defines the element to stop listening the inputs from
  82866. */
  82867. detachControl(element: Nullable<HTMLElement>): void;
  82868. /**
  82869. * Update the current camera state depending on the inputs that have been used this frame.
  82870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82871. */
  82872. checkInputs(): void;
  82873. /**
  82874. * Gets the class name of the current intput.
  82875. * @returns the class name
  82876. */
  82877. getClassName(): string;
  82878. /**
  82879. * Get the friendly name associated with the input class.
  82880. * @returns the input friendly name
  82881. */
  82882. getSimpleName(): string;
  82883. }
  82884. }
  82885. declare module BABYLON {
  82886. /**
  82887. * Default Inputs manager for the FreeCamera.
  82888. * It groups all the default supported inputs for ease of use.
  82889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82890. */
  82891. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82892. /**
  82893. * @hidden
  82894. */
  82895. _mouseInput: Nullable<FreeCameraMouseInput>;
  82896. /**
  82897. * Instantiates a new FreeCameraInputsManager.
  82898. * @param camera Defines the camera the inputs belong to
  82899. */
  82900. constructor(camera: FreeCamera);
  82901. /**
  82902. * Add keyboard input support to the input manager.
  82903. * @returns the current input manager
  82904. */
  82905. addKeyboard(): FreeCameraInputsManager;
  82906. /**
  82907. * Add mouse input support to the input manager.
  82908. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82909. * @returns the current input manager
  82910. */
  82911. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82912. /**
  82913. * Removes the mouse input support from the manager
  82914. * @returns the current input manager
  82915. */
  82916. removeMouse(): FreeCameraInputsManager;
  82917. /**
  82918. * Add touch input support to the input manager.
  82919. * @returns the current input manager
  82920. */
  82921. addTouch(): FreeCameraInputsManager;
  82922. /**
  82923. * Remove all attached input methods from a camera
  82924. */
  82925. clear(): void;
  82926. }
  82927. }
  82928. declare module BABYLON {
  82929. /**
  82930. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82931. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82932. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82933. */
  82934. export class FreeCamera extends TargetCamera {
  82935. /**
  82936. * Define the collision ellipsoid of the camera.
  82937. * This is helpful to simulate a camera body like the player body around the camera
  82938. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82939. */
  82940. ellipsoid: Vector3;
  82941. /**
  82942. * Define an offset for the position of the ellipsoid around the camera.
  82943. * This can be helpful to determine the center of the body near the gravity center of the body
  82944. * instead of its head.
  82945. */
  82946. ellipsoidOffset: Vector3;
  82947. /**
  82948. * Enable or disable collisions of the camera with the rest of the scene objects.
  82949. */
  82950. checkCollisions: boolean;
  82951. /**
  82952. * Enable or disable gravity on the camera.
  82953. */
  82954. applyGravity: boolean;
  82955. /**
  82956. * Define the input manager associated to the camera.
  82957. */
  82958. inputs: FreeCameraInputsManager;
  82959. /**
  82960. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82961. * Higher values reduce sensitivity.
  82962. */
  82963. get angularSensibility(): number;
  82964. /**
  82965. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82966. * Higher values reduce sensitivity.
  82967. */
  82968. set angularSensibility(value: number);
  82969. /**
  82970. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82971. */
  82972. get keysUp(): number[];
  82973. set keysUp(value: number[]);
  82974. /**
  82975. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82976. */
  82977. get keysDown(): number[];
  82978. set keysDown(value: number[]);
  82979. /**
  82980. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82981. */
  82982. get keysLeft(): number[];
  82983. set keysLeft(value: number[]);
  82984. /**
  82985. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82986. */
  82987. get keysRight(): number[];
  82988. set keysRight(value: number[]);
  82989. /**
  82990. * Event raised when the camera collide with a mesh in the scene.
  82991. */
  82992. onCollide: (collidedMesh: AbstractMesh) => void;
  82993. private _collider;
  82994. private _needMoveForGravity;
  82995. private _oldPosition;
  82996. private _diffPosition;
  82997. private _newPosition;
  82998. /** @hidden */
  82999. _localDirection: Vector3;
  83000. /** @hidden */
  83001. _transformedDirection: Vector3;
  83002. /**
  83003. * Instantiates a Free Camera.
  83004. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83005. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  83006. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83007. * @param name Define the name of the camera in the scene
  83008. * @param position Define the start position of the camera in the scene
  83009. * @param scene Define the scene the camera belongs to
  83010. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  83011. */
  83012. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  83013. /**
  83014. * Attached controls to the current camera.
  83015. * @param element Defines the element the controls should be listened from
  83016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83017. */
  83018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83019. /**
  83020. * Detach the current controls from the camera.
  83021. * The camera will stop reacting to inputs.
  83022. * @param element Defines the element to stop listening the inputs from
  83023. */
  83024. detachControl(element: HTMLElement): void;
  83025. private _collisionMask;
  83026. /**
  83027. * Define a collision mask to limit the list of object the camera can collide with
  83028. */
  83029. get collisionMask(): number;
  83030. set collisionMask(mask: number);
  83031. /** @hidden */
  83032. _collideWithWorld(displacement: Vector3): void;
  83033. private _onCollisionPositionChange;
  83034. /** @hidden */
  83035. _checkInputs(): void;
  83036. /** @hidden */
  83037. _decideIfNeedsToMove(): boolean;
  83038. /** @hidden */
  83039. _updatePosition(): void;
  83040. /**
  83041. * Destroy the camera and release the current resources hold by it.
  83042. */
  83043. dispose(): void;
  83044. /**
  83045. * Gets the current object class name.
  83046. * @return the class name
  83047. */
  83048. getClassName(): string;
  83049. }
  83050. }
  83051. declare module BABYLON {
  83052. /**
  83053. * Represents a gamepad control stick position
  83054. */
  83055. export class StickValues {
  83056. /**
  83057. * The x component of the control stick
  83058. */
  83059. x: number;
  83060. /**
  83061. * The y component of the control stick
  83062. */
  83063. y: number;
  83064. /**
  83065. * Initializes the gamepad x and y control stick values
  83066. * @param x The x component of the gamepad control stick value
  83067. * @param y The y component of the gamepad control stick value
  83068. */
  83069. constructor(
  83070. /**
  83071. * The x component of the control stick
  83072. */
  83073. x: number,
  83074. /**
  83075. * The y component of the control stick
  83076. */
  83077. y: number);
  83078. }
  83079. /**
  83080. * An interface which manages callbacks for gamepad button changes
  83081. */
  83082. export interface GamepadButtonChanges {
  83083. /**
  83084. * Called when a gamepad has been changed
  83085. */
  83086. changed: boolean;
  83087. /**
  83088. * Called when a gamepad press event has been triggered
  83089. */
  83090. pressChanged: boolean;
  83091. /**
  83092. * Called when a touch event has been triggered
  83093. */
  83094. touchChanged: boolean;
  83095. /**
  83096. * Called when a value has changed
  83097. */
  83098. valueChanged: boolean;
  83099. }
  83100. /**
  83101. * Represents a gamepad
  83102. */
  83103. export class Gamepad {
  83104. /**
  83105. * The id of the gamepad
  83106. */
  83107. id: string;
  83108. /**
  83109. * The index of the gamepad
  83110. */
  83111. index: number;
  83112. /**
  83113. * The browser gamepad
  83114. */
  83115. browserGamepad: any;
  83116. /**
  83117. * Specifies what type of gamepad this represents
  83118. */
  83119. type: number;
  83120. private _leftStick;
  83121. private _rightStick;
  83122. /** @hidden */
  83123. _isConnected: boolean;
  83124. private _leftStickAxisX;
  83125. private _leftStickAxisY;
  83126. private _rightStickAxisX;
  83127. private _rightStickAxisY;
  83128. /**
  83129. * Triggered when the left control stick has been changed
  83130. */
  83131. private _onleftstickchanged;
  83132. /**
  83133. * Triggered when the right control stick has been changed
  83134. */
  83135. private _onrightstickchanged;
  83136. /**
  83137. * Represents a gamepad controller
  83138. */
  83139. static GAMEPAD: number;
  83140. /**
  83141. * Represents a generic controller
  83142. */
  83143. static GENERIC: number;
  83144. /**
  83145. * Represents an XBox controller
  83146. */
  83147. static XBOX: number;
  83148. /**
  83149. * Represents a pose-enabled controller
  83150. */
  83151. static POSE_ENABLED: number;
  83152. /**
  83153. * Represents an Dual Shock controller
  83154. */
  83155. static DUALSHOCK: number;
  83156. /**
  83157. * Specifies whether the left control stick should be Y-inverted
  83158. */
  83159. protected _invertLeftStickY: boolean;
  83160. /**
  83161. * Specifies if the gamepad has been connected
  83162. */
  83163. get isConnected(): boolean;
  83164. /**
  83165. * Initializes the gamepad
  83166. * @param id The id of the gamepad
  83167. * @param index The index of the gamepad
  83168. * @param browserGamepad The browser gamepad
  83169. * @param leftStickX The x component of the left joystick
  83170. * @param leftStickY The y component of the left joystick
  83171. * @param rightStickX The x component of the right joystick
  83172. * @param rightStickY The y component of the right joystick
  83173. */
  83174. constructor(
  83175. /**
  83176. * The id of the gamepad
  83177. */
  83178. id: string,
  83179. /**
  83180. * The index of the gamepad
  83181. */
  83182. index: number,
  83183. /**
  83184. * The browser gamepad
  83185. */
  83186. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83187. /**
  83188. * Callback triggered when the left joystick has changed
  83189. * @param callback
  83190. */
  83191. onleftstickchanged(callback: (values: StickValues) => void): void;
  83192. /**
  83193. * Callback triggered when the right joystick has changed
  83194. * @param callback
  83195. */
  83196. onrightstickchanged(callback: (values: StickValues) => void): void;
  83197. /**
  83198. * Gets the left joystick
  83199. */
  83200. get leftStick(): StickValues;
  83201. /**
  83202. * Sets the left joystick values
  83203. */
  83204. set leftStick(newValues: StickValues);
  83205. /**
  83206. * Gets the right joystick
  83207. */
  83208. get rightStick(): StickValues;
  83209. /**
  83210. * Sets the right joystick value
  83211. */
  83212. set rightStick(newValues: StickValues);
  83213. /**
  83214. * Updates the gamepad joystick positions
  83215. */
  83216. update(): void;
  83217. /**
  83218. * Disposes the gamepad
  83219. */
  83220. dispose(): void;
  83221. }
  83222. /**
  83223. * Represents a generic gamepad
  83224. */
  83225. export class GenericPad extends Gamepad {
  83226. private _buttons;
  83227. private _onbuttondown;
  83228. private _onbuttonup;
  83229. /**
  83230. * Observable triggered when a button has been pressed
  83231. */
  83232. onButtonDownObservable: Observable<number>;
  83233. /**
  83234. * Observable triggered when a button has been released
  83235. */
  83236. onButtonUpObservable: Observable<number>;
  83237. /**
  83238. * Callback triggered when a button has been pressed
  83239. * @param callback Called when a button has been pressed
  83240. */
  83241. onbuttondown(callback: (buttonPressed: number) => void): void;
  83242. /**
  83243. * Callback triggered when a button has been released
  83244. * @param callback Called when a button has been released
  83245. */
  83246. onbuttonup(callback: (buttonReleased: number) => void): void;
  83247. /**
  83248. * Initializes the generic gamepad
  83249. * @param id The id of the generic gamepad
  83250. * @param index The index of the generic gamepad
  83251. * @param browserGamepad The browser gamepad
  83252. */
  83253. constructor(id: string, index: number, browserGamepad: any);
  83254. private _setButtonValue;
  83255. /**
  83256. * Updates the generic gamepad
  83257. */
  83258. update(): void;
  83259. /**
  83260. * Disposes the generic gamepad
  83261. */
  83262. dispose(): void;
  83263. }
  83264. }
  83265. declare module BABYLON {
  83266. interface Engine {
  83267. /**
  83268. * Creates a raw texture
  83269. * @param data defines the data to store in the texture
  83270. * @param width defines the width of the texture
  83271. * @param height defines the height of the texture
  83272. * @param format defines the format of the data
  83273. * @param generateMipMaps defines if the engine should generate the mip levels
  83274. * @param invertY defines if data must be stored with Y axis inverted
  83275. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83276. * @param compression defines the compression used (null by default)
  83277. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83278. * @returns the raw texture inside an InternalTexture
  83279. */
  83280. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83281. /**
  83282. * Update a raw texture
  83283. * @param texture defines the texture to update
  83284. * @param data defines the data to store in the texture
  83285. * @param format defines the format of the data
  83286. * @param invertY defines if data must be stored with Y axis inverted
  83287. */
  83288. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83289. /**
  83290. * Update a raw texture
  83291. * @param texture defines the texture to update
  83292. * @param data defines the data to store in the texture
  83293. * @param format defines the format of the data
  83294. * @param invertY defines if data must be stored with Y axis inverted
  83295. * @param compression defines the compression used (null by default)
  83296. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83297. */
  83298. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83299. /**
  83300. * Creates a new raw cube texture
  83301. * @param data defines the array of data to use to create each face
  83302. * @param size defines the size of the textures
  83303. * @param format defines the format of the data
  83304. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83305. * @param generateMipMaps defines if the engine should generate the mip levels
  83306. * @param invertY defines if data must be stored with Y axis inverted
  83307. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83308. * @param compression defines the compression used (null by default)
  83309. * @returns the cube texture as an InternalTexture
  83310. */
  83311. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83312. /**
  83313. * Update a raw cube texture
  83314. * @param texture defines the texture to udpdate
  83315. * @param data defines the data to store
  83316. * @param format defines the data format
  83317. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83318. * @param invertY defines if data must be stored with Y axis inverted
  83319. */
  83320. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83321. /**
  83322. * Update a raw cube texture
  83323. * @param texture defines the texture to udpdate
  83324. * @param data defines the data to store
  83325. * @param format defines the data format
  83326. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83327. * @param invertY defines if data must be stored with Y axis inverted
  83328. * @param compression defines the compression used (null by default)
  83329. */
  83330. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83331. /**
  83332. * Update a raw cube texture
  83333. * @param texture defines the texture to udpdate
  83334. * @param data defines the data to store
  83335. * @param format defines the data format
  83336. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83337. * @param invertY defines if data must be stored with Y axis inverted
  83338. * @param compression defines the compression used (null by default)
  83339. * @param level defines which level of the texture to update
  83340. */
  83341. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83342. /**
  83343. * Creates a new raw cube texture from a specified url
  83344. * @param url defines the url where the data is located
  83345. * @param scene defines the current scene
  83346. * @param size defines the size of the textures
  83347. * @param format defines the format of the data
  83348. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83349. * @param noMipmap defines if the engine should avoid generating the mip levels
  83350. * @param callback defines a callback used to extract texture data from loaded data
  83351. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83352. * @param onLoad defines a callback called when texture is loaded
  83353. * @param onError defines a callback called if there is an error
  83354. * @returns the cube texture as an InternalTexture
  83355. */
  83356. 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;
  83357. /**
  83358. * Creates a new raw cube texture from a specified url
  83359. * @param url defines the url where the data is located
  83360. * @param scene defines the current scene
  83361. * @param size defines the size of the textures
  83362. * @param format defines the format of the data
  83363. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83364. * @param noMipmap defines if the engine should avoid generating the mip levels
  83365. * @param callback defines a callback used to extract texture data from loaded data
  83366. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83367. * @param onLoad defines a callback called when texture is loaded
  83368. * @param onError defines a callback called if there is an error
  83369. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83370. * @param invertY defines if data must be stored with Y axis inverted
  83371. * @returns the cube texture as an InternalTexture
  83372. */
  83373. 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;
  83374. /**
  83375. * Creates a new raw 3D texture
  83376. * @param data defines the data used to create the texture
  83377. * @param width defines the width of the texture
  83378. * @param height defines the height of the texture
  83379. * @param depth defines the depth of the texture
  83380. * @param format defines the format of the texture
  83381. * @param generateMipMaps defines if the engine must generate mip levels
  83382. * @param invertY defines if data must be stored with Y axis inverted
  83383. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83384. * @param compression defines the compressed used (can be null)
  83385. * @param textureType defines the compressed used (can be null)
  83386. * @returns a new raw 3D texture (stored in an InternalTexture)
  83387. */
  83388. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83389. /**
  83390. * Update a raw 3D texture
  83391. * @param texture defines the texture to update
  83392. * @param data defines the data to store
  83393. * @param format defines the data format
  83394. * @param invertY defines if data must be stored with Y axis inverted
  83395. */
  83396. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83397. /**
  83398. * Update a raw 3D texture
  83399. * @param texture defines the texture to update
  83400. * @param data defines the data to store
  83401. * @param format defines the data format
  83402. * @param invertY defines if data must be stored with Y axis inverted
  83403. * @param compression defines the used compression (can be null)
  83404. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83405. */
  83406. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83407. /**
  83408. * Creates a new raw 2D array texture
  83409. * @param data defines the data used to create the texture
  83410. * @param width defines the width of the texture
  83411. * @param height defines the height of the texture
  83412. * @param depth defines the number of layers of the texture
  83413. * @param format defines the format of the texture
  83414. * @param generateMipMaps defines if the engine must generate mip levels
  83415. * @param invertY defines if data must be stored with Y axis inverted
  83416. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83417. * @param compression defines the compressed used (can be null)
  83418. * @param textureType defines the compressed used (can be null)
  83419. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83420. */
  83421. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83422. /**
  83423. * Update a raw 2D array texture
  83424. * @param texture defines the texture to update
  83425. * @param data defines the data to store
  83426. * @param format defines the data format
  83427. * @param invertY defines if data must be stored with Y axis inverted
  83428. */
  83429. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83430. /**
  83431. * Update a raw 2D array texture
  83432. * @param texture defines the texture to update
  83433. * @param data defines the data to store
  83434. * @param format defines the data format
  83435. * @param invertY defines if data must be stored with Y axis inverted
  83436. * @param compression defines the used compression (can be null)
  83437. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83438. */
  83439. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83440. }
  83441. }
  83442. declare module BABYLON {
  83443. /**
  83444. * Raw texture can help creating a texture directly from an array of data.
  83445. * This can be super useful if you either get the data from an uncompressed source or
  83446. * if you wish to create your texture pixel by pixel.
  83447. */
  83448. export class RawTexture extends Texture {
  83449. /**
  83450. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83451. */
  83452. format: number;
  83453. private _engine;
  83454. /**
  83455. * Instantiates a new RawTexture.
  83456. * Raw texture can help creating a texture directly from an array of data.
  83457. * This can be super useful if you either get the data from an uncompressed source or
  83458. * if you wish to create your texture pixel by pixel.
  83459. * @param data define the array of data to use to create the texture
  83460. * @param width define the width of the texture
  83461. * @param height define the height of the texture
  83462. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83463. * @param scene define the scene the texture belongs to
  83464. * @param generateMipMaps define whether mip maps should be generated or not
  83465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83468. */
  83469. constructor(data: ArrayBufferView, width: number, height: number,
  83470. /**
  83471. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83472. */
  83473. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83474. /**
  83475. * Updates the texture underlying data.
  83476. * @param data Define the new data of the texture
  83477. */
  83478. update(data: ArrayBufferView): void;
  83479. /**
  83480. * Creates a luminance texture from some data.
  83481. * @param data Define the texture data
  83482. * @param width Define the width of the texture
  83483. * @param height Define the height of the texture
  83484. * @param scene Define the scene the texture belongs to
  83485. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83488. * @returns the luminance texture
  83489. */
  83490. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83491. /**
  83492. * Creates a luminance alpha texture from some data.
  83493. * @param data Define the texture data
  83494. * @param width Define the width of the texture
  83495. * @param height Define the height of the texture
  83496. * @param scene Define the scene the texture belongs to
  83497. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83498. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83499. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83500. * @returns the luminance alpha texture
  83501. */
  83502. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83503. /**
  83504. * Creates an alpha texture from some data.
  83505. * @param data Define the texture data
  83506. * @param width Define the width of the texture
  83507. * @param height Define the height of the texture
  83508. * @param scene Define the scene the texture belongs to
  83509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83512. * @returns the alpha texture
  83513. */
  83514. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83515. /**
  83516. * Creates a RGB texture from some data.
  83517. * @param data Define the texture data
  83518. * @param width Define the width of the texture
  83519. * @param height Define the height of the texture
  83520. * @param scene Define the scene the texture belongs to
  83521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83525. * @returns the RGB alpha texture
  83526. */
  83527. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83528. /**
  83529. * Creates a RGBA texture from some data.
  83530. * @param data Define the texture data
  83531. * @param width Define the width of the texture
  83532. * @param height Define the height of the texture
  83533. * @param scene Define the scene the texture belongs to
  83534. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83535. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83536. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83537. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83538. * @returns the RGBA texture
  83539. */
  83540. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83541. /**
  83542. * Creates a R texture from some data.
  83543. * @param data Define the texture data
  83544. * @param width Define the width of the texture
  83545. * @param height Define the height of the texture
  83546. * @param scene Define the scene the texture belongs to
  83547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83550. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83551. * @returns the R texture
  83552. */
  83553. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83554. }
  83555. }
  83556. declare module BABYLON {
  83557. /**
  83558. * Interface for the size containing width and height
  83559. */
  83560. export interface ISize {
  83561. /**
  83562. * Width
  83563. */
  83564. width: number;
  83565. /**
  83566. * Heighht
  83567. */
  83568. height: number;
  83569. }
  83570. /**
  83571. * Size containing widht and height
  83572. */
  83573. export class Size implements ISize {
  83574. /**
  83575. * Width
  83576. */
  83577. width: number;
  83578. /**
  83579. * Height
  83580. */
  83581. height: number;
  83582. /**
  83583. * Creates a Size object from the given width and height (floats).
  83584. * @param width width of the new size
  83585. * @param height height of the new size
  83586. */
  83587. constructor(width: number, height: number);
  83588. /**
  83589. * Returns a string with the Size width and height
  83590. * @returns a string with the Size width and height
  83591. */
  83592. toString(): string;
  83593. /**
  83594. * "Size"
  83595. * @returns the string "Size"
  83596. */
  83597. getClassName(): string;
  83598. /**
  83599. * Returns the Size hash code.
  83600. * @returns a hash code for a unique width and height
  83601. */
  83602. getHashCode(): number;
  83603. /**
  83604. * Updates the current size from the given one.
  83605. * @param src the given size
  83606. */
  83607. copyFrom(src: Size): void;
  83608. /**
  83609. * Updates in place the current Size from the given floats.
  83610. * @param width width of the new size
  83611. * @param height height of the new size
  83612. * @returns the updated Size.
  83613. */
  83614. copyFromFloats(width: number, height: number): Size;
  83615. /**
  83616. * Updates in place the current Size from the given floats.
  83617. * @param width width to set
  83618. * @param height height to set
  83619. * @returns the updated Size.
  83620. */
  83621. set(width: number, height: number): Size;
  83622. /**
  83623. * Multiplies the width and height by numbers
  83624. * @param w factor to multiple the width by
  83625. * @param h factor to multiple the height by
  83626. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83627. */
  83628. multiplyByFloats(w: number, h: number): Size;
  83629. /**
  83630. * Clones the size
  83631. * @returns a new Size copied from the given one.
  83632. */
  83633. clone(): Size;
  83634. /**
  83635. * True if the current Size and the given one width and height are strictly equal.
  83636. * @param other the other size to compare against
  83637. * @returns True if the current Size and the given one width and height are strictly equal.
  83638. */
  83639. equals(other: Size): boolean;
  83640. /**
  83641. * The surface of the Size : width * height (float).
  83642. */
  83643. get surface(): number;
  83644. /**
  83645. * Create a new size of zero
  83646. * @returns a new Size set to (0.0, 0.0)
  83647. */
  83648. static Zero(): Size;
  83649. /**
  83650. * Sums the width and height of two sizes
  83651. * @param otherSize size to add to this size
  83652. * @returns a new Size set as the addition result of the current Size and the given one.
  83653. */
  83654. add(otherSize: Size): Size;
  83655. /**
  83656. * Subtracts the width and height of two
  83657. * @param otherSize size to subtract to this size
  83658. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83659. */
  83660. subtract(otherSize: Size): Size;
  83661. /**
  83662. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83663. * @param start starting size to lerp between
  83664. * @param end end size to lerp between
  83665. * @param amount amount to lerp between the start and end values
  83666. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83667. */
  83668. static Lerp(start: Size, end: Size, amount: number): Size;
  83669. }
  83670. }
  83671. declare module BABYLON {
  83672. /**
  83673. * Defines a runtime animation
  83674. */
  83675. export class RuntimeAnimation {
  83676. private _events;
  83677. /**
  83678. * The current frame of the runtime animation
  83679. */
  83680. private _currentFrame;
  83681. /**
  83682. * The animation used by the runtime animation
  83683. */
  83684. private _animation;
  83685. /**
  83686. * The target of the runtime animation
  83687. */
  83688. private _target;
  83689. /**
  83690. * The initiating animatable
  83691. */
  83692. private _host;
  83693. /**
  83694. * The original value of the runtime animation
  83695. */
  83696. private _originalValue;
  83697. /**
  83698. * The original blend value of the runtime animation
  83699. */
  83700. private _originalBlendValue;
  83701. /**
  83702. * The offsets cache of the runtime animation
  83703. */
  83704. private _offsetsCache;
  83705. /**
  83706. * The high limits cache of the runtime animation
  83707. */
  83708. private _highLimitsCache;
  83709. /**
  83710. * Specifies if the runtime animation has been stopped
  83711. */
  83712. private _stopped;
  83713. /**
  83714. * The blending factor of the runtime animation
  83715. */
  83716. private _blendingFactor;
  83717. /**
  83718. * The BabylonJS scene
  83719. */
  83720. private _scene;
  83721. /**
  83722. * The current value of the runtime animation
  83723. */
  83724. private _currentValue;
  83725. /** @hidden */
  83726. _animationState: _IAnimationState;
  83727. /**
  83728. * The active target of the runtime animation
  83729. */
  83730. private _activeTargets;
  83731. private _currentActiveTarget;
  83732. private _directTarget;
  83733. /**
  83734. * The target path of the runtime animation
  83735. */
  83736. private _targetPath;
  83737. /**
  83738. * The weight of the runtime animation
  83739. */
  83740. private _weight;
  83741. /**
  83742. * The ratio offset of the runtime animation
  83743. */
  83744. private _ratioOffset;
  83745. /**
  83746. * The previous delay of the runtime animation
  83747. */
  83748. private _previousDelay;
  83749. /**
  83750. * The previous ratio of the runtime animation
  83751. */
  83752. private _previousRatio;
  83753. private _enableBlending;
  83754. private _keys;
  83755. private _minFrame;
  83756. private _maxFrame;
  83757. private _minValue;
  83758. private _maxValue;
  83759. private _targetIsArray;
  83760. /**
  83761. * Gets the current frame of the runtime animation
  83762. */
  83763. get currentFrame(): number;
  83764. /**
  83765. * Gets the weight of the runtime animation
  83766. */
  83767. get weight(): number;
  83768. /**
  83769. * Gets the current value of the runtime animation
  83770. */
  83771. get currentValue(): any;
  83772. /**
  83773. * Gets the target path of the runtime animation
  83774. */
  83775. get targetPath(): string;
  83776. /**
  83777. * Gets the actual target of the runtime animation
  83778. */
  83779. get target(): any;
  83780. /** @hidden */
  83781. _onLoop: () => void;
  83782. /**
  83783. * Create a new RuntimeAnimation object
  83784. * @param target defines the target of the animation
  83785. * @param animation defines the source animation object
  83786. * @param scene defines the hosting scene
  83787. * @param host defines the initiating Animatable
  83788. */
  83789. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83790. private _preparePath;
  83791. /**
  83792. * Gets the animation from the runtime animation
  83793. */
  83794. get animation(): Animation;
  83795. /**
  83796. * Resets the runtime animation to the beginning
  83797. * @param restoreOriginal defines whether to restore the target property to the original value
  83798. */
  83799. reset(restoreOriginal?: boolean): void;
  83800. /**
  83801. * Specifies if the runtime animation is stopped
  83802. * @returns Boolean specifying if the runtime animation is stopped
  83803. */
  83804. isStopped(): boolean;
  83805. /**
  83806. * Disposes of the runtime animation
  83807. */
  83808. dispose(): void;
  83809. /**
  83810. * Apply the interpolated value to the target
  83811. * @param currentValue defines the value computed by the animation
  83812. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83813. */
  83814. setValue(currentValue: any, weight: number): void;
  83815. private _getOriginalValues;
  83816. private _setValue;
  83817. /**
  83818. * Gets the loop pmode of the runtime animation
  83819. * @returns Loop Mode
  83820. */
  83821. private _getCorrectLoopMode;
  83822. /**
  83823. * Move the current animation to a given frame
  83824. * @param frame defines the frame to move to
  83825. */
  83826. goToFrame(frame: number): void;
  83827. /**
  83828. * @hidden Internal use only
  83829. */
  83830. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83831. /**
  83832. * Execute the current animation
  83833. * @param delay defines the delay to add to the current frame
  83834. * @param from defines the lower bound of the animation range
  83835. * @param to defines the upper bound of the animation range
  83836. * @param loop defines if the current animation must loop
  83837. * @param speedRatio defines the current speed ratio
  83838. * @param weight defines the weight of the animation (default is -1 so no weight)
  83839. * @param onLoop optional callback called when animation loops
  83840. * @returns a boolean indicating if the animation is running
  83841. */
  83842. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83843. }
  83844. }
  83845. declare module BABYLON {
  83846. /**
  83847. * Class used to store an actual running animation
  83848. */
  83849. export class Animatable {
  83850. /** defines the target object */
  83851. target: any;
  83852. /** defines the starting frame number (default is 0) */
  83853. fromFrame: number;
  83854. /** defines the ending frame number (default is 100) */
  83855. toFrame: number;
  83856. /** defines if the animation must loop (default is false) */
  83857. loopAnimation: boolean;
  83858. /** defines a callback to call when animation ends if it is not looping */
  83859. onAnimationEnd?: (() => void) | null | undefined;
  83860. /** defines a callback to call when animation loops */
  83861. onAnimationLoop?: (() => void) | null | undefined;
  83862. private _localDelayOffset;
  83863. private _pausedDelay;
  83864. private _runtimeAnimations;
  83865. private _paused;
  83866. private _scene;
  83867. private _speedRatio;
  83868. private _weight;
  83869. private _syncRoot;
  83870. /**
  83871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83872. * This will only apply for non looping animation (default is true)
  83873. */
  83874. disposeOnEnd: boolean;
  83875. /**
  83876. * Gets a boolean indicating if the animation has started
  83877. */
  83878. animationStarted: boolean;
  83879. /**
  83880. * Observer raised when the animation ends
  83881. */
  83882. onAnimationEndObservable: Observable<Animatable>;
  83883. /**
  83884. * Observer raised when the animation loops
  83885. */
  83886. onAnimationLoopObservable: Observable<Animatable>;
  83887. /**
  83888. * Gets the root Animatable used to synchronize and normalize animations
  83889. */
  83890. get syncRoot(): Nullable<Animatable>;
  83891. /**
  83892. * Gets the current frame of the first RuntimeAnimation
  83893. * Used to synchronize Animatables
  83894. */
  83895. get masterFrame(): number;
  83896. /**
  83897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83898. */
  83899. get weight(): number;
  83900. set weight(value: number);
  83901. /**
  83902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83903. */
  83904. get speedRatio(): number;
  83905. set speedRatio(value: number);
  83906. /**
  83907. * Creates a new Animatable
  83908. * @param scene defines the hosting scene
  83909. * @param target defines the target object
  83910. * @param fromFrame defines the starting frame number (default is 0)
  83911. * @param toFrame defines the ending frame number (default is 100)
  83912. * @param loopAnimation defines if the animation must loop (default is false)
  83913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83915. * @param animations defines a group of animation to add to the new Animatable
  83916. * @param onAnimationLoop defines a callback to call when animation loops
  83917. */
  83918. constructor(scene: Scene,
  83919. /** defines the target object */
  83920. target: any,
  83921. /** defines the starting frame number (default is 0) */
  83922. fromFrame?: number,
  83923. /** defines the ending frame number (default is 100) */
  83924. toFrame?: number,
  83925. /** defines if the animation must loop (default is false) */
  83926. loopAnimation?: boolean, speedRatio?: number,
  83927. /** defines a callback to call when animation ends if it is not looping */
  83928. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83929. /** defines a callback to call when animation loops */
  83930. onAnimationLoop?: (() => void) | null | undefined);
  83931. /**
  83932. * Synchronize and normalize current Animatable with a source Animatable
  83933. * This is useful when using animation weights and when animations are not of the same length
  83934. * @param root defines the root Animatable to synchronize with
  83935. * @returns the current Animatable
  83936. */
  83937. syncWith(root: Animatable): Animatable;
  83938. /**
  83939. * Gets the list of runtime animations
  83940. * @returns an array of RuntimeAnimation
  83941. */
  83942. getAnimations(): RuntimeAnimation[];
  83943. /**
  83944. * Adds more animations to the current animatable
  83945. * @param target defines the target of the animations
  83946. * @param animations defines the new animations to add
  83947. */
  83948. appendAnimations(target: any, animations: Animation[]): void;
  83949. /**
  83950. * Gets the source animation for a specific property
  83951. * @param property defines the propertyu to look for
  83952. * @returns null or the source animation for the given property
  83953. */
  83954. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83955. /**
  83956. * Gets the runtime animation for a specific property
  83957. * @param property defines the propertyu to look for
  83958. * @returns null or the runtime animation for the given property
  83959. */
  83960. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83961. /**
  83962. * Resets the animatable to its original state
  83963. */
  83964. reset(): void;
  83965. /**
  83966. * Allows the animatable to blend with current running animations
  83967. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83968. * @param blendingSpeed defines the blending speed to use
  83969. */
  83970. enableBlending(blendingSpeed: number): void;
  83971. /**
  83972. * Disable animation blending
  83973. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83974. */
  83975. disableBlending(): void;
  83976. /**
  83977. * Jump directly to a given frame
  83978. * @param frame defines the frame to jump to
  83979. */
  83980. goToFrame(frame: number): void;
  83981. /**
  83982. * Pause the animation
  83983. */
  83984. pause(): void;
  83985. /**
  83986. * Restart the animation
  83987. */
  83988. restart(): void;
  83989. private _raiseOnAnimationEnd;
  83990. /**
  83991. * Stop and delete the current animation
  83992. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83993. * @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)
  83994. */
  83995. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83996. /**
  83997. * Wait asynchronously for the animation to end
  83998. * @returns a promise which will be fullfilled when the animation ends
  83999. */
  84000. waitAsync(): Promise<Animatable>;
  84001. /** @hidden */
  84002. _animate(delay: number): boolean;
  84003. }
  84004. interface Scene {
  84005. /** @hidden */
  84006. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  84007. /** @hidden */
  84008. _processLateAnimationBindingsForMatrices(holder: {
  84009. totalWeight: number;
  84010. animations: RuntimeAnimation[];
  84011. originalValue: Matrix;
  84012. }): any;
  84013. /** @hidden */
  84014. _processLateAnimationBindingsForQuaternions(holder: {
  84015. totalWeight: number;
  84016. animations: RuntimeAnimation[];
  84017. originalValue: Quaternion;
  84018. }, refQuaternion: Quaternion): Quaternion;
  84019. /** @hidden */
  84020. _processLateAnimationBindings(): void;
  84021. /**
  84022. * Will start the animation sequence of a given target
  84023. * @param target defines the target
  84024. * @param from defines from which frame should animation start
  84025. * @param to defines until which frame should animation run.
  84026. * @param weight defines the weight to apply to the animation (1.0 by default)
  84027. * @param loop defines if the animation loops
  84028. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84029. * @param onAnimationEnd defines the function to be executed when the animation ends
  84030. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84031. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84032. * @param onAnimationLoop defines the callback to call when an animation loops
  84033. * @returns the animatable object created for this animation
  84034. */
  84035. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84036. /**
  84037. * Will start the animation sequence of a given target
  84038. * @param target defines the target
  84039. * @param from defines from which frame should animation start
  84040. * @param to defines until which frame should animation run.
  84041. * @param loop defines if the animation loops
  84042. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84043. * @param onAnimationEnd defines the function to be executed when the animation ends
  84044. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84045. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84046. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  84047. * @param onAnimationLoop defines the callback to call when an animation loops
  84048. * @returns the animatable object created for this animation
  84049. */
  84050. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84051. /**
  84052. * Will start the animation sequence of a given target and its hierarchy
  84053. * @param target defines the target
  84054. * @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.
  84055. * @param from defines from which frame should animation start
  84056. * @param to defines until which frame should animation run.
  84057. * @param loop defines if the animation loops
  84058. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84059. * @param onAnimationEnd defines the function to be executed when the animation ends
  84060. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84061. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84062. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84063. * @param onAnimationLoop defines the callback to call when an animation loops
  84064. * @returns the list of created animatables
  84065. */
  84066. 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[];
  84067. /**
  84068. * Begin a new animation on a given node
  84069. * @param target defines the target where the animation will take place
  84070. * @param animations defines the list of animations to start
  84071. * @param from defines the initial value
  84072. * @param to defines the final value
  84073. * @param loop defines if you want animation to loop (off by default)
  84074. * @param speedRatio defines the speed ratio to apply to all animations
  84075. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84076. * @param onAnimationLoop defines the callback to call when an animation loops
  84077. * @returns the list of created animatables
  84078. */
  84079. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84080. /**
  84081. * Begin a new animation on a given node and its hierarchy
  84082. * @param target defines the root node where the animation will take place
  84083. * @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.
  84084. * @param animations defines the list of animations to start
  84085. * @param from defines the initial value
  84086. * @param to defines the final value
  84087. * @param loop defines if you want animation to loop (off by default)
  84088. * @param speedRatio defines the speed ratio to apply to all animations
  84089. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84090. * @param onAnimationLoop defines the callback to call when an animation loops
  84091. * @returns the list of animatables created for all nodes
  84092. */
  84093. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84094. /**
  84095. * Gets the animatable associated with a specific target
  84096. * @param target defines the target of the animatable
  84097. * @returns the required animatable if found
  84098. */
  84099. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84100. /**
  84101. * Gets all animatables associated with a given target
  84102. * @param target defines the target to look animatables for
  84103. * @returns an array of Animatables
  84104. */
  84105. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84106. /**
  84107. * Stops and removes all animations that have been applied to the scene
  84108. */
  84109. stopAllAnimations(): void;
  84110. /**
  84111. * Gets the current delta time used by animation engine
  84112. */
  84113. deltaTime: number;
  84114. }
  84115. interface Bone {
  84116. /**
  84117. * Copy an animation range from another bone
  84118. * @param source defines the source bone
  84119. * @param rangeName defines the range name to copy
  84120. * @param frameOffset defines the frame offset
  84121. * @param rescaleAsRequired defines if rescaling must be applied if required
  84122. * @param skelDimensionsRatio defines the scaling ratio
  84123. * @returns true if operation was successful
  84124. */
  84125. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84126. }
  84127. }
  84128. declare module BABYLON {
  84129. /**
  84130. * Class used to override all child animations of a given target
  84131. */
  84132. export class AnimationPropertiesOverride {
  84133. /**
  84134. * Gets or sets a value indicating if animation blending must be used
  84135. */
  84136. enableBlending: boolean;
  84137. /**
  84138. * Gets or sets the blending speed to use when enableBlending is true
  84139. */
  84140. blendingSpeed: number;
  84141. /**
  84142. * Gets or sets the default loop mode to use
  84143. */
  84144. loopMode: number;
  84145. }
  84146. }
  84147. declare module BABYLON {
  84148. /**
  84149. * Class used to handle skinning animations
  84150. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84151. */
  84152. export class Skeleton implements IAnimatable {
  84153. /** defines the skeleton name */
  84154. name: string;
  84155. /** defines the skeleton Id */
  84156. id: string;
  84157. /**
  84158. * Defines the list of child bones
  84159. */
  84160. bones: Bone[];
  84161. /**
  84162. * Defines an estimate of the dimension of the skeleton at rest
  84163. */
  84164. dimensionsAtRest: Vector3;
  84165. /**
  84166. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84167. */
  84168. needInitialSkinMatrix: boolean;
  84169. /**
  84170. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84171. */
  84172. overrideMesh: Nullable<AbstractMesh>;
  84173. /**
  84174. * Gets the list of animations attached to this skeleton
  84175. */
  84176. animations: Array<Animation>;
  84177. private _scene;
  84178. private _isDirty;
  84179. private _transformMatrices;
  84180. private _transformMatrixTexture;
  84181. private _meshesWithPoseMatrix;
  84182. private _animatables;
  84183. private _identity;
  84184. private _synchronizedWithMesh;
  84185. private _ranges;
  84186. private _lastAbsoluteTransformsUpdateId;
  84187. private _canUseTextureForBones;
  84188. private _uniqueId;
  84189. /** @hidden */
  84190. _numBonesWithLinkedTransformNode: number;
  84191. /** @hidden */
  84192. _hasWaitingData: Nullable<boolean>;
  84193. /**
  84194. * Specifies if the skeleton should be serialized
  84195. */
  84196. doNotSerialize: boolean;
  84197. private _useTextureToStoreBoneMatrices;
  84198. /**
  84199. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84200. * Please note that this option is not available if the hardware does not support it
  84201. */
  84202. get useTextureToStoreBoneMatrices(): boolean;
  84203. set useTextureToStoreBoneMatrices(value: boolean);
  84204. private _animationPropertiesOverride;
  84205. /**
  84206. * Gets or sets the animation properties override
  84207. */
  84208. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84209. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84210. /**
  84211. * List of inspectable custom properties (used by the Inspector)
  84212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84213. */
  84214. inspectableCustomProperties: IInspectable[];
  84215. /**
  84216. * An observable triggered before computing the skeleton's matrices
  84217. */
  84218. onBeforeComputeObservable: Observable<Skeleton>;
  84219. /**
  84220. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84221. */
  84222. get isUsingTextureForMatrices(): boolean;
  84223. /**
  84224. * Gets the unique ID of this skeleton
  84225. */
  84226. get uniqueId(): number;
  84227. /**
  84228. * Creates a new skeleton
  84229. * @param name defines the skeleton name
  84230. * @param id defines the skeleton Id
  84231. * @param scene defines the hosting scene
  84232. */
  84233. constructor(
  84234. /** defines the skeleton name */
  84235. name: string,
  84236. /** defines the skeleton Id */
  84237. id: string, scene: Scene);
  84238. /**
  84239. * Gets the current object class name.
  84240. * @return the class name
  84241. */
  84242. getClassName(): string;
  84243. /**
  84244. * Returns an array containing the root bones
  84245. * @returns an array containing the root bones
  84246. */
  84247. getChildren(): Array<Bone>;
  84248. /**
  84249. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84250. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84251. * @returns a Float32Array containing matrices data
  84252. */
  84253. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84254. /**
  84255. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84256. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84257. * @returns a raw texture containing the data
  84258. */
  84259. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84260. /**
  84261. * Gets the current hosting scene
  84262. * @returns a scene object
  84263. */
  84264. getScene(): Scene;
  84265. /**
  84266. * Gets a string representing the current skeleton data
  84267. * @param fullDetails defines a boolean indicating if we want a verbose version
  84268. * @returns a string representing the current skeleton data
  84269. */
  84270. toString(fullDetails?: boolean): string;
  84271. /**
  84272. * Get bone's index searching by name
  84273. * @param name defines bone's name to search for
  84274. * @return the indice of the bone. Returns -1 if not found
  84275. */
  84276. getBoneIndexByName(name: string): number;
  84277. /**
  84278. * Creater a new animation range
  84279. * @param name defines the name of the range
  84280. * @param from defines the start key
  84281. * @param to defines the end key
  84282. */
  84283. createAnimationRange(name: string, from: number, to: number): void;
  84284. /**
  84285. * Delete a specific animation range
  84286. * @param name defines the name of the range
  84287. * @param deleteFrames defines if frames must be removed as well
  84288. */
  84289. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84290. /**
  84291. * Gets a specific animation range
  84292. * @param name defines the name of the range to look for
  84293. * @returns the requested animation range or null if not found
  84294. */
  84295. getAnimationRange(name: string): Nullable<AnimationRange>;
  84296. /**
  84297. * Gets the list of all animation ranges defined on this skeleton
  84298. * @returns an array
  84299. */
  84300. getAnimationRanges(): Nullable<AnimationRange>[];
  84301. /**
  84302. * Copy animation range from a source skeleton.
  84303. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84304. * @param source defines the source skeleton
  84305. * @param name defines the name of the range to copy
  84306. * @param rescaleAsRequired defines if rescaling must be applied if required
  84307. * @returns true if operation was successful
  84308. */
  84309. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84310. /**
  84311. * Forces the skeleton to go to rest pose
  84312. */
  84313. returnToRest(): void;
  84314. private _getHighestAnimationFrame;
  84315. /**
  84316. * Begin a specific animation range
  84317. * @param name defines the name of the range to start
  84318. * @param loop defines if looping must be turned on (false by default)
  84319. * @param speedRatio defines the speed ratio to apply (1 by default)
  84320. * @param onAnimationEnd defines a callback which will be called when animation will end
  84321. * @returns a new animatable
  84322. */
  84323. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84324. /** @hidden */
  84325. _markAsDirty(): void;
  84326. /** @hidden */
  84327. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84328. /** @hidden */
  84329. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84330. private _computeTransformMatrices;
  84331. /**
  84332. * Build all resources required to render a skeleton
  84333. */
  84334. prepare(): void;
  84335. /**
  84336. * Gets the list of animatables currently running for this skeleton
  84337. * @returns an array of animatables
  84338. */
  84339. getAnimatables(): IAnimatable[];
  84340. /**
  84341. * Clone the current skeleton
  84342. * @param name defines the name of the new skeleton
  84343. * @param id defines the id of the new skeleton
  84344. * @returns the new skeleton
  84345. */
  84346. clone(name: string, id?: string): Skeleton;
  84347. /**
  84348. * Enable animation blending for this skeleton
  84349. * @param blendingSpeed defines the blending speed to apply
  84350. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84351. */
  84352. enableBlending(blendingSpeed?: number): void;
  84353. /**
  84354. * Releases all resources associated with the current skeleton
  84355. */
  84356. dispose(): void;
  84357. /**
  84358. * Serialize the skeleton in a JSON object
  84359. * @returns a JSON object
  84360. */
  84361. serialize(): any;
  84362. /**
  84363. * Creates a new skeleton from serialized data
  84364. * @param parsedSkeleton defines the serialized data
  84365. * @param scene defines the hosting scene
  84366. * @returns a new skeleton
  84367. */
  84368. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84369. /**
  84370. * Compute all node absolute transforms
  84371. * @param forceUpdate defines if computation must be done even if cache is up to date
  84372. */
  84373. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84374. /**
  84375. * Gets the root pose matrix
  84376. * @returns a matrix
  84377. */
  84378. getPoseMatrix(): Nullable<Matrix>;
  84379. /**
  84380. * Sorts bones per internal index
  84381. */
  84382. sortBones(): void;
  84383. private _sortBones;
  84384. }
  84385. }
  84386. declare module BABYLON {
  84387. /**
  84388. * Class used to store bone information
  84389. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84390. */
  84391. export class Bone extends Node {
  84392. /**
  84393. * defines the bone name
  84394. */
  84395. name: string;
  84396. private static _tmpVecs;
  84397. private static _tmpQuat;
  84398. private static _tmpMats;
  84399. /**
  84400. * Gets the list of child bones
  84401. */
  84402. children: Bone[];
  84403. /** Gets the animations associated with this bone */
  84404. animations: Animation[];
  84405. /**
  84406. * Gets or sets bone length
  84407. */
  84408. length: number;
  84409. /**
  84410. * @hidden Internal only
  84411. * Set this value to map this bone to a different index in the transform matrices
  84412. * Set this value to -1 to exclude the bone from the transform matrices
  84413. */
  84414. _index: Nullable<number>;
  84415. private _skeleton;
  84416. private _localMatrix;
  84417. private _restPose;
  84418. private _baseMatrix;
  84419. private _absoluteTransform;
  84420. private _invertedAbsoluteTransform;
  84421. private _parent;
  84422. private _scalingDeterminant;
  84423. private _worldTransform;
  84424. private _localScaling;
  84425. private _localRotation;
  84426. private _localPosition;
  84427. private _needToDecompose;
  84428. private _needToCompose;
  84429. /** @hidden */
  84430. _linkedTransformNode: Nullable<TransformNode>;
  84431. /** @hidden */
  84432. _waitingTransformNodeId: Nullable<string>;
  84433. /** @hidden */
  84434. get _matrix(): Matrix;
  84435. /** @hidden */
  84436. set _matrix(value: Matrix);
  84437. /**
  84438. * Create a new bone
  84439. * @param name defines the bone name
  84440. * @param skeleton defines the parent skeleton
  84441. * @param parentBone defines the parent (can be null if the bone is the root)
  84442. * @param localMatrix defines the local matrix
  84443. * @param restPose defines the rest pose matrix
  84444. * @param baseMatrix defines the base matrix
  84445. * @param index defines index of the bone in the hiearchy
  84446. */
  84447. constructor(
  84448. /**
  84449. * defines the bone name
  84450. */
  84451. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84452. /**
  84453. * Gets the current object class name.
  84454. * @return the class name
  84455. */
  84456. getClassName(): string;
  84457. /**
  84458. * Gets the parent skeleton
  84459. * @returns a skeleton
  84460. */
  84461. getSkeleton(): Skeleton;
  84462. /**
  84463. * Gets parent bone
  84464. * @returns a bone or null if the bone is the root of the bone hierarchy
  84465. */
  84466. getParent(): Nullable<Bone>;
  84467. /**
  84468. * Returns an array containing the root bones
  84469. * @returns an array containing the root bones
  84470. */
  84471. getChildren(): Array<Bone>;
  84472. /**
  84473. * Gets the node index in matrix array generated for rendering
  84474. * @returns the node index
  84475. */
  84476. getIndex(): number;
  84477. /**
  84478. * Sets the parent bone
  84479. * @param parent defines the parent (can be null if the bone is the root)
  84480. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84481. */
  84482. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84483. /**
  84484. * Gets the local matrix
  84485. * @returns a matrix
  84486. */
  84487. getLocalMatrix(): Matrix;
  84488. /**
  84489. * Gets the base matrix (initial matrix which remains unchanged)
  84490. * @returns a matrix
  84491. */
  84492. getBaseMatrix(): Matrix;
  84493. /**
  84494. * Gets the rest pose matrix
  84495. * @returns a matrix
  84496. */
  84497. getRestPose(): Matrix;
  84498. /**
  84499. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84500. */
  84501. getWorldMatrix(): Matrix;
  84502. /**
  84503. * Sets the local matrix to rest pose matrix
  84504. */
  84505. returnToRest(): void;
  84506. /**
  84507. * Gets the inverse of the absolute transform matrix.
  84508. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84509. * @returns a matrix
  84510. */
  84511. getInvertedAbsoluteTransform(): Matrix;
  84512. /**
  84513. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84514. * @returns a matrix
  84515. */
  84516. getAbsoluteTransform(): Matrix;
  84517. /**
  84518. * Links with the given transform node.
  84519. * The local matrix of this bone is copied from the transform node every frame.
  84520. * @param transformNode defines the transform node to link to
  84521. */
  84522. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84523. /**
  84524. * Gets the node used to drive the bone's transformation
  84525. * @returns a transform node or null
  84526. */
  84527. getTransformNode(): Nullable<TransformNode>;
  84528. /** Gets or sets current position (in local space) */
  84529. get position(): Vector3;
  84530. set position(newPosition: Vector3);
  84531. /** Gets or sets current rotation (in local space) */
  84532. get rotation(): Vector3;
  84533. set rotation(newRotation: Vector3);
  84534. /** Gets or sets current rotation quaternion (in local space) */
  84535. get rotationQuaternion(): Quaternion;
  84536. set rotationQuaternion(newRotation: Quaternion);
  84537. /** Gets or sets current scaling (in local space) */
  84538. get scaling(): Vector3;
  84539. set scaling(newScaling: Vector3);
  84540. /**
  84541. * Gets the animation properties override
  84542. */
  84543. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84544. private _decompose;
  84545. private _compose;
  84546. /**
  84547. * Update the base and local matrices
  84548. * @param matrix defines the new base or local matrix
  84549. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84550. * @param updateLocalMatrix defines if the local matrix should be updated
  84551. */
  84552. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84553. /** @hidden */
  84554. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84555. /**
  84556. * Flag the bone as dirty (Forcing it to update everything)
  84557. */
  84558. markAsDirty(): void;
  84559. /** @hidden */
  84560. _markAsDirtyAndCompose(): void;
  84561. private _markAsDirtyAndDecompose;
  84562. /**
  84563. * Translate the bone in local or world space
  84564. * @param vec The amount to translate the bone
  84565. * @param space The space that the translation is in
  84566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84567. */
  84568. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84569. /**
  84570. * Set the postion of the bone in local or world space
  84571. * @param position The position to set the bone
  84572. * @param space The space that the position is in
  84573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84574. */
  84575. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84576. /**
  84577. * Set the absolute position of the bone (world space)
  84578. * @param position The position to set the bone
  84579. * @param mesh The mesh that this bone is attached to
  84580. */
  84581. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84582. /**
  84583. * Scale the bone on the x, y and z axes (in local space)
  84584. * @param x The amount to scale the bone on the x axis
  84585. * @param y The amount to scale the bone on the y axis
  84586. * @param z The amount to scale the bone on the z axis
  84587. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84588. */
  84589. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84590. /**
  84591. * Set the bone scaling in local space
  84592. * @param scale defines the scaling vector
  84593. */
  84594. setScale(scale: Vector3): void;
  84595. /**
  84596. * Gets the current scaling in local space
  84597. * @returns the current scaling vector
  84598. */
  84599. getScale(): Vector3;
  84600. /**
  84601. * Gets the current scaling in local space and stores it in a target vector
  84602. * @param result defines the target vector
  84603. */
  84604. getScaleToRef(result: Vector3): void;
  84605. /**
  84606. * Set the yaw, pitch, and roll of the bone in local or world space
  84607. * @param yaw The rotation of the bone on the y axis
  84608. * @param pitch The rotation of the bone on the x axis
  84609. * @param roll The rotation of the bone on the z axis
  84610. * @param space The space that the axes of rotation are in
  84611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84612. */
  84613. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84614. /**
  84615. * Add a rotation to the bone on an axis in local or world space
  84616. * @param axis The axis to rotate the bone on
  84617. * @param amount The amount to rotate the bone
  84618. * @param space The space that the axis is in
  84619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84620. */
  84621. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84622. /**
  84623. * Set the rotation of the bone to a particular axis angle in local or world space
  84624. * @param axis The axis to rotate the bone on
  84625. * @param angle The angle that the bone should be rotated to
  84626. * @param space The space that the axis is in
  84627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84628. */
  84629. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84630. /**
  84631. * Set the euler rotation of the bone in local of world space
  84632. * @param rotation The euler rotation that the bone should be set to
  84633. * @param space The space that the rotation is in
  84634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84635. */
  84636. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84637. /**
  84638. * Set the quaternion rotation of the bone in local of world space
  84639. * @param quat The quaternion rotation that the bone should be set to
  84640. * @param space The space that the rotation is in
  84641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84642. */
  84643. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84644. /**
  84645. * Set the rotation matrix of the bone in local of world space
  84646. * @param rotMat The rotation matrix that the bone should be set to
  84647. * @param space The space that the rotation is in
  84648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84649. */
  84650. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84651. private _rotateWithMatrix;
  84652. private _getNegativeRotationToRef;
  84653. /**
  84654. * Get the position of the bone in local or world space
  84655. * @param space The space that the returned position is in
  84656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84657. * @returns The position of the bone
  84658. */
  84659. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84660. /**
  84661. * Copy the position of the bone to a vector3 in local or world space
  84662. * @param space The space that the returned position is in
  84663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84664. * @param result The vector3 to copy the position to
  84665. */
  84666. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84667. /**
  84668. * Get the absolute position of the bone (world space)
  84669. * @param mesh The mesh that this bone is attached to
  84670. * @returns The absolute position of the bone
  84671. */
  84672. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84673. /**
  84674. * Copy the absolute position of the bone (world space) to the result param
  84675. * @param mesh The mesh that this bone is attached to
  84676. * @param result The vector3 to copy the absolute position to
  84677. */
  84678. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84679. /**
  84680. * Compute the absolute transforms of this bone and its children
  84681. */
  84682. computeAbsoluteTransforms(): void;
  84683. /**
  84684. * Get the world direction from an axis that is in the local space of the bone
  84685. * @param localAxis The local direction that is used to compute the world direction
  84686. * @param mesh The mesh that this bone is attached to
  84687. * @returns The world direction
  84688. */
  84689. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84690. /**
  84691. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84692. * @param localAxis The local direction that is used to compute the world direction
  84693. * @param mesh The mesh that this bone is attached to
  84694. * @param result The vector3 that the world direction will be copied to
  84695. */
  84696. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84697. /**
  84698. * Get the euler rotation of the bone in local or world space
  84699. * @param space The space that the rotation should be in
  84700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84701. * @returns The euler rotation
  84702. */
  84703. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84704. /**
  84705. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84706. * @param space The space that the rotation should be in
  84707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84708. * @param result The vector3 that the rotation should be copied to
  84709. */
  84710. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84711. /**
  84712. * Get the quaternion rotation of the bone in either local or world space
  84713. * @param space The space that the rotation should be in
  84714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84715. * @returns The quaternion rotation
  84716. */
  84717. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84718. /**
  84719. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84720. * @param space The space that the rotation should be in
  84721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84722. * @param result The quaternion that the rotation should be copied to
  84723. */
  84724. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84725. /**
  84726. * Get the rotation matrix of the bone in local or world space
  84727. * @param space The space that the rotation should be in
  84728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84729. * @returns The rotation matrix
  84730. */
  84731. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84732. /**
  84733. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84734. * @param space The space that the rotation should be in
  84735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84736. * @param result The quaternion that the rotation should be copied to
  84737. */
  84738. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84739. /**
  84740. * Get the world position of a point that is in the local space of the bone
  84741. * @param position The local position
  84742. * @param mesh The mesh that this bone is attached to
  84743. * @returns The world position
  84744. */
  84745. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84746. /**
  84747. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84748. * @param position The local position
  84749. * @param mesh The mesh that this bone is attached to
  84750. * @param result The vector3 that the world position should be copied to
  84751. */
  84752. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84753. /**
  84754. * Get the local position of a point that is in world space
  84755. * @param position The world position
  84756. * @param mesh The mesh that this bone is attached to
  84757. * @returns The local position
  84758. */
  84759. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84760. /**
  84761. * Get the local position of a point that is in world space and copy it to the result param
  84762. * @param position The world position
  84763. * @param mesh The mesh that this bone is attached to
  84764. * @param result The vector3 that the local position should be copied to
  84765. */
  84766. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84767. }
  84768. }
  84769. declare module BABYLON {
  84770. /**
  84771. * 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.
  84772. * @see https://doc.babylonjs.com/how_to/transformnode
  84773. */
  84774. export class TransformNode extends Node {
  84775. /**
  84776. * Object will not rotate to face the camera
  84777. */
  84778. static BILLBOARDMODE_NONE: number;
  84779. /**
  84780. * Object will rotate to face the camera but only on the x axis
  84781. */
  84782. static BILLBOARDMODE_X: number;
  84783. /**
  84784. * Object will rotate to face the camera but only on the y axis
  84785. */
  84786. static BILLBOARDMODE_Y: number;
  84787. /**
  84788. * Object will rotate to face the camera but only on the z axis
  84789. */
  84790. static BILLBOARDMODE_Z: number;
  84791. /**
  84792. * Object will rotate to face the camera
  84793. */
  84794. static BILLBOARDMODE_ALL: number;
  84795. /**
  84796. * Object will rotate to face the camera's position instead of orientation
  84797. */
  84798. static BILLBOARDMODE_USE_POSITION: number;
  84799. private _forward;
  84800. private _forwardInverted;
  84801. private _up;
  84802. private _right;
  84803. private _rightInverted;
  84804. private _position;
  84805. private _rotation;
  84806. private _rotationQuaternion;
  84807. protected _scaling: Vector3;
  84808. protected _isDirty: boolean;
  84809. private _transformToBoneReferal;
  84810. private _isAbsoluteSynced;
  84811. private _billboardMode;
  84812. /**
  84813. * Gets or sets the billboard mode. Default is 0.
  84814. *
  84815. * | Value | Type | Description |
  84816. * | --- | --- | --- |
  84817. * | 0 | BILLBOARDMODE_NONE | |
  84818. * | 1 | BILLBOARDMODE_X | |
  84819. * | 2 | BILLBOARDMODE_Y | |
  84820. * | 4 | BILLBOARDMODE_Z | |
  84821. * | 7 | BILLBOARDMODE_ALL | |
  84822. *
  84823. */
  84824. get billboardMode(): number;
  84825. set billboardMode(value: number);
  84826. private _preserveParentRotationForBillboard;
  84827. /**
  84828. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84829. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84830. */
  84831. get preserveParentRotationForBillboard(): boolean;
  84832. set preserveParentRotationForBillboard(value: boolean);
  84833. /**
  84834. * 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
  84835. */
  84836. scalingDeterminant: number;
  84837. private _infiniteDistance;
  84838. /**
  84839. * Gets or sets the distance of the object to max, often used by skybox
  84840. */
  84841. get infiniteDistance(): boolean;
  84842. set infiniteDistance(value: boolean);
  84843. /**
  84844. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84845. * By default the system will update normals to compensate
  84846. */
  84847. ignoreNonUniformScaling: boolean;
  84848. /**
  84849. * 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
  84850. */
  84851. reIntegrateRotationIntoRotationQuaternion: boolean;
  84852. /** @hidden */
  84853. _poseMatrix: Nullable<Matrix>;
  84854. /** @hidden */
  84855. _localMatrix: Matrix;
  84856. private _usePivotMatrix;
  84857. private _absolutePosition;
  84858. private _absoluteScaling;
  84859. private _absoluteRotationQuaternion;
  84860. private _pivotMatrix;
  84861. private _pivotMatrixInverse;
  84862. protected _postMultiplyPivotMatrix: boolean;
  84863. protected _isWorldMatrixFrozen: boolean;
  84864. /** @hidden */
  84865. _indexInSceneTransformNodesArray: number;
  84866. /**
  84867. * An event triggered after the world matrix is updated
  84868. */
  84869. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84870. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84871. /**
  84872. * Gets a string identifying the name of the class
  84873. * @returns "TransformNode" string
  84874. */
  84875. getClassName(): string;
  84876. /**
  84877. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84878. */
  84879. get position(): Vector3;
  84880. set position(newPosition: Vector3);
  84881. /**
  84882. * 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)).
  84883. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84884. */
  84885. get rotation(): Vector3;
  84886. set rotation(newRotation: Vector3);
  84887. /**
  84888. * 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)).
  84889. */
  84890. get scaling(): Vector3;
  84891. set scaling(newScaling: Vector3);
  84892. /**
  84893. * 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).
  84894. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84895. */
  84896. get rotationQuaternion(): Nullable<Quaternion>;
  84897. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84898. /**
  84899. * The forward direction of that transform in world space.
  84900. */
  84901. get forward(): Vector3;
  84902. /**
  84903. * The up direction of that transform in world space.
  84904. */
  84905. get up(): Vector3;
  84906. /**
  84907. * The right direction of that transform in world space.
  84908. */
  84909. get right(): Vector3;
  84910. /**
  84911. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84912. * @param matrix the matrix to copy the pose from
  84913. * @returns this TransformNode.
  84914. */
  84915. updatePoseMatrix(matrix: Matrix): TransformNode;
  84916. /**
  84917. * Returns the mesh Pose matrix.
  84918. * @returns the pose matrix
  84919. */
  84920. getPoseMatrix(): Matrix;
  84921. /** @hidden */
  84922. _isSynchronized(): boolean;
  84923. /** @hidden */
  84924. _initCache(): void;
  84925. /**
  84926. * Flag the transform node as dirty (Forcing it to update everything)
  84927. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84928. * @returns this transform node
  84929. */
  84930. markAsDirty(property: string): TransformNode;
  84931. /**
  84932. * Returns the current mesh absolute position.
  84933. * Returns a Vector3.
  84934. */
  84935. get absolutePosition(): Vector3;
  84936. /**
  84937. * Returns the current mesh absolute scaling.
  84938. * Returns a Vector3.
  84939. */
  84940. get absoluteScaling(): Vector3;
  84941. /**
  84942. * Returns the current mesh absolute rotation.
  84943. * Returns a Quaternion.
  84944. */
  84945. get absoluteRotationQuaternion(): Quaternion;
  84946. /**
  84947. * Sets a new matrix to apply before all other transformation
  84948. * @param matrix defines the transform matrix
  84949. * @returns the current TransformNode
  84950. */
  84951. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84952. /**
  84953. * Sets a new pivot matrix to the current node
  84954. * @param matrix defines the new pivot matrix to use
  84955. * @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
  84956. * @returns the current TransformNode
  84957. */
  84958. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84959. /**
  84960. * Returns the mesh pivot matrix.
  84961. * Default : Identity.
  84962. * @returns the matrix
  84963. */
  84964. getPivotMatrix(): Matrix;
  84965. /**
  84966. * Instantiate (when possible) or clone that node with its hierarchy
  84967. * @param newParent defines the new parent to use for the instance (or clone)
  84968. * @param options defines options to configure how copy is done
  84969. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84970. * @returns an instance (or a clone) of the current node with its hiearchy
  84971. */
  84972. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84973. doNotInstantiate: boolean;
  84974. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84975. /**
  84976. * Prevents the World matrix to be computed any longer
  84977. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84978. * @returns the TransformNode.
  84979. */
  84980. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84981. /**
  84982. * Allows back the World matrix computation.
  84983. * @returns the TransformNode.
  84984. */
  84985. unfreezeWorldMatrix(): this;
  84986. /**
  84987. * True if the World matrix has been frozen.
  84988. */
  84989. get isWorldMatrixFrozen(): boolean;
  84990. /**
  84991. * Retuns the mesh absolute position in the World.
  84992. * @returns a Vector3.
  84993. */
  84994. getAbsolutePosition(): Vector3;
  84995. /**
  84996. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84997. * @param absolutePosition the absolute position to set
  84998. * @returns the TransformNode.
  84999. */
  85000. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  85001. /**
  85002. * Sets the mesh position in its local space.
  85003. * @param vector3 the position to set in localspace
  85004. * @returns the TransformNode.
  85005. */
  85006. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  85007. /**
  85008. * Returns the mesh position in the local space from the current World matrix values.
  85009. * @returns a new Vector3.
  85010. */
  85011. getPositionExpressedInLocalSpace(): Vector3;
  85012. /**
  85013. * Translates the mesh along the passed Vector3 in its local space.
  85014. * @param vector3 the distance to translate in localspace
  85015. * @returns the TransformNode.
  85016. */
  85017. locallyTranslate(vector3: Vector3): TransformNode;
  85018. private static _lookAtVectorCache;
  85019. /**
  85020. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  85021. * @param targetPoint the position (must be in same space as current mesh) to look at
  85022. * @param yawCor optional yaw (y-axis) correction in radians
  85023. * @param pitchCor optional pitch (x-axis) correction in radians
  85024. * @param rollCor optional roll (z-axis) correction in radians
  85025. * @param space the choosen space of the target
  85026. * @returns the TransformNode.
  85027. */
  85028. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  85029. /**
  85030. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85031. * This Vector3 is expressed in the World space.
  85032. * @param localAxis axis to rotate
  85033. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85034. */
  85035. getDirection(localAxis: Vector3): Vector3;
  85036. /**
  85037. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  85038. * localAxis is expressed in the mesh local space.
  85039. * result is computed in the Wordl space from the mesh World matrix.
  85040. * @param localAxis axis to rotate
  85041. * @param result the resulting transformnode
  85042. * @returns this TransformNode.
  85043. */
  85044. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  85045. /**
  85046. * Sets this transform node rotation to the given local axis.
  85047. * @param localAxis the axis in local space
  85048. * @param yawCor optional yaw (y-axis) correction in radians
  85049. * @param pitchCor optional pitch (x-axis) correction in radians
  85050. * @param rollCor optional roll (z-axis) correction in radians
  85051. * @returns this TransformNode
  85052. */
  85053. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85054. /**
  85055. * Sets a new pivot point to the current node
  85056. * @param point defines the new pivot point to use
  85057. * @param space defines if the point is in world or local space (local by default)
  85058. * @returns the current TransformNode
  85059. */
  85060. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85061. /**
  85062. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85063. * @returns the pivot point
  85064. */
  85065. getPivotPoint(): Vector3;
  85066. /**
  85067. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85068. * @param result the vector3 to store the result
  85069. * @returns this TransformNode.
  85070. */
  85071. getPivotPointToRef(result: Vector3): TransformNode;
  85072. /**
  85073. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85074. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85075. */
  85076. getAbsolutePivotPoint(): Vector3;
  85077. /**
  85078. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85079. * @param result vector3 to store the result
  85080. * @returns this TransformNode.
  85081. */
  85082. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85083. /**
  85084. * Defines the passed node as the parent of the current node.
  85085. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85086. * @see https://doc.babylonjs.com/how_to/parenting
  85087. * @param node the node ot set as the parent
  85088. * @returns this TransformNode.
  85089. */
  85090. setParent(node: Nullable<Node>): TransformNode;
  85091. private _nonUniformScaling;
  85092. /**
  85093. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85094. */
  85095. get nonUniformScaling(): boolean;
  85096. /** @hidden */
  85097. _updateNonUniformScalingState(value: boolean): boolean;
  85098. /**
  85099. * Attach the current TransformNode to another TransformNode associated with a bone
  85100. * @param bone Bone affecting the TransformNode
  85101. * @param affectedTransformNode TransformNode associated with the bone
  85102. * @returns this object
  85103. */
  85104. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85105. /**
  85106. * Detach the transform node if its associated with a bone
  85107. * @returns this object
  85108. */
  85109. detachFromBone(): TransformNode;
  85110. private static _rotationAxisCache;
  85111. /**
  85112. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85113. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85114. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85115. * The passed axis is also normalized.
  85116. * @param axis the axis to rotate around
  85117. * @param amount the amount to rotate in radians
  85118. * @param space Space to rotate in (Default: local)
  85119. * @returns the TransformNode.
  85120. */
  85121. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85122. /**
  85123. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85124. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85125. * The passed axis is also normalized. .
  85126. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85127. * @param point the point to rotate around
  85128. * @param axis the axis to rotate around
  85129. * @param amount the amount to rotate in radians
  85130. * @returns the TransformNode
  85131. */
  85132. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85133. /**
  85134. * Translates the mesh along the axis vector for the passed distance in the given space.
  85135. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85136. * @param axis the axis to translate in
  85137. * @param distance the distance to translate
  85138. * @param space Space to rotate in (Default: local)
  85139. * @returns the TransformNode.
  85140. */
  85141. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85142. /**
  85143. * Adds a rotation step to the mesh current rotation.
  85144. * x, y, z are Euler angles expressed in radians.
  85145. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85146. * This means this rotation is made in the mesh local space only.
  85147. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85148. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85149. * ```javascript
  85150. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85151. * ```
  85152. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85153. * 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.
  85154. * @param x Rotation to add
  85155. * @param y Rotation to add
  85156. * @param z Rotation to add
  85157. * @returns the TransformNode.
  85158. */
  85159. addRotation(x: number, y: number, z: number): TransformNode;
  85160. /**
  85161. * @hidden
  85162. */
  85163. protected _getEffectiveParent(): Nullable<Node>;
  85164. /**
  85165. * Computes the world matrix of the node
  85166. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85167. * @returns the world matrix
  85168. */
  85169. computeWorldMatrix(force?: boolean): Matrix;
  85170. protected _afterComputeWorldMatrix(): void;
  85171. /**
  85172. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85173. * @param func callback function to add
  85174. *
  85175. * @returns the TransformNode.
  85176. */
  85177. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85178. /**
  85179. * Removes a registered callback function.
  85180. * @param func callback function to remove
  85181. * @returns the TransformNode.
  85182. */
  85183. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85184. /**
  85185. * Gets the position of the current mesh in camera space
  85186. * @param camera defines the camera to use
  85187. * @returns a position
  85188. */
  85189. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85190. /**
  85191. * Returns the distance from the mesh to the active camera
  85192. * @param camera defines the camera to use
  85193. * @returns the distance
  85194. */
  85195. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85196. /**
  85197. * Clone the current transform node
  85198. * @param name Name of the new clone
  85199. * @param newParent New parent for the clone
  85200. * @param doNotCloneChildren Do not clone children hierarchy
  85201. * @returns the new transform node
  85202. */
  85203. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85204. /**
  85205. * Serializes the objects information.
  85206. * @param currentSerializationObject defines the object to serialize in
  85207. * @returns the serialized object
  85208. */
  85209. serialize(currentSerializationObject?: any): any;
  85210. /**
  85211. * Returns a new TransformNode object parsed from the source provided.
  85212. * @param parsedTransformNode is the source.
  85213. * @param scene the scne the object belongs to
  85214. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85215. * @returns a new TransformNode object parsed from the source provided.
  85216. */
  85217. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85218. /**
  85219. * Get all child-transformNodes of this node
  85220. * @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
  85221. * @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
  85222. * @returns an array of TransformNode
  85223. */
  85224. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85225. /**
  85226. * Releases resources associated with this transform node.
  85227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85229. */
  85230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85231. /**
  85232. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85233. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85234. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85235. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85236. * @returns the current mesh
  85237. */
  85238. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85239. private _syncAbsoluteScalingAndRotation;
  85240. }
  85241. }
  85242. declare module BABYLON {
  85243. /**
  85244. * Defines the types of pose enabled controllers that are supported
  85245. */
  85246. export enum PoseEnabledControllerType {
  85247. /**
  85248. * HTC Vive
  85249. */
  85250. VIVE = 0,
  85251. /**
  85252. * Oculus Rift
  85253. */
  85254. OCULUS = 1,
  85255. /**
  85256. * Windows mixed reality
  85257. */
  85258. WINDOWS = 2,
  85259. /**
  85260. * Samsung gear VR
  85261. */
  85262. GEAR_VR = 3,
  85263. /**
  85264. * Google Daydream
  85265. */
  85266. DAYDREAM = 4,
  85267. /**
  85268. * Generic
  85269. */
  85270. GENERIC = 5
  85271. }
  85272. /**
  85273. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85274. */
  85275. export interface MutableGamepadButton {
  85276. /**
  85277. * Value of the button/trigger
  85278. */
  85279. value: number;
  85280. /**
  85281. * If the button/trigger is currently touched
  85282. */
  85283. touched: boolean;
  85284. /**
  85285. * If the button/trigger is currently pressed
  85286. */
  85287. pressed: boolean;
  85288. }
  85289. /**
  85290. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85291. * @hidden
  85292. */
  85293. export interface ExtendedGamepadButton extends GamepadButton {
  85294. /**
  85295. * If the button/trigger is currently pressed
  85296. */
  85297. readonly pressed: boolean;
  85298. /**
  85299. * If the button/trigger is currently touched
  85300. */
  85301. readonly touched: boolean;
  85302. /**
  85303. * Value of the button/trigger
  85304. */
  85305. readonly value: number;
  85306. }
  85307. /** @hidden */
  85308. export interface _GamePadFactory {
  85309. /**
  85310. * Returns wether or not the current gamepad can be created for this type of controller.
  85311. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85312. * @returns true if it can be created, otherwise false
  85313. */
  85314. canCreate(gamepadInfo: any): boolean;
  85315. /**
  85316. * Creates a new instance of the Gamepad.
  85317. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85318. * @returns the new gamepad instance
  85319. */
  85320. create(gamepadInfo: any): Gamepad;
  85321. }
  85322. /**
  85323. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85324. */
  85325. export class PoseEnabledControllerHelper {
  85326. /** @hidden */
  85327. static _ControllerFactories: _GamePadFactory[];
  85328. /** @hidden */
  85329. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85330. /**
  85331. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85332. * @param vrGamepad the gamepad to initialized
  85333. * @returns a vr controller of the type the gamepad identified as
  85334. */
  85335. static InitiateController(vrGamepad: any): Gamepad;
  85336. }
  85337. /**
  85338. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85339. */
  85340. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85341. /**
  85342. * If the controller is used in a webXR session
  85343. */
  85344. isXR: boolean;
  85345. private _deviceRoomPosition;
  85346. private _deviceRoomRotationQuaternion;
  85347. /**
  85348. * The device position in babylon space
  85349. */
  85350. devicePosition: Vector3;
  85351. /**
  85352. * The device rotation in babylon space
  85353. */
  85354. deviceRotationQuaternion: Quaternion;
  85355. /**
  85356. * The scale factor of the device in babylon space
  85357. */
  85358. deviceScaleFactor: number;
  85359. /**
  85360. * (Likely devicePosition should be used instead) The device position in its room space
  85361. */
  85362. position: Vector3;
  85363. /**
  85364. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85365. */
  85366. rotationQuaternion: Quaternion;
  85367. /**
  85368. * The type of controller (Eg. Windows mixed reality)
  85369. */
  85370. controllerType: PoseEnabledControllerType;
  85371. protected _calculatedPosition: Vector3;
  85372. private _calculatedRotation;
  85373. /**
  85374. * The raw pose from the device
  85375. */
  85376. rawPose: DevicePose;
  85377. private _trackPosition;
  85378. private _maxRotationDistFromHeadset;
  85379. private _draggedRoomRotation;
  85380. /**
  85381. * @hidden
  85382. */
  85383. _disableTrackPosition(fixedPosition: Vector3): void;
  85384. /**
  85385. * Internal, the mesh attached to the controller
  85386. * @hidden
  85387. */
  85388. _mesh: Nullable<AbstractMesh>;
  85389. private _poseControlledCamera;
  85390. private _leftHandSystemQuaternion;
  85391. /**
  85392. * Internal, matrix used to convert room space to babylon space
  85393. * @hidden
  85394. */
  85395. _deviceToWorld: Matrix;
  85396. /**
  85397. * Node to be used when casting a ray from the controller
  85398. * @hidden
  85399. */
  85400. _pointingPoseNode: Nullable<TransformNode>;
  85401. /**
  85402. * Name of the child mesh that can be used to cast a ray from the controller
  85403. */
  85404. static readonly POINTING_POSE: string;
  85405. /**
  85406. * Creates a new PoseEnabledController from a gamepad
  85407. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85408. */
  85409. constructor(browserGamepad: any);
  85410. private _workingMatrix;
  85411. /**
  85412. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85413. */
  85414. update(): void;
  85415. /**
  85416. * Updates only the pose device and mesh without doing any button event checking
  85417. */
  85418. protected _updatePoseAndMesh(): void;
  85419. /**
  85420. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85421. * @param poseData raw pose fromthe device
  85422. */
  85423. updateFromDevice(poseData: DevicePose): void;
  85424. /**
  85425. * @hidden
  85426. */
  85427. _meshAttachedObservable: Observable<AbstractMesh>;
  85428. /**
  85429. * Attaches a mesh to the controller
  85430. * @param mesh the mesh to be attached
  85431. */
  85432. attachToMesh(mesh: AbstractMesh): void;
  85433. /**
  85434. * Attaches the controllers mesh to a camera
  85435. * @param camera the camera the mesh should be attached to
  85436. */
  85437. attachToPoseControlledCamera(camera: TargetCamera): void;
  85438. /**
  85439. * Disposes of the controller
  85440. */
  85441. dispose(): void;
  85442. /**
  85443. * The mesh that is attached to the controller
  85444. */
  85445. get mesh(): Nullable<AbstractMesh>;
  85446. /**
  85447. * Gets the ray of the controller in the direction the controller is pointing
  85448. * @param length the length the resulting ray should be
  85449. * @returns a ray in the direction the controller is pointing
  85450. */
  85451. getForwardRay(length?: number): Ray;
  85452. }
  85453. }
  85454. declare module BABYLON {
  85455. /**
  85456. * Defines the WebVRController object that represents controllers tracked in 3D space
  85457. */
  85458. export abstract class WebVRController extends PoseEnabledController {
  85459. /**
  85460. * Internal, the default controller model for the controller
  85461. */
  85462. protected _defaultModel: Nullable<AbstractMesh>;
  85463. /**
  85464. * Fired when the trigger state has changed
  85465. */
  85466. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85467. /**
  85468. * Fired when the main button state has changed
  85469. */
  85470. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85471. /**
  85472. * Fired when the secondary button state has changed
  85473. */
  85474. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85475. /**
  85476. * Fired when the pad state has changed
  85477. */
  85478. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85479. /**
  85480. * Fired when controllers stick values have changed
  85481. */
  85482. onPadValuesChangedObservable: Observable<StickValues>;
  85483. /**
  85484. * Array of button availible on the controller
  85485. */
  85486. protected _buttons: Array<MutableGamepadButton>;
  85487. private _onButtonStateChange;
  85488. /**
  85489. * Fired when a controller button's state has changed
  85490. * @param callback the callback containing the button that was modified
  85491. */
  85492. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85493. /**
  85494. * X and Y axis corresponding to the controllers joystick
  85495. */
  85496. pad: StickValues;
  85497. /**
  85498. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85499. */
  85500. hand: string;
  85501. /**
  85502. * The default controller model for the controller
  85503. */
  85504. get defaultModel(): Nullable<AbstractMesh>;
  85505. /**
  85506. * Creates a new WebVRController from a gamepad
  85507. * @param vrGamepad the gamepad that the WebVRController should be created from
  85508. */
  85509. constructor(vrGamepad: any);
  85510. /**
  85511. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85512. */
  85513. update(): void;
  85514. /**
  85515. * Function to be called when a button is modified
  85516. */
  85517. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85518. /**
  85519. * Loads a mesh and attaches it to the controller
  85520. * @param scene the scene the mesh should be added to
  85521. * @param meshLoaded callback for when the mesh has been loaded
  85522. */
  85523. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85524. private _setButtonValue;
  85525. private _changes;
  85526. private _checkChanges;
  85527. /**
  85528. * Disposes of th webVRCOntroller
  85529. */
  85530. dispose(): void;
  85531. }
  85532. }
  85533. declare module BABYLON {
  85534. /**
  85535. * The HemisphericLight simulates the ambient environment light,
  85536. * so the passed direction is the light reflection direction, not the incoming direction.
  85537. */
  85538. export class HemisphericLight extends Light {
  85539. /**
  85540. * The groundColor is the light in the opposite direction to the one specified during creation.
  85541. * 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.
  85542. */
  85543. groundColor: Color3;
  85544. /**
  85545. * The light reflection direction, not the incoming direction.
  85546. */
  85547. direction: Vector3;
  85548. /**
  85549. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85550. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85551. * The HemisphericLight can't cast shadows.
  85552. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85553. * @param name The friendly name of the light
  85554. * @param direction The direction of the light reflection
  85555. * @param scene The scene the light belongs to
  85556. */
  85557. constructor(name: string, direction: Vector3, scene: Scene);
  85558. protected _buildUniformLayout(): void;
  85559. /**
  85560. * Returns the string "HemisphericLight".
  85561. * @return The class name
  85562. */
  85563. getClassName(): string;
  85564. /**
  85565. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85566. * Returns the updated direction.
  85567. * @param target The target the direction should point to
  85568. * @return The computed direction
  85569. */
  85570. setDirectionToTarget(target: Vector3): Vector3;
  85571. /**
  85572. * Returns the shadow generator associated to the light.
  85573. * @returns Always null for hemispheric lights because it does not support shadows.
  85574. */
  85575. getShadowGenerator(): Nullable<IShadowGenerator>;
  85576. /**
  85577. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85578. * @param effect The effect to update
  85579. * @param lightIndex The index of the light in the effect to update
  85580. * @returns The hemispheric light
  85581. */
  85582. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85583. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85584. /**
  85585. * Computes the world matrix of the node
  85586. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85587. * @param useWasUpdatedFlag defines a reserved property
  85588. * @returns the world matrix
  85589. */
  85590. computeWorldMatrix(): Matrix;
  85591. /**
  85592. * Returns the integer 3.
  85593. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85594. */
  85595. getTypeID(): number;
  85596. /**
  85597. * Prepares the list of defines specific to the light type.
  85598. * @param defines the list of defines
  85599. * @param lightIndex defines the index of the light for the effect
  85600. */
  85601. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85602. }
  85603. }
  85604. declare module BABYLON {
  85605. /** @hidden */
  85606. export var vrMultiviewToSingleviewPixelShader: {
  85607. name: string;
  85608. shader: string;
  85609. };
  85610. }
  85611. declare module BABYLON {
  85612. /**
  85613. * Renders to multiple views with a single draw call
  85614. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85615. */
  85616. export class MultiviewRenderTarget extends RenderTargetTexture {
  85617. /**
  85618. * Creates a multiview render target
  85619. * @param scene scene used with the render target
  85620. * @param size the size of the render target (used for each view)
  85621. */
  85622. constructor(scene: Scene, size?: number | {
  85623. width: number;
  85624. height: number;
  85625. } | {
  85626. ratio: number;
  85627. });
  85628. /**
  85629. * @hidden
  85630. * @param faceIndex the face index, if its a cube texture
  85631. */
  85632. _bindFrameBuffer(faceIndex?: number): void;
  85633. /**
  85634. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85635. * @returns the view count
  85636. */
  85637. getViewCount(): number;
  85638. }
  85639. }
  85640. declare module BABYLON {
  85641. /**
  85642. * Represents a camera frustum
  85643. */
  85644. export class Frustum {
  85645. /**
  85646. * Gets the planes representing the frustum
  85647. * @param transform matrix to be applied to the returned planes
  85648. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85649. */
  85650. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85651. /**
  85652. * Gets the near frustum plane transformed by the transform matrix
  85653. * @param transform transformation matrix to be applied to the resulting frustum plane
  85654. * @param frustumPlane the resuling frustum plane
  85655. */
  85656. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85657. /**
  85658. * Gets the far frustum plane transformed by the transform matrix
  85659. * @param transform transformation matrix to be applied to the resulting frustum plane
  85660. * @param frustumPlane the resuling frustum plane
  85661. */
  85662. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85663. /**
  85664. * Gets the left frustum plane transformed by the transform matrix
  85665. * @param transform transformation matrix to be applied to the resulting frustum plane
  85666. * @param frustumPlane the resuling frustum plane
  85667. */
  85668. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85669. /**
  85670. * Gets the right frustum plane transformed by the transform matrix
  85671. * @param transform transformation matrix to be applied to the resulting frustum plane
  85672. * @param frustumPlane the resuling frustum plane
  85673. */
  85674. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85675. /**
  85676. * Gets the top frustum plane transformed by the transform matrix
  85677. * @param transform transformation matrix to be applied to the resulting frustum plane
  85678. * @param frustumPlane the resuling frustum plane
  85679. */
  85680. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85681. /**
  85682. * Gets the bottom frustum plane transformed by the transform matrix
  85683. * @param transform transformation matrix to be applied to the resulting frustum plane
  85684. * @param frustumPlane the resuling frustum plane
  85685. */
  85686. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85687. /**
  85688. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85689. * @param transform transformation matrix to be applied to the resulting frustum planes
  85690. * @param frustumPlanes the resuling frustum planes
  85691. */
  85692. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85693. }
  85694. }
  85695. declare module BABYLON {
  85696. interface Engine {
  85697. /**
  85698. * Creates a new multiview render target
  85699. * @param width defines the width of the texture
  85700. * @param height defines the height of the texture
  85701. * @returns the created multiview texture
  85702. */
  85703. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85704. /**
  85705. * Binds a multiview framebuffer to be drawn to
  85706. * @param multiviewTexture texture to bind
  85707. */
  85708. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85709. }
  85710. interface Camera {
  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. _useMultiviewToSingleView: boolean;
  85716. /**
  85717. * @hidden
  85718. * 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)
  85719. */
  85720. _multiviewTexture: Nullable<RenderTargetTexture>;
  85721. /**
  85722. * @hidden
  85723. * ensures the multiview texture of the camera exists and has the specified width/height
  85724. * @param width height to set on the multiview texture
  85725. * @param height width to set on the multiview texture
  85726. */
  85727. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85728. }
  85729. interface Scene {
  85730. /** @hidden */
  85731. _transformMatrixR: Matrix;
  85732. /** @hidden */
  85733. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85734. /** @hidden */
  85735. _createMultiviewUbo(): void;
  85736. /** @hidden */
  85737. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85738. /** @hidden */
  85739. _renderMultiviewToSingleView(camera: Camera): void;
  85740. }
  85741. }
  85742. declare module BABYLON {
  85743. /**
  85744. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85745. * This will not be used for webXR as it supports displaying texture arrays directly
  85746. */
  85747. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85748. /**
  85749. * Initializes a VRMultiviewToSingleview
  85750. * @param name name of the post process
  85751. * @param camera camera to be applied to
  85752. * @param scaleFactor scaling factor to the size of the output texture
  85753. */
  85754. constructor(name: string, camera: Camera, scaleFactor: number);
  85755. }
  85756. }
  85757. declare module BABYLON {
  85758. /**
  85759. * Interface used to define additional presentation attributes
  85760. */
  85761. export interface IVRPresentationAttributes {
  85762. /**
  85763. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85764. */
  85765. highRefreshRate: boolean;
  85766. /**
  85767. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85768. */
  85769. foveationLevel: number;
  85770. }
  85771. interface Engine {
  85772. /** @hidden */
  85773. _vrDisplay: any;
  85774. /** @hidden */
  85775. _vrSupported: boolean;
  85776. /** @hidden */
  85777. _oldSize: Size;
  85778. /** @hidden */
  85779. _oldHardwareScaleFactor: number;
  85780. /** @hidden */
  85781. _vrExclusivePointerMode: boolean;
  85782. /** @hidden */
  85783. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85784. /** @hidden */
  85785. _onVRDisplayPointerRestricted: () => void;
  85786. /** @hidden */
  85787. _onVRDisplayPointerUnrestricted: () => void;
  85788. /** @hidden */
  85789. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85790. /** @hidden */
  85791. _onVrDisplayDisconnect: Nullable<() => void>;
  85792. /** @hidden */
  85793. _onVrDisplayPresentChange: Nullable<() => void>;
  85794. /**
  85795. * Observable signaled when VR display mode changes
  85796. */
  85797. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85798. /**
  85799. * Observable signaled when VR request present is complete
  85800. */
  85801. onVRRequestPresentComplete: Observable<boolean>;
  85802. /**
  85803. * Observable signaled when VR request present starts
  85804. */
  85805. onVRRequestPresentStart: Observable<Engine>;
  85806. /**
  85807. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85808. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85809. */
  85810. isInVRExclusivePointerMode: boolean;
  85811. /**
  85812. * Gets a boolean indicating if a webVR device was detected
  85813. * @returns true if a webVR device was detected
  85814. */
  85815. isVRDevicePresent(): boolean;
  85816. /**
  85817. * Gets the current webVR device
  85818. * @returns the current webVR device (or null)
  85819. */
  85820. getVRDevice(): any;
  85821. /**
  85822. * Initializes a webVR display and starts listening to display change events
  85823. * The onVRDisplayChangedObservable will be notified upon these changes
  85824. * @returns A promise containing a VRDisplay and if vr is supported
  85825. */
  85826. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85827. /** @hidden */
  85828. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85829. /**
  85830. * Gets or sets the presentation attributes used to configure VR rendering
  85831. */
  85832. vrPresentationAttributes?: IVRPresentationAttributes;
  85833. /**
  85834. * Call this function to switch to webVR mode
  85835. * Will do nothing if webVR is not supported or if there is no webVR device
  85836. * @param options the webvr options provided to the camera. mainly used for multiview
  85837. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85838. */
  85839. enableVR(options: WebVROptions): void;
  85840. /** @hidden */
  85841. _onVRFullScreenTriggered(): void;
  85842. }
  85843. }
  85844. declare module BABYLON {
  85845. /**
  85846. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85847. * IMPORTANT!! The data is right-hand data.
  85848. * @export
  85849. * @interface DevicePose
  85850. */
  85851. export interface DevicePose {
  85852. /**
  85853. * The position of the device, values in array are [x,y,z].
  85854. */
  85855. readonly position: Nullable<Float32Array>;
  85856. /**
  85857. * The linearVelocity of the device, values in array are [x,y,z].
  85858. */
  85859. readonly linearVelocity: Nullable<Float32Array>;
  85860. /**
  85861. * The linearAcceleration of the device, values in array are [x,y,z].
  85862. */
  85863. readonly linearAcceleration: Nullable<Float32Array>;
  85864. /**
  85865. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85866. */
  85867. readonly orientation: Nullable<Float32Array>;
  85868. /**
  85869. * The angularVelocity of the device, values in array are [x,y,z].
  85870. */
  85871. readonly angularVelocity: Nullable<Float32Array>;
  85872. /**
  85873. * The angularAcceleration of the device, values in array are [x,y,z].
  85874. */
  85875. readonly angularAcceleration: Nullable<Float32Array>;
  85876. }
  85877. /**
  85878. * Interface representing a pose controlled object in Babylon.
  85879. * A pose controlled object has both regular pose values as well as pose values
  85880. * from an external device such as a VR head mounted display
  85881. */
  85882. export interface PoseControlled {
  85883. /**
  85884. * The position of the object in babylon space.
  85885. */
  85886. position: Vector3;
  85887. /**
  85888. * The rotation quaternion of the object in babylon space.
  85889. */
  85890. rotationQuaternion: Quaternion;
  85891. /**
  85892. * The position of the device in babylon space.
  85893. */
  85894. devicePosition?: Vector3;
  85895. /**
  85896. * The rotation quaternion of the device in babylon space.
  85897. */
  85898. deviceRotationQuaternion: Quaternion;
  85899. /**
  85900. * The raw pose coming from the device.
  85901. */
  85902. rawPose: Nullable<DevicePose>;
  85903. /**
  85904. * The scale of the device to be used when translating from device space to babylon space.
  85905. */
  85906. deviceScaleFactor: number;
  85907. /**
  85908. * Updates the poseControlled values based on the input device pose.
  85909. * @param poseData the pose data to update the object with
  85910. */
  85911. updateFromDevice(poseData: DevicePose): void;
  85912. }
  85913. /**
  85914. * Set of options to customize the webVRCamera
  85915. */
  85916. export interface WebVROptions {
  85917. /**
  85918. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85919. */
  85920. trackPosition?: boolean;
  85921. /**
  85922. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85923. */
  85924. positionScale?: number;
  85925. /**
  85926. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85927. */
  85928. displayName?: string;
  85929. /**
  85930. * Should the native controller meshes be initialized. (default: true)
  85931. */
  85932. controllerMeshes?: boolean;
  85933. /**
  85934. * Creating a default HemiLight only on controllers. (default: true)
  85935. */
  85936. defaultLightingOnControllers?: boolean;
  85937. /**
  85938. * If you don't want to use the default VR button of the helper. (default: false)
  85939. */
  85940. useCustomVRButton?: boolean;
  85941. /**
  85942. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85943. */
  85944. customVRButton?: HTMLButtonElement;
  85945. /**
  85946. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85947. */
  85948. rayLength?: number;
  85949. /**
  85950. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85951. */
  85952. defaultHeight?: number;
  85953. /**
  85954. * If multiview should be used if availible (default: false)
  85955. */
  85956. useMultiview?: boolean;
  85957. }
  85958. /**
  85959. * This represents a WebVR camera.
  85960. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85961. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85962. */
  85963. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85964. private webVROptions;
  85965. /**
  85966. * @hidden
  85967. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85968. */
  85969. _vrDevice: any;
  85970. /**
  85971. * The rawPose of the vrDevice.
  85972. */
  85973. rawPose: Nullable<DevicePose>;
  85974. private _onVREnabled;
  85975. private _specsVersion;
  85976. private _attached;
  85977. private _frameData;
  85978. protected _descendants: Array<Node>;
  85979. private _deviceRoomPosition;
  85980. /** @hidden */
  85981. _deviceRoomRotationQuaternion: Quaternion;
  85982. private _standingMatrix;
  85983. /**
  85984. * Represents device position in babylon space.
  85985. */
  85986. devicePosition: Vector3;
  85987. /**
  85988. * Represents device rotation in babylon space.
  85989. */
  85990. deviceRotationQuaternion: Quaternion;
  85991. /**
  85992. * The scale of the device to be used when translating from device space to babylon space.
  85993. */
  85994. deviceScaleFactor: number;
  85995. private _deviceToWorld;
  85996. private _worldToDevice;
  85997. /**
  85998. * References to the webVR controllers for the vrDevice.
  85999. */
  86000. controllers: Array<WebVRController>;
  86001. /**
  86002. * Emits an event when a controller is attached.
  86003. */
  86004. onControllersAttachedObservable: Observable<WebVRController[]>;
  86005. /**
  86006. * Emits an event when a controller's mesh has been loaded;
  86007. */
  86008. onControllerMeshLoadedObservable: Observable<WebVRController>;
  86009. /**
  86010. * Emits an event when the HMD's pose has been updated.
  86011. */
  86012. onPoseUpdatedFromDeviceObservable: Observable<any>;
  86013. private _poseSet;
  86014. /**
  86015. * If the rig cameras be used as parent instead of this camera.
  86016. */
  86017. rigParenting: boolean;
  86018. private _lightOnControllers;
  86019. private _defaultHeight?;
  86020. /**
  86021. * Instantiates a WebVRFreeCamera.
  86022. * @param name The name of the WebVRFreeCamera
  86023. * @param position The starting anchor position for the camera
  86024. * @param scene The scene the camera belongs to
  86025. * @param webVROptions a set of customizable options for the webVRCamera
  86026. */
  86027. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  86028. /**
  86029. * Gets the device distance from the ground in meters.
  86030. * @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.
  86031. */
  86032. deviceDistanceToRoomGround(): number;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  86036. */
  86037. useStandingMatrix(callback?: (bool: boolean) => void): void;
  86038. /**
  86039. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86040. * @returns A promise with a boolean set to if the standing matrix is supported.
  86041. */
  86042. useStandingMatrixAsync(): Promise<boolean>;
  86043. /**
  86044. * Disposes the camera
  86045. */
  86046. dispose(): void;
  86047. /**
  86048. * Gets a vrController by name.
  86049. * @param name The name of the controller to retreive
  86050. * @returns the controller matching the name specified or null if not found
  86051. */
  86052. getControllerByName(name: string): Nullable<WebVRController>;
  86053. private _leftController;
  86054. /**
  86055. * The controller corresponding to the users left hand.
  86056. */
  86057. get leftController(): Nullable<WebVRController>;
  86058. private _rightController;
  86059. /**
  86060. * The controller corresponding to the users right hand.
  86061. */
  86062. get rightController(): Nullable<WebVRController>;
  86063. /**
  86064. * Casts a ray forward from the vrCamera's gaze.
  86065. * @param length Length of the ray (default: 100)
  86066. * @returns the ray corresponding to the gaze
  86067. */
  86068. getForwardRay(length?: number): Ray;
  86069. /**
  86070. * @hidden
  86071. * Updates the camera based on device's frame data
  86072. */
  86073. _checkInputs(): void;
  86074. /**
  86075. * Updates the poseControlled values based on the input device pose.
  86076. * @param poseData Pose coming from the device
  86077. */
  86078. updateFromDevice(poseData: DevicePose): void;
  86079. private _htmlElementAttached;
  86080. private _detachIfAttached;
  86081. /**
  86082. * WebVR's attach control will start broadcasting frames to the device.
  86083. * Note that in certain browsers (chrome for example) this function must be called
  86084. * within a user-interaction callback. Example:
  86085. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86086. *
  86087. * @param element html element to attach the vrDevice to
  86088. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86089. */
  86090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86091. /**
  86092. * Detaches the camera from the html element and disables VR
  86093. *
  86094. * @param element html element to detach from
  86095. */
  86096. detachControl(element: HTMLElement): void;
  86097. /**
  86098. * @returns the name of this class
  86099. */
  86100. getClassName(): string;
  86101. /**
  86102. * Calls resetPose on the vrDisplay
  86103. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86104. */
  86105. resetToCurrentRotation(): void;
  86106. /**
  86107. * @hidden
  86108. * Updates the rig cameras (left and right eye)
  86109. */
  86110. _updateRigCameras(): void;
  86111. private _workingVector;
  86112. private _oneVector;
  86113. private _workingMatrix;
  86114. private updateCacheCalled;
  86115. private _correctPositionIfNotTrackPosition;
  86116. /**
  86117. * @hidden
  86118. * Updates the cached values of the camera
  86119. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86120. */
  86121. _updateCache(ignoreParentClass?: boolean): void;
  86122. /**
  86123. * @hidden
  86124. * Get current device position in babylon world
  86125. */
  86126. _computeDevicePosition(): void;
  86127. /**
  86128. * Updates the current device position and rotation in the babylon world
  86129. */
  86130. update(): void;
  86131. /**
  86132. * @hidden
  86133. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86134. * @returns an identity matrix
  86135. */
  86136. _getViewMatrix(): Matrix;
  86137. private _tmpMatrix;
  86138. /**
  86139. * This function is called by the two RIG cameras.
  86140. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86141. * @hidden
  86142. */
  86143. _getWebVRViewMatrix(): Matrix;
  86144. /** @hidden */
  86145. _getWebVRProjectionMatrix(): Matrix;
  86146. private _onGamepadConnectedObserver;
  86147. private _onGamepadDisconnectedObserver;
  86148. private _updateCacheWhenTrackingDisabledObserver;
  86149. /**
  86150. * Initializes the controllers and their meshes
  86151. */
  86152. initControllers(): void;
  86153. }
  86154. }
  86155. declare module BABYLON {
  86156. /**
  86157. * Size options for a post process
  86158. */
  86159. export type PostProcessOptions = {
  86160. width: number;
  86161. height: number;
  86162. };
  86163. /**
  86164. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86165. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86166. */
  86167. export class PostProcess {
  86168. /** Name of the PostProcess. */
  86169. name: string;
  86170. /**
  86171. * Gets or sets the unique id of the post process
  86172. */
  86173. uniqueId: number;
  86174. /**
  86175. * Width of the texture to apply the post process on
  86176. */
  86177. width: number;
  86178. /**
  86179. * Height of the texture to apply the post process on
  86180. */
  86181. height: number;
  86182. /**
  86183. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86184. * @hidden
  86185. */
  86186. _outputTexture: Nullable<InternalTexture>;
  86187. /**
  86188. * Sampling mode used by the shader
  86189. * See https://doc.babylonjs.com/classes/3.1/texture
  86190. */
  86191. renderTargetSamplingMode: number;
  86192. /**
  86193. * Clear color to use when screen clearing
  86194. */
  86195. clearColor: Color4;
  86196. /**
  86197. * If the buffer needs to be cleared before applying the post process. (default: true)
  86198. * Should be set to false if shader will overwrite all previous pixels.
  86199. */
  86200. autoClear: boolean;
  86201. /**
  86202. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86203. */
  86204. alphaMode: number;
  86205. /**
  86206. * Sets the setAlphaBlendConstants of the babylon engine
  86207. */
  86208. alphaConstants: Color4;
  86209. /**
  86210. * Animations to be used for the post processing
  86211. */
  86212. animations: Animation[];
  86213. /**
  86214. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86215. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86216. */
  86217. enablePixelPerfectMode: boolean;
  86218. /**
  86219. * Force the postprocess to be applied without taking in account viewport
  86220. */
  86221. forceFullscreenViewport: boolean;
  86222. /**
  86223. * List of inspectable custom properties (used by the Inspector)
  86224. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86225. */
  86226. inspectableCustomProperties: IInspectable[];
  86227. /**
  86228. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86229. *
  86230. * | Value | Type | Description |
  86231. * | ----- | ----------------------------------- | ----------- |
  86232. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86233. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86234. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86235. *
  86236. */
  86237. scaleMode: number;
  86238. /**
  86239. * Force textures to be a power of two (default: false)
  86240. */
  86241. alwaysForcePOT: boolean;
  86242. private _samples;
  86243. /**
  86244. * Number of sample textures (default: 1)
  86245. */
  86246. get samples(): number;
  86247. set samples(n: number);
  86248. /**
  86249. * Modify the scale of the post process to be the same as the viewport (default: false)
  86250. */
  86251. adaptScaleToCurrentViewport: boolean;
  86252. private _camera;
  86253. private _scene;
  86254. private _engine;
  86255. private _options;
  86256. private _reusable;
  86257. private _textureType;
  86258. /**
  86259. * Smart array of input and output textures for the post process.
  86260. * @hidden
  86261. */
  86262. _textures: SmartArray<InternalTexture>;
  86263. /**
  86264. * The index in _textures that corresponds to the output texture.
  86265. * @hidden
  86266. */
  86267. _currentRenderTextureInd: number;
  86268. private _effect;
  86269. private _samplers;
  86270. private _fragmentUrl;
  86271. private _vertexUrl;
  86272. private _parameters;
  86273. private _scaleRatio;
  86274. protected _indexParameters: any;
  86275. private _shareOutputWithPostProcess;
  86276. private _texelSize;
  86277. private _forcedOutputTexture;
  86278. /**
  86279. * Returns the fragment url or shader name used in the post process.
  86280. * @returns the fragment url or name in the shader store.
  86281. */
  86282. getEffectName(): string;
  86283. /**
  86284. * An event triggered when the postprocess is activated.
  86285. */
  86286. onActivateObservable: Observable<Camera>;
  86287. private _onActivateObserver;
  86288. /**
  86289. * A function that is added to the onActivateObservable
  86290. */
  86291. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86292. /**
  86293. * An event triggered when the postprocess changes its size.
  86294. */
  86295. onSizeChangedObservable: Observable<PostProcess>;
  86296. private _onSizeChangedObserver;
  86297. /**
  86298. * A function that is added to the onSizeChangedObservable
  86299. */
  86300. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86301. /**
  86302. * An event triggered when the postprocess applies its effect.
  86303. */
  86304. onApplyObservable: Observable<Effect>;
  86305. private _onApplyObserver;
  86306. /**
  86307. * A function that is added to the onApplyObservable
  86308. */
  86309. set onApply(callback: (effect: Effect) => void);
  86310. /**
  86311. * An event triggered before rendering the postprocess
  86312. */
  86313. onBeforeRenderObservable: Observable<Effect>;
  86314. private _onBeforeRenderObserver;
  86315. /**
  86316. * A function that is added to the onBeforeRenderObservable
  86317. */
  86318. set onBeforeRender(callback: (effect: Effect) => void);
  86319. /**
  86320. * An event triggered after rendering the postprocess
  86321. */
  86322. onAfterRenderObservable: Observable<Effect>;
  86323. private _onAfterRenderObserver;
  86324. /**
  86325. * A function that is added to the onAfterRenderObservable
  86326. */
  86327. set onAfterRender(callback: (efect: Effect) => void);
  86328. /**
  86329. * 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
  86330. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86331. */
  86332. get inputTexture(): InternalTexture;
  86333. set inputTexture(value: InternalTexture);
  86334. /**
  86335. * Gets the camera which post process is applied to.
  86336. * @returns The camera the post process is applied to.
  86337. */
  86338. getCamera(): Camera;
  86339. /**
  86340. * Gets the texel size of the postprocess.
  86341. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86342. */
  86343. get texelSize(): Vector2;
  86344. /**
  86345. * Creates a new instance PostProcess
  86346. * @param name The name of the PostProcess.
  86347. * @param fragmentUrl The url of the fragment shader to be used.
  86348. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86349. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86350. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86351. * @param camera The camera to apply the render pass to.
  86352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86353. * @param engine The engine which the post process will be applied. (default: current engine)
  86354. * @param reusable If the post process can be reused on the same frame. (default: false)
  86355. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86356. * @param textureType Type of textures used when performing the post process. (default: 0)
  86357. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86358. * @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
  86359. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86360. */
  86361. constructor(
  86362. /** Name of the PostProcess. */
  86363. 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);
  86364. /**
  86365. * Gets a string idenfifying the name of the class
  86366. * @returns "PostProcess" string
  86367. */
  86368. getClassName(): string;
  86369. /**
  86370. * Gets the engine which this post process belongs to.
  86371. * @returns The engine the post process was enabled with.
  86372. */
  86373. getEngine(): Engine;
  86374. /**
  86375. * The effect that is created when initializing the post process.
  86376. * @returns The created effect corresponding the the postprocess.
  86377. */
  86378. getEffect(): Effect;
  86379. /**
  86380. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86381. * @param postProcess The post process to share the output with.
  86382. * @returns This post process.
  86383. */
  86384. shareOutputWith(postProcess: PostProcess): PostProcess;
  86385. /**
  86386. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86387. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86388. */
  86389. useOwnOutput(): void;
  86390. /**
  86391. * Updates the effect with the current post process compile time values and recompiles the shader.
  86392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86395. * @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
  86396. * @param onCompiled Called when the shader has been compiled.
  86397. * @param onError Called if there is an error when compiling a shader.
  86398. */
  86399. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86400. /**
  86401. * The post process is reusable if it can be used multiple times within one frame.
  86402. * @returns If the post process is reusable
  86403. */
  86404. isReusable(): boolean;
  86405. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86406. markTextureDirty(): void;
  86407. /**
  86408. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86409. * 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.
  86410. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86411. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86412. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86413. * @returns The target texture that was bound to be written to.
  86414. */
  86415. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86416. /**
  86417. * If the post process is supported.
  86418. */
  86419. get isSupported(): boolean;
  86420. /**
  86421. * The aspect ratio of the output texture.
  86422. */
  86423. get aspectRatio(): number;
  86424. /**
  86425. * Get a value indicating if the post-process is ready to be used
  86426. * @returns true if the post-process is ready (shader is compiled)
  86427. */
  86428. isReady(): boolean;
  86429. /**
  86430. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86431. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86432. */
  86433. apply(): Nullable<Effect>;
  86434. private _disposeTextures;
  86435. /**
  86436. * Disposes the post process.
  86437. * @param camera The camera to dispose the post process on.
  86438. */
  86439. dispose(camera?: Camera): void;
  86440. }
  86441. }
  86442. declare module BABYLON {
  86443. /** @hidden */
  86444. export var kernelBlurVaryingDeclaration: {
  86445. name: string;
  86446. shader: string;
  86447. };
  86448. }
  86449. declare module BABYLON {
  86450. /** @hidden */
  86451. export var kernelBlurFragment: {
  86452. name: string;
  86453. shader: string;
  86454. };
  86455. }
  86456. declare module BABYLON {
  86457. /** @hidden */
  86458. export var kernelBlurFragment2: {
  86459. name: string;
  86460. shader: string;
  86461. };
  86462. }
  86463. declare module BABYLON {
  86464. /** @hidden */
  86465. export var kernelBlurPixelShader: {
  86466. name: string;
  86467. shader: string;
  86468. };
  86469. }
  86470. declare module BABYLON {
  86471. /** @hidden */
  86472. export var kernelBlurVertex: {
  86473. name: string;
  86474. shader: string;
  86475. };
  86476. }
  86477. declare module BABYLON {
  86478. /** @hidden */
  86479. export var kernelBlurVertexShader: {
  86480. name: string;
  86481. shader: string;
  86482. };
  86483. }
  86484. declare module BABYLON {
  86485. /**
  86486. * The Blur Post Process which blurs an image based on a kernel and direction.
  86487. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86488. */
  86489. export class BlurPostProcess extends PostProcess {
  86490. /** The direction in which to blur the image. */
  86491. direction: Vector2;
  86492. private blockCompilation;
  86493. protected _kernel: number;
  86494. protected _idealKernel: number;
  86495. protected _packedFloat: boolean;
  86496. private _staticDefines;
  86497. /**
  86498. * Sets the length in pixels of the blur sample region
  86499. */
  86500. set kernel(v: number);
  86501. /**
  86502. * Gets the length in pixels of the blur sample region
  86503. */
  86504. get kernel(): number;
  86505. /**
  86506. * Sets wether or not the blur needs to unpack/repack floats
  86507. */
  86508. set packedFloat(v: boolean);
  86509. /**
  86510. * Gets wether or not the blur is unpacking/repacking floats
  86511. */
  86512. get packedFloat(): boolean;
  86513. /**
  86514. * Creates a new instance BlurPostProcess
  86515. * @param name The name of the effect.
  86516. * @param direction The direction in which to blur the image.
  86517. * @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.
  86518. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86519. * @param camera The camera to apply the render pass to.
  86520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86521. * @param engine The engine which the post process will be applied. (default: current engine)
  86522. * @param reusable If the post process can be reused on the same frame. (default: false)
  86523. * @param textureType Type of textures used when performing the post process. (default: 0)
  86524. * @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)
  86525. */
  86526. constructor(name: string,
  86527. /** The direction in which to blur the image. */
  86528. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86529. /**
  86530. * Updates the effect with the current post process compile time values and recompiles the shader.
  86531. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86532. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86533. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86534. * @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
  86535. * @param onCompiled Called when the shader has been compiled.
  86536. * @param onError Called if there is an error when compiling a shader.
  86537. */
  86538. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86539. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86540. /**
  86541. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86542. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86543. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86544. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86545. * The gaps between physical kernels are compensated for in the weighting of the samples
  86546. * @param idealKernel Ideal blur kernel.
  86547. * @return Nearest best kernel.
  86548. */
  86549. protected _nearestBestKernel(idealKernel: number): number;
  86550. /**
  86551. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86552. * @param x The point on the Gaussian distribution to sample.
  86553. * @return the value of the Gaussian function at x.
  86554. */
  86555. protected _gaussianWeight(x: number): number;
  86556. /**
  86557. * Generates a string that can be used as a floating point number in GLSL.
  86558. * @param x Value to print.
  86559. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86560. * @return GLSL float string.
  86561. */
  86562. protected _glslFloat(x: number, decimalFigures?: number): string;
  86563. }
  86564. }
  86565. declare module BABYLON {
  86566. /**
  86567. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86568. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86569. * You can then easily use it as a reflectionTexture on a flat surface.
  86570. * In case the surface is not a plane, please consider relying on reflection probes.
  86571. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86572. */
  86573. export class MirrorTexture extends RenderTargetTexture {
  86574. private scene;
  86575. /**
  86576. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86577. * 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.
  86578. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86579. */
  86580. mirrorPlane: Plane;
  86581. /**
  86582. * Define the blur ratio used to blur the reflection if needed.
  86583. */
  86584. set blurRatio(value: number);
  86585. get blurRatio(): number;
  86586. /**
  86587. * Define the adaptive blur kernel used to blur the reflection if needed.
  86588. * This will autocompute the closest best match for the `blurKernel`
  86589. */
  86590. set adaptiveBlurKernel(value: number);
  86591. /**
  86592. * Define the blur kernel 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 blurKernel(value: number);
  86596. /**
  86597. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86599. */
  86600. set blurKernelX(value: number);
  86601. get blurKernelX(): number;
  86602. /**
  86603. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86604. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86605. */
  86606. set blurKernelY(value: number);
  86607. get blurKernelY(): number;
  86608. private _autoComputeBlurKernel;
  86609. protected _onRatioRescale(): void;
  86610. private _updateGammaSpace;
  86611. private _imageProcessingConfigChangeObserver;
  86612. private _transformMatrix;
  86613. private _mirrorMatrix;
  86614. private _savedViewMatrix;
  86615. private _blurX;
  86616. private _blurY;
  86617. private _adaptiveBlurKernel;
  86618. private _blurKernelX;
  86619. private _blurKernelY;
  86620. private _blurRatio;
  86621. /**
  86622. * Instantiates a Mirror Texture.
  86623. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86624. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86625. * You can then easily use it as a reflectionTexture on a flat surface.
  86626. * In case the surface is not a plane, please consider relying on reflection probes.
  86627. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86628. * @param name
  86629. * @param size
  86630. * @param scene
  86631. * @param generateMipMaps
  86632. * @param type
  86633. * @param samplingMode
  86634. * @param generateDepthBuffer
  86635. */
  86636. constructor(name: string, size: number | {
  86637. width: number;
  86638. height: number;
  86639. } | {
  86640. ratio: number;
  86641. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86642. private _preparePostProcesses;
  86643. /**
  86644. * Clone the mirror texture.
  86645. * @returns the cloned texture
  86646. */
  86647. clone(): MirrorTexture;
  86648. /**
  86649. * Serialize the texture to a JSON representation you could use in Parse later on
  86650. * @returns the serialized JSON representation
  86651. */
  86652. serialize(): any;
  86653. /**
  86654. * Dispose the texture and release its associated resources.
  86655. */
  86656. dispose(): void;
  86657. }
  86658. }
  86659. declare module BABYLON {
  86660. /**
  86661. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86662. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86663. */
  86664. export class Texture extends BaseTexture {
  86665. /**
  86666. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86667. */
  86668. static SerializeBuffers: boolean;
  86669. /** @hidden */
  86670. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86671. /** @hidden */
  86672. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86673. /** @hidden */
  86674. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86675. /** nearest is mag = nearest and min = nearest and mip = linear */
  86676. static readonly NEAREST_SAMPLINGMODE: number;
  86677. /** nearest is mag = nearest and min = nearest and mip = linear */
  86678. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86679. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86680. static readonly BILINEAR_SAMPLINGMODE: number;
  86681. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86682. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86683. /** Trilinear is mag = linear and min = linear and mip = linear */
  86684. static readonly TRILINEAR_SAMPLINGMODE: number;
  86685. /** Trilinear is mag = linear and min = linear and mip = linear */
  86686. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86687. /** mag = nearest and min = nearest and mip = nearest */
  86688. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86689. /** mag = nearest and min = linear and mip = nearest */
  86690. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86691. /** mag = nearest and min = linear and mip = linear */
  86692. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86693. /** mag = nearest and min = linear and mip = none */
  86694. static readonly NEAREST_LINEAR: number;
  86695. /** mag = nearest and min = nearest and mip = none */
  86696. static readonly NEAREST_NEAREST: number;
  86697. /** mag = linear and min = nearest and mip = nearest */
  86698. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86699. /** mag = linear and min = nearest and mip = linear */
  86700. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86701. /** mag = linear and min = linear and mip = none */
  86702. static readonly LINEAR_LINEAR: number;
  86703. /** mag = linear and min = nearest and mip = none */
  86704. static readonly LINEAR_NEAREST: number;
  86705. /** Explicit coordinates mode */
  86706. static readonly EXPLICIT_MODE: number;
  86707. /** Spherical coordinates mode */
  86708. static readonly SPHERICAL_MODE: number;
  86709. /** Planar coordinates mode */
  86710. static readonly PLANAR_MODE: number;
  86711. /** Cubic coordinates mode */
  86712. static readonly CUBIC_MODE: number;
  86713. /** Projection coordinates mode */
  86714. static readonly PROJECTION_MODE: number;
  86715. /** Inverse Cubic coordinates mode */
  86716. static readonly SKYBOX_MODE: number;
  86717. /** Inverse Cubic coordinates mode */
  86718. static readonly INVCUBIC_MODE: number;
  86719. /** Equirectangular coordinates mode */
  86720. static readonly EQUIRECTANGULAR_MODE: number;
  86721. /** Equirectangular Fixed coordinates mode */
  86722. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86723. /** Equirectangular Fixed Mirrored coordinates mode */
  86724. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86725. /** Texture is not repeating outside of 0..1 UVs */
  86726. static readonly CLAMP_ADDRESSMODE: number;
  86727. /** Texture is repeating outside of 0..1 UVs */
  86728. static readonly WRAP_ADDRESSMODE: number;
  86729. /** Texture is repeating and mirrored */
  86730. static readonly MIRROR_ADDRESSMODE: number;
  86731. /**
  86732. * 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
  86733. */
  86734. static UseSerializedUrlIfAny: boolean;
  86735. /**
  86736. * Define the url of the texture.
  86737. */
  86738. url: Nullable<string>;
  86739. /**
  86740. * Define an offset on the texture to offset the u coordinates of the UVs
  86741. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86742. */
  86743. uOffset: number;
  86744. /**
  86745. * Define an offset on the texture to offset the v coordinates of the UVs
  86746. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86747. */
  86748. vOffset: number;
  86749. /**
  86750. * Define an offset on the texture to scale the u coordinates of the UVs
  86751. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86752. */
  86753. uScale: number;
  86754. /**
  86755. * Define an offset on the texture to scale the v coordinates of the UVs
  86756. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86757. */
  86758. vScale: number;
  86759. /**
  86760. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86761. * @see http://doc.babylonjs.com/how_to/more_materials
  86762. */
  86763. uAng: number;
  86764. /**
  86765. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86766. * @see http://doc.babylonjs.com/how_to/more_materials
  86767. */
  86768. vAng: number;
  86769. /**
  86770. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86771. * @see http://doc.babylonjs.com/how_to/more_materials
  86772. */
  86773. wAng: number;
  86774. /**
  86775. * Defines the center of rotation (U)
  86776. */
  86777. uRotationCenter: number;
  86778. /**
  86779. * Defines the center of rotation (V)
  86780. */
  86781. vRotationCenter: number;
  86782. /**
  86783. * Defines the center of rotation (W)
  86784. */
  86785. wRotationCenter: number;
  86786. /**
  86787. * Are mip maps generated for this texture or not.
  86788. */
  86789. get noMipmap(): boolean;
  86790. /**
  86791. * List of inspectable custom properties (used by the Inspector)
  86792. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86793. */
  86794. inspectableCustomProperties: Nullable<IInspectable[]>;
  86795. private _noMipmap;
  86796. /** @hidden */
  86797. _invertY: boolean;
  86798. private _rowGenerationMatrix;
  86799. private _cachedTextureMatrix;
  86800. private _projectionModeMatrix;
  86801. private _t0;
  86802. private _t1;
  86803. private _t2;
  86804. private _cachedUOffset;
  86805. private _cachedVOffset;
  86806. private _cachedUScale;
  86807. private _cachedVScale;
  86808. private _cachedUAng;
  86809. private _cachedVAng;
  86810. private _cachedWAng;
  86811. private _cachedProjectionMatrixId;
  86812. private _cachedCoordinatesMode;
  86813. /** @hidden */
  86814. protected _initialSamplingMode: number;
  86815. /** @hidden */
  86816. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86817. private _deleteBuffer;
  86818. protected _format: Nullable<number>;
  86819. private _delayedOnLoad;
  86820. private _delayedOnError;
  86821. private _mimeType?;
  86822. /**
  86823. * Observable triggered once the texture has been loaded.
  86824. */
  86825. onLoadObservable: Observable<Texture>;
  86826. protected _isBlocking: boolean;
  86827. /**
  86828. * Is the texture preventing material to render while loading.
  86829. * If false, a default texture will be used instead of the loading one during the preparation step.
  86830. */
  86831. set isBlocking(value: boolean);
  86832. get isBlocking(): boolean;
  86833. /**
  86834. * Get the current sampling mode associated with the texture.
  86835. */
  86836. get samplingMode(): number;
  86837. /**
  86838. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86839. */
  86840. get invertY(): boolean;
  86841. /**
  86842. * Instantiates a new texture.
  86843. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86844. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86845. * @param url defines the url of the picture to load as a texture
  86846. * @param scene defines the scene or engine the texture will belong to
  86847. * @param noMipmap defines if the texture will require mip maps or not
  86848. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86849. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86850. * @param onLoad defines a callback triggered when the texture has been loaded
  86851. * @param onError defines a callback triggered when an error occurred during the loading session
  86852. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86853. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86854. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86855. * @param mimeType defines an optional mime type information
  86856. */
  86857. 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);
  86858. /**
  86859. * Update the url (and optional buffer) of this texture if url was null during construction.
  86860. * @param url the url of the texture
  86861. * @param buffer the buffer of the texture (defaults to null)
  86862. * @param onLoad callback called when the texture is loaded (defaults to null)
  86863. */
  86864. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86865. /**
  86866. * Finish the loading sequence of a texture flagged as delayed load.
  86867. * @hidden
  86868. */
  86869. delayLoad(): void;
  86870. private _prepareRowForTextureGeneration;
  86871. /**
  86872. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86873. * @returns the transform matrix of the texture.
  86874. */
  86875. getTextureMatrix(uBase?: number): Matrix;
  86876. /**
  86877. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86878. * @returns The reflection texture transform
  86879. */
  86880. getReflectionTextureMatrix(): Matrix;
  86881. /**
  86882. * Clones the texture.
  86883. * @returns the cloned texture
  86884. */
  86885. clone(): Texture;
  86886. /**
  86887. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86888. * @returns The JSON representation of the texture
  86889. */
  86890. serialize(): any;
  86891. /**
  86892. * Get the current class name of the texture useful for serialization or dynamic coding.
  86893. * @returns "Texture"
  86894. */
  86895. getClassName(): string;
  86896. /**
  86897. * Dispose the texture and release its associated resources.
  86898. */
  86899. dispose(): void;
  86900. /**
  86901. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86902. * @param parsedTexture Define the JSON representation of the texture
  86903. * @param scene Define the scene the parsed texture should be instantiated in
  86904. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86905. * @returns The parsed texture if successful
  86906. */
  86907. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86908. /**
  86909. * Creates a texture from its base 64 representation.
  86910. * @param data Define the base64 payload without the data: prefix
  86911. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86912. * @param scene Define the scene the texture should belong to
  86913. * @param noMipmap Forces the texture to not create mip map information if true
  86914. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86915. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86916. * @param onLoad define a callback triggered when the texture has been loaded
  86917. * @param onError define a callback triggered when an error occurred during the loading session
  86918. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86919. * @returns the created texture
  86920. */
  86921. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86922. /**
  86923. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86924. * @param data Define the base64 payload without the data: prefix
  86925. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86926. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86927. * @param scene Define the scene the texture should belong to
  86928. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86929. * @param noMipmap Forces the texture to not create mip map information if true
  86930. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86931. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86932. * @param onLoad define a callback triggered when the texture has been loaded
  86933. * @param onError define a callback triggered when an error occurred during the loading session
  86934. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86935. * @returns the created texture
  86936. */
  86937. 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;
  86938. }
  86939. }
  86940. declare module BABYLON {
  86941. /**
  86942. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86943. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86944. */
  86945. export class PostProcessManager {
  86946. private _scene;
  86947. private _indexBuffer;
  86948. private _vertexBuffers;
  86949. /**
  86950. * Creates a new instance PostProcess
  86951. * @param scene The scene that the post process is associated with.
  86952. */
  86953. constructor(scene: Scene);
  86954. private _prepareBuffers;
  86955. private _buildIndexBuffer;
  86956. /**
  86957. * Rebuilds the vertex buffers of the manager.
  86958. * @hidden
  86959. */
  86960. _rebuild(): void;
  86961. /**
  86962. * Prepares a frame to be run through a post process.
  86963. * @param sourceTexture The input texture to the post procesess. (default: null)
  86964. * @param postProcesses An array of post processes to be run. (default: null)
  86965. * @returns True if the post processes were able to be run.
  86966. * @hidden
  86967. */
  86968. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86969. /**
  86970. * Manually render a set of post processes to a texture.
  86971. * @param postProcesses An array of post processes to be run.
  86972. * @param targetTexture The target texture to render to.
  86973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86974. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86975. * @param lodLevel defines which lod of the texture to render to
  86976. */
  86977. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86978. /**
  86979. * Finalize the result of the output of the postprocesses.
  86980. * @param doNotPresent If true the result will not be displayed to the screen.
  86981. * @param targetTexture The target texture to render to.
  86982. * @param faceIndex The index of the face to bind the target texture to.
  86983. * @param postProcesses The array of post processes to render.
  86984. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86985. * @hidden
  86986. */
  86987. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86988. /**
  86989. * Disposes of the post process manager.
  86990. */
  86991. dispose(): void;
  86992. }
  86993. }
  86994. declare module BABYLON {
  86995. /** Interface used by value gradients (color, factor, ...) */
  86996. export interface IValueGradient {
  86997. /**
  86998. * Gets or sets the gradient value (between 0 and 1)
  86999. */
  87000. gradient: number;
  87001. }
  87002. /** Class used to store color4 gradient */
  87003. export class ColorGradient implements IValueGradient {
  87004. /**
  87005. * Gets or sets the gradient value (between 0 and 1)
  87006. */
  87007. gradient: number;
  87008. /**
  87009. * Gets or sets first associated color
  87010. */
  87011. color1: Color4;
  87012. /**
  87013. * Gets or sets second associated color
  87014. */
  87015. color2?: Color4;
  87016. /**
  87017. * Will get a color picked randomly between color1 and color2.
  87018. * If color2 is undefined then color1 will be used
  87019. * @param result defines the target Color4 to store the result in
  87020. */
  87021. getColorToRef(result: Color4): void;
  87022. }
  87023. /** Class used to store color 3 gradient */
  87024. export class Color3Gradient implements IValueGradient {
  87025. /**
  87026. * Gets or sets the gradient value (between 0 and 1)
  87027. */
  87028. gradient: number;
  87029. /**
  87030. * Gets or sets the associated color
  87031. */
  87032. color: Color3;
  87033. }
  87034. /** Class used to store factor gradient */
  87035. export class FactorGradient implements IValueGradient {
  87036. /**
  87037. * Gets or sets the gradient value (between 0 and 1)
  87038. */
  87039. gradient: number;
  87040. /**
  87041. * Gets or sets first associated factor
  87042. */
  87043. factor1: number;
  87044. /**
  87045. * Gets or sets second associated factor
  87046. */
  87047. factor2?: number;
  87048. /**
  87049. * Will get a number picked randomly between factor1 and factor2.
  87050. * If factor2 is undefined then factor1 will be used
  87051. * @returns the picked number
  87052. */
  87053. getFactor(): number;
  87054. }
  87055. /**
  87056. * Helper used to simplify some generic gradient tasks
  87057. */
  87058. export class GradientHelper {
  87059. /**
  87060. * Gets the current gradient from an array of IValueGradient
  87061. * @param ratio defines the current ratio to get
  87062. * @param gradients defines the array of IValueGradient
  87063. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87064. */
  87065. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87066. }
  87067. }
  87068. declare module BABYLON {
  87069. interface ThinEngine {
  87070. /**
  87071. * Creates a dynamic texture
  87072. * @param width defines the width of the texture
  87073. * @param height defines the height of the texture
  87074. * @param generateMipMaps defines if the engine should generate the mip levels
  87075. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87076. * @returns the dynamic texture inside an InternalTexture
  87077. */
  87078. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87079. /**
  87080. * Update the content of a dynamic texture
  87081. * @param texture defines the texture to update
  87082. * @param canvas defines the canvas containing the source
  87083. * @param invertY defines if data must be stored with Y axis inverted
  87084. * @param premulAlpha defines if alpha is stored as premultiplied
  87085. * @param format defines the format of the data
  87086. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87087. */
  87088. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87089. }
  87090. }
  87091. declare module BABYLON {
  87092. /**
  87093. * Helper class used to generate a canvas to manipulate images
  87094. */
  87095. export class CanvasGenerator {
  87096. /**
  87097. * Create a new canvas (or offscreen canvas depending on the context)
  87098. * @param width defines the expected width
  87099. * @param height defines the expected height
  87100. * @return a new canvas or offscreen canvas
  87101. */
  87102. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87103. }
  87104. }
  87105. declare module BABYLON {
  87106. /**
  87107. * A class extending Texture allowing drawing on a texture
  87108. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87109. */
  87110. export class DynamicTexture extends Texture {
  87111. private _generateMipMaps;
  87112. private _canvas;
  87113. private _context;
  87114. private _engine;
  87115. /**
  87116. * Creates a DynamicTexture
  87117. * @param name defines the name of the texture
  87118. * @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
  87119. * @param scene defines the scene where you want the texture
  87120. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87121. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87122. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87123. */
  87124. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87125. /**
  87126. * Get the current class name of the texture useful for serialization or dynamic coding.
  87127. * @returns "DynamicTexture"
  87128. */
  87129. getClassName(): string;
  87130. /**
  87131. * Gets the current state of canRescale
  87132. */
  87133. get canRescale(): boolean;
  87134. private _recreate;
  87135. /**
  87136. * Scales the texture
  87137. * @param ratio the scale factor to apply to both width and height
  87138. */
  87139. scale(ratio: number): void;
  87140. /**
  87141. * Resizes the texture
  87142. * @param width the new width
  87143. * @param height the new height
  87144. */
  87145. scaleTo(width: number, height: number): void;
  87146. /**
  87147. * Gets the context of the canvas used by the texture
  87148. * @returns the canvas context of the dynamic texture
  87149. */
  87150. getContext(): CanvasRenderingContext2D;
  87151. /**
  87152. * Clears the texture
  87153. */
  87154. clear(): void;
  87155. /**
  87156. * Updates the texture
  87157. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87158. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87159. */
  87160. update(invertY?: boolean, premulAlpha?: boolean): void;
  87161. /**
  87162. * Draws text onto the texture
  87163. * @param text defines the text to be drawn
  87164. * @param x defines the placement of the text from the left
  87165. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87166. * @param font defines the font to be used with font-style, font-size, font-name
  87167. * @param color defines the color used for the text
  87168. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87169. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87170. * @param update defines whether texture is immediately update (default is true)
  87171. */
  87172. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87173. /**
  87174. * Clones the texture
  87175. * @returns the clone of the texture.
  87176. */
  87177. clone(): DynamicTexture;
  87178. /**
  87179. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87180. * @returns a serialized dynamic texture object
  87181. */
  87182. serialize(): any;
  87183. /** @hidden */
  87184. _rebuild(): void;
  87185. }
  87186. }
  87187. declare module BABYLON {
  87188. interface AbstractScene {
  87189. /**
  87190. * The list of procedural textures added to the scene
  87191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87192. */
  87193. proceduralTextures: Array<ProceduralTexture>;
  87194. }
  87195. /**
  87196. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87197. * in a given scene.
  87198. */
  87199. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87200. /**
  87201. * The component name helpfull to identify the component in the list of scene components.
  87202. */
  87203. readonly name: string;
  87204. /**
  87205. * The scene the component belongs to.
  87206. */
  87207. scene: Scene;
  87208. /**
  87209. * Creates a new instance of the component for the given scene
  87210. * @param scene Defines the scene to register the component in
  87211. */
  87212. constructor(scene: Scene);
  87213. /**
  87214. * Registers the component in a given scene
  87215. */
  87216. register(): void;
  87217. /**
  87218. * Rebuilds the elements related to this component in case of
  87219. * context lost for instance.
  87220. */
  87221. rebuild(): void;
  87222. /**
  87223. * Disposes the component and the associated ressources.
  87224. */
  87225. dispose(): void;
  87226. private _beforeClear;
  87227. }
  87228. }
  87229. declare module BABYLON {
  87230. interface ThinEngine {
  87231. /**
  87232. * Creates a new render target cube texture
  87233. * @param size defines the size of the texture
  87234. * @param options defines the options used to create the texture
  87235. * @returns a new render target cube texture stored in an InternalTexture
  87236. */
  87237. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87238. }
  87239. }
  87240. declare module BABYLON {
  87241. /** @hidden */
  87242. export var proceduralVertexShader: {
  87243. name: string;
  87244. shader: string;
  87245. };
  87246. }
  87247. declare module BABYLON {
  87248. /**
  87249. * 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.
  87250. * This is the base class of any Procedural texture and contains most of the shareable code.
  87251. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87252. */
  87253. export class ProceduralTexture extends Texture {
  87254. isCube: boolean;
  87255. /**
  87256. * Define if the texture is enabled or not (disabled texture will not render)
  87257. */
  87258. isEnabled: boolean;
  87259. /**
  87260. * Define if the texture must be cleared before rendering (default is true)
  87261. */
  87262. autoClear: boolean;
  87263. /**
  87264. * Callback called when the texture is generated
  87265. */
  87266. onGenerated: () => void;
  87267. /**
  87268. * Event raised when the texture is generated
  87269. */
  87270. onGeneratedObservable: Observable<ProceduralTexture>;
  87271. /** @hidden */
  87272. _generateMipMaps: boolean;
  87273. /** @hidden **/
  87274. _effect: Effect;
  87275. /** @hidden */
  87276. _textures: {
  87277. [key: string]: Texture;
  87278. };
  87279. private _size;
  87280. private _currentRefreshId;
  87281. private _frameId;
  87282. private _refreshRate;
  87283. private _vertexBuffers;
  87284. private _indexBuffer;
  87285. private _uniforms;
  87286. private _samplers;
  87287. private _fragment;
  87288. private _floats;
  87289. private _ints;
  87290. private _floatsArrays;
  87291. private _colors3;
  87292. private _colors4;
  87293. private _vectors2;
  87294. private _vectors3;
  87295. private _matrices;
  87296. private _fallbackTexture;
  87297. private _fallbackTextureUsed;
  87298. private _engine;
  87299. private _cachedDefines;
  87300. private _contentUpdateId;
  87301. private _contentData;
  87302. /**
  87303. * Instantiates a new procedural texture.
  87304. * 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.
  87305. * This is the base class of any Procedural texture and contains most of the shareable code.
  87306. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87307. * @param name Define the name of the texture
  87308. * @param size Define the size of the texture to create
  87309. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87310. * @param scene Define the scene the texture belongs to
  87311. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87312. * @param generateMipMaps Define if the texture should creates mip maps or not
  87313. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87314. */
  87315. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87316. /**
  87317. * The effect that is created when initializing the post process.
  87318. * @returns The created effect corresponding the the postprocess.
  87319. */
  87320. getEffect(): Effect;
  87321. /**
  87322. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87323. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87324. */
  87325. getContent(): Nullable<ArrayBufferView>;
  87326. private _createIndexBuffer;
  87327. /** @hidden */
  87328. _rebuild(): void;
  87329. /**
  87330. * Resets the texture in order to recreate its associated resources.
  87331. * This can be called in case of context loss
  87332. */
  87333. reset(): void;
  87334. protected _getDefines(): string;
  87335. /**
  87336. * Is the texture ready to be used ? (rendered at least once)
  87337. * @returns true if ready, otherwise, false.
  87338. */
  87339. isReady(): boolean;
  87340. /**
  87341. * Resets the refresh counter of the texture and start bak from scratch.
  87342. * Could be useful to regenerate the texture if it is setup to render only once.
  87343. */
  87344. resetRefreshCounter(): void;
  87345. /**
  87346. * Set the fragment shader to use in order to render the texture.
  87347. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87348. */
  87349. setFragment(fragment: any): void;
  87350. /**
  87351. * Define the refresh rate of the texture or the rendering frequency.
  87352. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87353. */
  87354. get refreshRate(): number;
  87355. set refreshRate(value: number);
  87356. /** @hidden */
  87357. _shouldRender(): boolean;
  87358. /**
  87359. * Get the size the texture is rendering at.
  87360. * @returns the size (texture is always squared)
  87361. */
  87362. getRenderSize(): number;
  87363. /**
  87364. * Resize the texture to new value.
  87365. * @param size Define the new size the texture should have
  87366. * @param generateMipMaps Define whether the new texture should create mip maps
  87367. */
  87368. resize(size: number, generateMipMaps: boolean): void;
  87369. private _checkUniform;
  87370. /**
  87371. * Set a texture in the shader program used to render.
  87372. * @param name Define the name of the uniform samplers as defined in the shader
  87373. * @param texture Define the texture to bind to this sampler
  87374. * @return the texture itself allowing "fluent" like uniform updates
  87375. */
  87376. setTexture(name: string, texture: Texture): ProceduralTexture;
  87377. /**
  87378. * Set a float in the shader.
  87379. * @param name Define the name of the uniform as defined in the shader
  87380. * @param value Define the value to give to the uniform
  87381. * @return the texture itself allowing "fluent" like uniform updates
  87382. */
  87383. setFloat(name: string, value: number): ProceduralTexture;
  87384. /**
  87385. * Set a int in the shader.
  87386. * @param name Define the name of the uniform as defined in the shader
  87387. * @param value Define the value to give to the uniform
  87388. * @return the texture itself allowing "fluent" like uniform updates
  87389. */
  87390. setInt(name: string, value: number): ProceduralTexture;
  87391. /**
  87392. * Set an array of floats in the shader.
  87393. * @param name Define the name of the uniform as defined in the shader
  87394. * @param value Define the value to give to the uniform
  87395. * @return the texture itself allowing "fluent" like uniform updates
  87396. */
  87397. setFloats(name: string, value: number[]): ProceduralTexture;
  87398. /**
  87399. * Set a vec3 in the shader from a Color3.
  87400. * @param name Define the name of the uniform as defined in the shader
  87401. * @param value Define the value to give to the uniform
  87402. * @return the texture itself allowing "fluent" like uniform updates
  87403. */
  87404. setColor3(name: string, value: Color3): ProceduralTexture;
  87405. /**
  87406. * Set a vec4 in the shader from a Color4.
  87407. * @param name Define the name of the uniform as defined in the shader
  87408. * @param value Define the value to give to the uniform
  87409. * @return the texture itself allowing "fluent" like uniform updates
  87410. */
  87411. setColor4(name: string, value: Color4): ProceduralTexture;
  87412. /**
  87413. * Set a vec2 in the shader from a Vector2.
  87414. * @param name Define the name of the uniform as defined in the shader
  87415. * @param value Define the value to give to the uniform
  87416. * @return the texture itself allowing "fluent" like uniform updates
  87417. */
  87418. setVector2(name: string, value: Vector2): ProceduralTexture;
  87419. /**
  87420. * Set a vec3 in the shader from a Vector3.
  87421. * @param name Define the name of the uniform as defined in the shader
  87422. * @param value Define the value to give to the uniform
  87423. * @return the texture itself allowing "fluent" like uniform updates
  87424. */
  87425. setVector3(name: string, value: Vector3): ProceduralTexture;
  87426. /**
  87427. * Set a mat4 in the shader from a MAtrix.
  87428. * @param name Define the name of the uniform as defined in the shader
  87429. * @param value Define the value to give to the uniform
  87430. * @return the texture itself allowing "fluent" like uniform updates
  87431. */
  87432. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87433. /**
  87434. * Render the texture to its associated render target.
  87435. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87436. */
  87437. render(useCameraPostProcess?: boolean): void;
  87438. /**
  87439. * Clone the texture.
  87440. * @returns the cloned texture
  87441. */
  87442. clone(): ProceduralTexture;
  87443. /**
  87444. * Dispose the texture and release its asoociated resources.
  87445. */
  87446. dispose(): void;
  87447. }
  87448. }
  87449. declare module BABYLON {
  87450. /**
  87451. * This represents the base class for particle system in Babylon.
  87452. * 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.
  87453. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87454. * @example https://doc.babylonjs.com/babylon101/particles
  87455. */
  87456. export class BaseParticleSystem {
  87457. /**
  87458. * Source color is added to the destination color without alpha affecting the result
  87459. */
  87460. static BLENDMODE_ONEONE: number;
  87461. /**
  87462. * Blend current color and particle color using particle’s alpha
  87463. */
  87464. static BLENDMODE_STANDARD: number;
  87465. /**
  87466. * Add current color and particle color multiplied by particle’s alpha
  87467. */
  87468. static BLENDMODE_ADD: number;
  87469. /**
  87470. * Multiply current color with particle color
  87471. */
  87472. static BLENDMODE_MULTIPLY: number;
  87473. /**
  87474. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87475. */
  87476. static BLENDMODE_MULTIPLYADD: number;
  87477. /**
  87478. * List of animations used by the particle system.
  87479. */
  87480. animations: Animation[];
  87481. /**
  87482. * The id of the Particle system.
  87483. */
  87484. id: string;
  87485. /**
  87486. * The friendly name of the Particle system.
  87487. */
  87488. name: string;
  87489. /**
  87490. * The rendering group used by the Particle system to chose when to render.
  87491. */
  87492. renderingGroupId: number;
  87493. /**
  87494. * The emitter represents the Mesh or position we are attaching the particle system to.
  87495. */
  87496. emitter: Nullable<AbstractMesh | Vector3>;
  87497. /**
  87498. * The maximum number of particles to emit per frame
  87499. */
  87500. emitRate: number;
  87501. /**
  87502. * If you want to launch only a few particles at once, that can be done, as well.
  87503. */
  87504. manualEmitCount: number;
  87505. /**
  87506. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87507. */
  87508. updateSpeed: number;
  87509. /**
  87510. * The amount of time the particle system is running (depends of the overall update speed).
  87511. */
  87512. targetStopDuration: number;
  87513. /**
  87514. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87515. */
  87516. disposeOnStop: boolean;
  87517. /**
  87518. * Minimum power of emitting particles.
  87519. */
  87520. minEmitPower: number;
  87521. /**
  87522. * Maximum power of emitting particles.
  87523. */
  87524. maxEmitPower: number;
  87525. /**
  87526. * Minimum life time of emitting particles.
  87527. */
  87528. minLifeTime: number;
  87529. /**
  87530. * Maximum life time of emitting particles.
  87531. */
  87532. maxLifeTime: number;
  87533. /**
  87534. * Minimum Size of emitting particles.
  87535. */
  87536. minSize: number;
  87537. /**
  87538. * Maximum Size of emitting particles.
  87539. */
  87540. maxSize: number;
  87541. /**
  87542. * Minimum scale of emitting particles on X axis.
  87543. */
  87544. minScaleX: number;
  87545. /**
  87546. * Maximum scale of emitting particles on X axis.
  87547. */
  87548. maxScaleX: number;
  87549. /**
  87550. * Minimum scale of emitting particles on Y axis.
  87551. */
  87552. minScaleY: number;
  87553. /**
  87554. * Maximum scale of emitting particles on Y axis.
  87555. */
  87556. maxScaleY: number;
  87557. /**
  87558. * Gets or sets the minimal initial rotation in radians.
  87559. */
  87560. minInitialRotation: number;
  87561. /**
  87562. * Gets or sets the maximal initial rotation in radians.
  87563. */
  87564. maxInitialRotation: number;
  87565. /**
  87566. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87567. */
  87568. minAngularSpeed: number;
  87569. /**
  87570. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87571. */
  87572. maxAngularSpeed: number;
  87573. /**
  87574. * The texture used to render each particle. (this can be a spritesheet)
  87575. */
  87576. particleTexture: Nullable<Texture>;
  87577. /**
  87578. * The layer mask we are rendering the particles through.
  87579. */
  87580. layerMask: number;
  87581. /**
  87582. * This can help using your own shader to render the particle system.
  87583. * The according effect will be created
  87584. */
  87585. customShader: any;
  87586. /**
  87587. * By default particle system starts as soon as they are created. This prevents the
  87588. * automatic start to happen and let you decide when to start emitting particles.
  87589. */
  87590. preventAutoStart: boolean;
  87591. private _noiseTexture;
  87592. /**
  87593. * Gets or sets a texture used to add random noise to particle positions
  87594. */
  87595. get noiseTexture(): Nullable<ProceduralTexture>;
  87596. set noiseTexture(value: Nullable<ProceduralTexture>);
  87597. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87598. noiseStrength: Vector3;
  87599. /**
  87600. * Callback triggered when the particle animation is ending.
  87601. */
  87602. onAnimationEnd: Nullable<() => void>;
  87603. /**
  87604. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87605. */
  87606. blendMode: number;
  87607. /**
  87608. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87609. * to override the particles.
  87610. */
  87611. forceDepthWrite: boolean;
  87612. /** 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 */
  87613. preWarmCycles: number;
  87614. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87615. preWarmStepOffset: number;
  87616. /**
  87617. * 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)
  87618. */
  87619. spriteCellChangeSpeed: number;
  87620. /**
  87621. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87622. */
  87623. startSpriteCellID: number;
  87624. /**
  87625. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87626. */
  87627. endSpriteCellID: number;
  87628. /**
  87629. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87630. */
  87631. spriteCellWidth: number;
  87632. /**
  87633. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87634. */
  87635. spriteCellHeight: number;
  87636. /**
  87637. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87638. */
  87639. spriteRandomStartCell: boolean;
  87640. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87641. translationPivot: Vector2;
  87642. /** @hidden */
  87643. protected _isAnimationSheetEnabled: boolean;
  87644. /**
  87645. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87646. */
  87647. beginAnimationOnStart: boolean;
  87648. /**
  87649. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87650. */
  87651. beginAnimationFrom: number;
  87652. /**
  87653. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87654. */
  87655. beginAnimationTo: number;
  87656. /**
  87657. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87658. */
  87659. beginAnimationLoop: boolean;
  87660. /**
  87661. * Gets or sets a world offset applied to all particles
  87662. */
  87663. worldOffset: Vector3;
  87664. /**
  87665. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87666. */
  87667. get isAnimationSheetEnabled(): boolean;
  87668. set isAnimationSheetEnabled(value: boolean);
  87669. /**
  87670. * Get hosting scene
  87671. * @returns the scene
  87672. */
  87673. getScene(): Scene;
  87674. /**
  87675. * You can use gravity if you want to give an orientation to your particles.
  87676. */
  87677. gravity: Vector3;
  87678. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87679. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87680. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87681. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87682. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87683. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87684. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87685. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87686. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87687. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87688. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87689. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87690. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87691. /**
  87692. * Defines the delay in milliseconds before starting the system (0 by default)
  87693. */
  87694. startDelay: number;
  87695. /**
  87696. * Gets the current list of drag gradients.
  87697. * You must use addDragGradient and removeDragGradient to udpate this list
  87698. * @returns the list of drag gradients
  87699. */
  87700. getDragGradients(): Nullable<Array<FactorGradient>>;
  87701. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87702. limitVelocityDamping: number;
  87703. /**
  87704. * Gets the current list of limit velocity gradients.
  87705. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87706. * @returns the list of limit velocity gradients
  87707. */
  87708. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87709. /**
  87710. * Gets the current list of color gradients.
  87711. * You must use addColorGradient and removeColorGradient to udpate this list
  87712. * @returns the list of color gradients
  87713. */
  87714. getColorGradients(): Nullable<Array<ColorGradient>>;
  87715. /**
  87716. * Gets the current list of size gradients.
  87717. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87718. * @returns the list of size gradients
  87719. */
  87720. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87721. /**
  87722. * Gets the current list of color remap gradients.
  87723. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87724. * @returns the list of color remap gradients
  87725. */
  87726. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87727. /**
  87728. * Gets the current list of alpha remap gradients.
  87729. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87730. * @returns the list of alpha remap gradients
  87731. */
  87732. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87733. /**
  87734. * Gets the current list of life time gradients.
  87735. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87736. * @returns the list of life time gradients
  87737. */
  87738. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87739. /**
  87740. * Gets the current list of angular speed gradients.
  87741. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87742. * @returns the list of angular speed gradients
  87743. */
  87744. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87745. /**
  87746. * Gets the current list of velocity gradients.
  87747. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87748. * @returns the list of velocity gradients
  87749. */
  87750. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87751. /**
  87752. * Gets the current list of start size gradients.
  87753. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87754. * @returns the list of start size gradients
  87755. */
  87756. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87757. /**
  87758. * Gets the current list of emit rate gradients.
  87759. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87760. * @returns the list of emit rate gradients
  87761. */
  87762. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87763. /**
  87764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87765. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87766. */
  87767. get direction1(): Vector3;
  87768. set direction1(value: Vector3);
  87769. /**
  87770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87771. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87772. */
  87773. get direction2(): Vector3;
  87774. set direction2(value: Vector3);
  87775. /**
  87776. * 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.
  87777. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87778. */
  87779. get minEmitBox(): Vector3;
  87780. set minEmitBox(value: Vector3);
  87781. /**
  87782. * 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.
  87783. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87784. */
  87785. get maxEmitBox(): Vector3;
  87786. set maxEmitBox(value: Vector3);
  87787. /**
  87788. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87789. */
  87790. color1: Color4;
  87791. /**
  87792. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87793. */
  87794. color2: Color4;
  87795. /**
  87796. * Color the particle will have at the end of its lifetime
  87797. */
  87798. colorDead: Color4;
  87799. /**
  87800. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87801. */
  87802. textureMask: Color4;
  87803. /**
  87804. * The particle emitter type defines the emitter used by the particle system.
  87805. * It can be for example box, sphere, or cone...
  87806. */
  87807. particleEmitterType: IParticleEmitterType;
  87808. /** @hidden */
  87809. _isSubEmitter: boolean;
  87810. /**
  87811. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87812. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87813. */
  87814. billboardMode: number;
  87815. protected _isBillboardBased: boolean;
  87816. /**
  87817. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87818. */
  87819. get isBillboardBased(): boolean;
  87820. set isBillboardBased(value: boolean);
  87821. /**
  87822. * The scene the particle system belongs to.
  87823. */
  87824. protected _scene: Scene;
  87825. /**
  87826. * Local cache of defines for image processing.
  87827. */
  87828. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87829. /**
  87830. * Default configuration related to image processing available in the standard Material.
  87831. */
  87832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87833. /**
  87834. * Gets the image processing configuration used either in this material.
  87835. */
  87836. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87837. /**
  87838. * Sets the Default image processing configuration used either in the this material.
  87839. *
  87840. * If sets to null, the scene one is in use.
  87841. */
  87842. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87843. /**
  87844. * Attaches a new image processing configuration to the Standard Material.
  87845. * @param configuration
  87846. */
  87847. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87848. /** @hidden */
  87849. protected _reset(): void;
  87850. /** @hidden */
  87851. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87852. /**
  87853. * Instantiates a particle system.
  87854. * 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.
  87855. * @param name The name of the particle system
  87856. */
  87857. constructor(name: string);
  87858. /**
  87859. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87862. * @returns the emitter
  87863. */
  87864. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87865. /**
  87866. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87867. * @param radius The radius of the hemisphere to emit from
  87868. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87869. * @returns the emitter
  87870. */
  87871. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87872. /**
  87873. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87874. * @param radius The radius of the sphere to emit from
  87875. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87876. * @returns the emitter
  87877. */
  87878. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87879. /**
  87880. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87881. * @param radius The radius of the sphere to emit from
  87882. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87883. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87884. * @returns the emitter
  87885. */
  87886. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87887. /**
  87888. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87889. * @param radius The radius of the emission cylinder
  87890. * @param height The height of the emission cylinder
  87891. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87892. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87893. * @returns the emitter
  87894. */
  87895. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87896. /**
  87897. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87898. * @param radius The radius of the cylinder to emit from
  87899. * @param height The height of the emission cylinder
  87900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87903. * @returns the emitter
  87904. */
  87905. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87906. /**
  87907. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87908. * @param radius The radius of the cone to emit from
  87909. * @param angle The base angle of the cone
  87910. * @returns the emitter
  87911. */
  87912. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87913. /**
  87914. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87917. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87918. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87919. * @returns the emitter
  87920. */
  87921. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /**
  87926. * Type of sub emitter
  87927. */
  87928. export enum SubEmitterType {
  87929. /**
  87930. * Attached to the particle over it's lifetime
  87931. */
  87932. ATTACHED = 0,
  87933. /**
  87934. * Created when the particle dies
  87935. */
  87936. END = 1
  87937. }
  87938. /**
  87939. * Sub emitter class used to emit particles from an existing particle
  87940. */
  87941. export class SubEmitter {
  87942. /**
  87943. * the particle system to be used by the sub emitter
  87944. */
  87945. particleSystem: ParticleSystem;
  87946. /**
  87947. * Type of the submitter (Default: END)
  87948. */
  87949. type: SubEmitterType;
  87950. /**
  87951. * 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)
  87952. * Note: This only is supported when using an emitter of type Mesh
  87953. */
  87954. inheritDirection: boolean;
  87955. /**
  87956. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87957. */
  87958. inheritedVelocityAmount: number;
  87959. /**
  87960. * Creates a sub emitter
  87961. * @param particleSystem the particle system to be used by the sub emitter
  87962. */
  87963. constructor(
  87964. /**
  87965. * the particle system to be used by the sub emitter
  87966. */
  87967. particleSystem: ParticleSystem);
  87968. /**
  87969. * Clones the sub emitter
  87970. * @returns the cloned sub emitter
  87971. */
  87972. clone(): SubEmitter;
  87973. /**
  87974. * Serialize current object to a JSON object
  87975. * @returns the serialized object
  87976. */
  87977. serialize(): any;
  87978. /** @hidden */
  87979. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87980. /**
  87981. * Creates a new SubEmitter from a serialized JSON version
  87982. * @param serializationObject defines the JSON object to read from
  87983. * @param scene defines the hosting scene
  87984. * @param rootUrl defines the rootUrl for data loading
  87985. * @returns a new SubEmitter
  87986. */
  87987. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87988. /** Release associated resources */
  87989. dispose(): void;
  87990. }
  87991. }
  87992. declare module BABYLON {
  87993. /** @hidden */
  87994. export var clipPlaneFragmentDeclaration: {
  87995. name: string;
  87996. shader: string;
  87997. };
  87998. }
  87999. declare module BABYLON {
  88000. /** @hidden */
  88001. export var imageProcessingDeclaration: {
  88002. name: string;
  88003. shader: string;
  88004. };
  88005. }
  88006. declare module BABYLON {
  88007. /** @hidden */
  88008. export var imageProcessingFunctions: {
  88009. name: string;
  88010. shader: string;
  88011. };
  88012. }
  88013. declare module BABYLON {
  88014. /** @hidden */
  88015. export var clipPlaneFragment: {
  88016. name: string;
  88017. shader: string;
  88018. };
  88019. }
  88020. declare module BABYLON {
  88021. /** @hidden */
  88022. export var particlesPixelShader: {
  88023. name: string;
  88024. shader: string;
  88025. };
  88026. }
  88027. declare module BABYLON {
  88028. /** @hidden */
  88029. export var clipPlaneVertexDeclaration: {
  88030. name: string;
  88031. shader: string;
  88032. };
  88033. }
  88034. declare module BABYLON {
  88035. /** @hidden */
  88036. export var clipPlaneVertex: {
  88037. name: string;
  88038. shader: string;
  88039. };
  88040. }
  88041. declare module BABYLON {
  88042. /** @hidden */
  88043. export var particlesVertexShader: {
  88044. name: string;
  88045. shader: string;
  88046. };
  88047. }
  88048. declare module BABYLON {
  88049. /**
  88050. * This represents a particle system in Babylon.
  88051. * 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.
  88052. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88053. * @example https://doc.babylonjs.com/babylon101/particles
  88054. */
  88055. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88056. /**
  88057. * Billboard mode will only apply to Y axis
  88058. */
  88059. static readonly BILLBOARDMODE_Y: number;
  88060. /**
  88061. * Billboard mode will apply to all axes
  88062. */
  88063. static readonly BILLBOARDMODE_ALL: number;
  88064. /**
  88065. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88066. */
  88067. static readonly BILLBOARDMODE_STRETCHED: number;
  88068. /**
  88069. * This function can be defined to provide custom update for active particles.
  88070. * This function will be called instead of regular update (age, position, color, etc.).
  88071. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88072. */
  88073. updateFunction: (particles: Particle[]) => void;
  88074. private _emitterWorldMatrix;
  88075. /**
  88076. * This function can be defined to specify initial direction for every new particle.
  88077. * It by default use the emitterType defined function
  88078. */
  88079. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88080. /**
  88081. * This function can be defined to specify initial position for every new particle.
  88082. * It by default use the emitterType defined function
  88083. */
  88084. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88085. /**
  88086. * @hidden
  88087. */
  88088. _inheritedVelocityOffset: Vector3;
  88089. /**
  88090. * An event triggered when the system is disposed
  88091. */
  88092. onDisposeObservable: Observable<ParticleSystem>;
  88093. private _onDisposeObserver;
  88094. /**
  88095. * Sets a callback that will be triggered when the system is disposed
  88096. */
  88097. set onDispose(callback: () => void);
  88098. private _particles;
  88099. private _epsilon;
  88100. private _capacity;
  88101. private _stockParticles;
  88102. private _newPartsExcess;
  88103. private _vertexData;
  88104. private _vertexBuffer;
  88105. private _vertexBuffers;
  88106. private _spriteBuffer;
  88107. private _indexBuffer;
  88108. private _effect;
  88109. private _customEffect;
  88110. private _cachedDefines;
  88111. private _scaledColorStep;
  88112. private _colorDiff;
  88113. private _scaledDirection;
  88114. private _scaledGravity;
  88115. private _currentRenderId;
  88116. private _alive;
  88117. private _useInstancing;
  88118. private _started;
  88119. private _stopped;
  88120. private _actualFrame;
  88121. private _scaledUpdateSpeed;
  88122. private _vertexBufferSize;
  88123. /** @hidden */
  88124. _currentEmitRateGradient: Nullable<FactorGradient>;
  88125. /** @hidden */
  88126. _currentEmitRate1: number;
  88127. /** @hidden */
  88128. _currentEmitRate2: number;
  88129. /** @hidden */
  88130. _currentStartSizeGradient: Nullable<FactorGradient>;
  88131. /** @hidden */
  88132. _currentStartSize1: number;
  88133. /** @hidden */
  88134. _currentStartSize2: number;
  88135. private readonly _rawTextureWidth;
  88136. private _rampGradientsTexture;
  88137. private _useRampGradients;
  88138. /** Gets or sets a boolean indicating that ramp gradients must be used
  88139. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88140. */
  88141. get useRampGradients(): boolean;
  88142. set useRampGradients(value: boolean);
  88143. /**
  88144. * 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.
  88145. * 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: [])
  88146. */
  88147. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88148. private _subEmitters;
  88149. /**
  88150. * @hidden
  88151. * If the particle systems emitter should be disposed when the particle system is disposed
  88152. */
  88153. _disposeEmitterOnDispose: boolean;
  88154. /**
  88155. * The current active Sub-systems, this property is used by the root particle system only.
  88156. */
  88157. activeSubSystems: Array<ParticleSystem>;
  88158. private _rootParticleSystem;
  88159. /**
  88160. * Gets the current list of active particles
  88161. */
  88162. get particles(): Particle[];
  88163. /**
  88164. * Returns the string "ParticleSystem"
  88165. * @returns a string containing the class name
  88166. */
  88167. getClassName(): string;
  88168. /**
  88169. * Instantiates a particle system.
  88170. * 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.
  88171. * @param name The name of the particle system
  88172. * @param capacity The max number of particles alive at the same time
  88173. * @param scene The scene the particle system belongs to
  88174. * @param customEffect a custom effect used to change the way particles are rendered by default
  88175. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88176. * @param epsilon Offset used to render the particles
  88177. */
  88178. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88179. private _addFactorGradient;
  88180. private _removeFactorGradient;
  88181. /**
  88182. * Adds a new life time gradient
  88183. * @param gradient defines the gradient to use (between 0 and 1)
  88184. * @param factor defines the life time factor to affect to the specified gradient
  88185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88186. * @returns the current particle system
  88187. */
  88188. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88189. /**
  88190. * Remove a specific life time gradient
  88191. * @param gradient defines the gradient to remove
  88192. * @returns the current particle system
  88193. */
  88194. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88195. /**
  88196. * Adds a new size gradient
  88197. * @param gradient defines the gradient to use (between 0 and 1)
  88198. * @param factor defines the size factor to affect to the specified gradient
  88199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88200. * @returns the current particle system
  88201. */
  88202. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88203. /**
  88204. * Remove a specific size gradient
  88205. * @param gradient defines the gradient to remove
  88206. * @returns the current particle system
  88207. */
  88208. removeSizeGradient(gradient: number): IParticleSystem;
  88209. /**
  88210. * Adds a new color remap gradient
  88211. * @param gradient defines the gradient to use (between 0 and 1)
  88212. * @param min defines the color remap minimal range
  88213. * @param max defines the color remap maximal range
  88214. * @returns the current particle system
  88215. */
  88216. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88217. /**
  88218. * Remove a specific color remap gradient
  88219. * @param gradient defines the gradient to remove
  88220. * @returns the current particle system
  88221. */
  88222. removeColorRemapGradient(gradient: number): IParticleSystem;
  88223. /**
  88224. * Adds a new alpha remap gradient
  88225. * @param gradient defines the gradient to use (between 0 and 1)
  88226. * @param min defines the alpha remap minimal range
  88227. * @param max defines the alpha remap maximal range
  88228. * @returns the current particle system
  88229. */
  88230. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88231. /**
  88232. * Remove a specific alpha remap gradient
  88233. * @param gradient defines the gradient to remove
  88234. * @returns the current particle system
  88235. */
  88236. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88237. /**
  88238. * Adds a new angular speed gradient
  88239. * @param gradient defines the gradient to use (between 0 and 1)
  88240. * @param factor defines the angular speed to affect to the specified gradient
  88241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88242. * @returns the current particle system
  88243. */
  88244. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88245. /**
  88246. * Remove a specific angular speed gradient
  88247. * @param gradient defines the gradient to remove
  88248. * @returns the current particle system
  88249. */
  88250. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88251. /**
  88252. * Adds a new velocity gradient
  88253. * @param gradient defines the gradient to use (between 0 and 1)
  88254. * @param factor defines the velocity to affect to the specified gradient
  88255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88256. * @returns the current particle system
  88257. */
  88258. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88259. /**
  88260. * Remove a specific velocity gradient
  88261. * @param gradient defines the gradient to remove
  88262. * @returns the current particle system
  88263. */
  88264. removeVelocityGradient(gradient: number): IParticleSystem;
  88265. /**
  88266. * Adds a new limit velocity gradient
  88267. * @param gradient defines the gradient to use (between 0 and 1)
  88268. * @param factor defines the limit velocity value to affect to the specified gradient
  88269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88270. * @returns the current particle system
  88271. */
  88272. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88273. /**
  88274. * Remove a specific limit velocity gradient
  88275. * @param gradient defines the gradient to remove
  88276. * @returns the current particle system
  88277. */
  88278. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88279. /**
  88280. * Adds a new drag gradient
  88281. * @param gradient defines the gradient to use (between 0 and 1)
  88282. * @param factor defines the drag value to affect to the specified gradient
  88283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88284. * @returns the current particle system
  88285. */
  88286. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88287. /**
  88288. * Remove a specific drag gradient
  88289. * @param gradient defines the gradient to remove
  88290. * @returns the current particle system
  88291. */
  88292. removeDragGradient(gradient: number): IParticleSystem;
  88293. /**
  88294. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88295. * @param gradient defines the gradient to use (between 0 and 1)
  88296. * @param factor defines the emit rate value to affect to the specified gradient
  88297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88298. * @returns the current particle system
  88299. */
  88300. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88301. /**
  88302. * Remove a specific emit rate gradient
  88303. * @param gradient defines the gradient to remove
  88304. * @returns the current particle system
  88305. */
  88306. removeEmitRateGradient(gradient: number): IParticleSystem;
  88307. /**
  88308. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88309. * @param gradient defines the gradient to use (between 0 and 1)
  88310. * @param factor defines the start size value to affect to the specified gradient
  88311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88312. * @returns the current particle system
  88313. */
  88314. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88315. /**
  88316. * Remove a specific start size gradient
  88317. * @param gradient defines the gradient to remove
  88318. * @returns the current particle system
  88319. */
  88320. removeStartSizeGradient(gradient: number): IParticleSystem;
  88321. private _createRampGradientTexture;
  88322. /**
  88323. * Gets the current list of ramp gradients.
  88324. * You must use addRampGradient and removeRampGradient to udpate this list
  88325. * @returns the list of ramp gradients
  88326. */
  88327. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88328. /**
  88329. * Adds a new ramp gradient used to remap particle colors
  88330. * @param gradient defines the gradient to use (between 0 and 1)
  88331. * @param color defines the color to affect to the specified gradient
  88332. * @returns the current particle system
  88333. */
  88334. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88335. /**
  88336. * Remove a specific ramp gradient
  88337. * @param gradient defines the gradient to remove
  88338. * @returns the current particle system
  88339. */
  88340. removeRampGradient(gradient: number): ParticleSystem;
  88341. /**
  88342. * Adds a new color gradient
  88343. * @param gradient defines the gradient to use (between 0 and 1)
  88344. * @param color1 defines the color to affect to the specified gradient
  88345. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88346. * @returns this particle system
  88347. */
  88348. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88349. /**
  88350. * Remove a specific color gradient
  88351. * @param gradient defines the gradient to remove
  88352. * @returns this particle system
  88353. */
  88354. removeColorGradient(gradient: number): IParticleSystem;
  88355. private _fetchR;
  88356. protected _reset(): void;
  88357. private _resetEffect;
  88358. private _createVertexBuffers;
  88359. private _createIndexBuffer;
  88360. /**
  88361. * Gets the maximum number of particles active at the same time.
  88362. * @returns The max number of active particles.
  88363. */
  88364. getCapacity(): number;
  88365. /**
  88366. * Gets whether there are still active particles in the system.
  88367. * @returns True if it is alive, otherwise false.
  88368. */
  88369. isAlive(): boolean;
  88370. /**
  88371. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88372. * @returns True if it has been started, otherwise false.
  88373. */
  88374. isStarted(): boolean;
  88375. private _prepareSubEmitterInternalArray;
  88376. /**
  88377. * Starts the particle system and begins to emit
  88378. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88379. */
  88380. start(delay?: number): void;
  88381. /**
  88382. * Stops the particle system.
  88383. * @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.
  88384. */
  88385. stop(stopSubEmitters?: boolean): void;
  88386. /**
  88387. * Remove all active particles
  88388. */
  88389. reset(): void;
  88390. /**
  88391. * @hidden (for internal use only)
  88392. */
  88393. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88394. /**
  88395. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88396. * Its lifetime will start back at 0.
  88397. */
  88398. recycleParticle: (particle: Particle) => void;
  88399. private _stopSubEmitters;
  88400. private _createParticle;
  88401. private _removeFromRoot;
  88402. private _emitFromParticle;
  88403. private _update;
  88404. /** @hidden */
  88405. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88406. /** @hidden */
  88407. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88408. /** @hidden */
  88409. private _getEffect;
  88410. /**
  88411. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88412. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88413. */
  88414. animate(preWarmOnly?: boolean): void;
  88415. private _appendParticleVertices;
  88416. /**
  88417. * Rebuilds the particle system.
  88418. */
  88419. rebuild(): void;
  88420. /**
  88421. * Is this system ready to be used/rendered
  88422. * @return true if the system is ready
  88423. */
  88424. isReady(): boolean;
  88425. private _render;
  88426. /**
  88427. * Renders the particle system in its current state.
  88428. * @returns the current number of particles
  88429. */
  88430. render(): number;
  88431. /**
  88432. * Disposes the particle system and free the associated resources
  88433. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88434. */
  88435. dispose(disposeTexture?: boolean): void;
  88436. /**
  88437. * Clones the particle system.
  88438. * @param name The name of the cloned object
  88439. * @param newEmitter The new emitter to use
  88440. * @returns the cloned particle system
  88441. */
  88442. clone(name: string, newEmitter: any): ParticleSystem;
  88443. /**
  88444. * Serializes the particle system to a JSON object.
  88445. * @returns the JSON object
  88446. */
  88447. serialize(): any;
  88448. /** @hidden */
  88449. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88450. /** @hidden */
  88451. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88452. /**
  88453. * Parses a JSON object to create a particle system.
  88454. * @param parsedParticleSystem The JSON object to parse
  88455. * @param scene The scene to create the particle system in
  88456. * @param rootUrl The root url to use to load external dependencies like texture
  88457. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88458. * @returns the Parsed particle system
  88459. */
  88460. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88461. }
  88462. }
  88463. declare module BABYLON {
  88464. /**
  88465. * A particle represents one of the element emitted by a particle system.
  88466. * This is mainly define by its coordinates, direction, velocity and age.
  88467. */
  88468. export class Particle {
  88469. /**
  88470. * The particle system the particle belongs to.
  88471. */
  88472. particleSystem: ParticleSystem;
  88473. private static _Count;
  88474. /**
  88475. * Unique ID of the particle
  88476. */
  88477. id: number;
  88478. /**
  88479. * The world position of the particle in the scene.
  88480. */
  88481. position: Vector3;
  88482. /**
  88483. * The world direction of the particle in the scene.
  88484. */
  88485. direction: Vector3;
  88486. /**
  88487. * The color of the particle.
  88488. */
  88489. color: Color4;
  88490. /**
  88491. * The color change of the particle per step.
  88492. */
  88493. colorStep: Color4;
  88494. /**
  88495. * Defines how long will the life of the particle be.
  88496. */
  88497. lifeTime: number;
  88498. /**
  88499. * The current age of the particle.
  88500. */
  88501. age: number;
  88502. /**
  88503. * The current size of the particle.
  88504. */
  88505. size: number;
  88506. /**
  88507. * The current scale of the particle.
  88508. */
  88509. scale: Vector2;
  88510. /**
  88511. * The current angle of the particle.
  88512. */
  88513. angle: number;
  88514. /**
  88515. * Defines how fast is the angle changing.
  88516. */
  88517. angularSpeed: number;
  88518. /**
  88519. * Defines the cell index used by the particle to be rendered from a sprite.
  88520. */
  88521. cellIndex: number;
  88522. /**
  88523. * The information required to support color remapping
  88524. */
  88525. remapData: Vector4;
  88526. /** @hidden */
  88527. _randomCellOffset?: number;
  88528. /** @hidden */
  88529. _initialDirection: Nullable<Vector3>;
  88530. /** @hidden */
  88531. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88532. /** @hidden */
  88533. _initialStartSpriteCellID: number;
  88534. /** @hidden */
  88535. _initialEndSpriteCellID: number;
  88536. /** @hidden */
  88537. _currentColorGradient: Nullable<ColorGradient>;
  88538. /** @hidden */
  88539. _currentColor1: Color4;
  88540. /** @hidden */
  88541. _currentColor2: Color4;
  88542. /** @hidden */
  88543. _currentSizeGradient: Nullable<FactorGradient>;
  88544. /** @hidden */
  88545. _currentSize1: number;
  88546. /** @hidden */
  88547. _currentSize2: number;
  88548. /** @hidden */
  88549. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88550. /** @hidden */
  88551. _currentAngularSpeed1: number;
  88552. /** @hidden */
  88553. _currentAngularSpeed2: number;
  88554. /** @hidden */
  88555. _currentVelocityGradient: Nullable<FactorGradient>;
  88556. /** @hidden */
  88557. _currentVelocity1: number;
  88558. /** @hidden */
  88559. _currentVelocity2: number;
  88560. /** @hidden */
  88561. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88562. /** @hidden */
  88563. _currentLimitVelocity1: number;
  88564. /** @hidden */
  88565. _currentLimitVelocity2: number;
  88566. /** @hidden */
  88567. _currentDragGradient: Nullable<FactorGradient>;
  88568. /** @hidden */
  88569. _currentDrag1: number;
  88570. /** @hidden */
  88571. _currentDrag2: number;
  88572. /** @hidden */
  88573. _randomNoiseCoordinates1: Vector3;
  88574. /** @hidden */
  88575. _randomNoiseCoordinates2: Vector3;
  88576. /**
  88577. * Creates a new instance Particle
  88578. * @param particleSystem the particle system the particle belongs to
  88579. */
  88580. constructor(
  88581. /**
  88582. * The particle system the particle belongs to.
  88583. */
  88584. particleSystem: ParticleSystem);
  88585. private updateCellInfoFromSystem;
  88586. /**
  88587. * Defines how the sprite cell index is updated for the particle
  88588. */
  88589. updateCellIndex(): void;
  88590. /** @hidden */
  88591. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88592. /** @hidden */
  88593. _inheritParticleInfoToSubEmitters(): void;
  88594. /** @hidden */
  88595. _reset(): void;
  88596. /**
  88597. * Copy the properties of particle to another one.
  88598. * @param other the particle to copy the information to.
  88599. */
  88600. copyTo(other: Particle): void;
  88601. }
  88602. }
  88603. declare module BABYLON {
  88604. /**
  88605. * Particle emitter represents a volume emitting particles.
  88606. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88607. */
  88608. export interface IParticleEmitterType {
  88609. /**
  88610. * Called by the particle System when the direction is computed for the created particle.
  88611. * @param worldMatrix is the world matrix of the particle system
  88612. * @param directionToUpdate is the direction vector to update with the result
  88613. * @param particle is the particle we are computed the direction for
  88614. */
  88615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88616. /**
  88617. * Called by the particle System when the position is computed for the created particle.
  88618. * @param worldMatrix is the world matrix of the particle system
  88619. * @param positionToUpdate is the position vector to update with the result
  88620. * @param particle is the particle we are computed the position for
  88621. */
  88622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88623. /**
  88624. * Clones the current emitter and returns a copy of it
  88625. * @returns the new emitter
  88626. */
  88627. clone(): IParticleEmitterType;
  88628. /**
  88629. * Called by the GPUParticleSystem to setup the update shader
  88630. * @param effect defines the update shader
  88631. */
  88632. applyToShader(effect: Effect): void;
  88633. /**
  88634. * Returns a string to use to update the GPU particles update shader
  88635. * @returns the effect defines string
  88636. */
  88637. getEffectDefines(): string;
  88638. /**
  88639. * Returns a string representing the class name
  88640. * @returns a string containing the class name
  88641. */
  88642. getClassName(): string;
  88643. /**
  88644. * Serializes the particle system to a JSON object.
  88645. * @returns the JSON object
  88646. */
  88647. serialize(): any;
  88648. /**
  88649. * Parse properties from a JSON object
  88650. * @param serializationObject defines the JSON object
  88651. */
  88652. parse(serializationObject: any): void;
  88653. }
  88654. }
  88655. declare module BABYLON {
  88656. /**
  88657. * Particle emitter emitting particles from the inside of a box.
  88658. * It emits the particles randomly between 2 given directions.
  88659. */
  88660. export class BoxParticleEmitter implements IParticleEmitterType {
  88661. /**
  88662. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88663. */
  88664. direction1: Vector3;
  88665. /**
  88666. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88667. */
  88668. direction2: Vector3;
  88669. /**
  88670. * 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.
  88671. */
  88672. minEmitBox: Vector3;
  88673. /**
  88674. * 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.
  88675. */
  88676. maxEmitBox: Vector3;
  88677. /**
  88678. * Creates a new instance BoxParticleEmitter
  88679. */
  88680. constructor();
  88681. /**
  88682. * Called by the particle System when the direction is computed for the created particle.
  88683. * @param worldMatrix is the world matrix of the particle system
  88684. * @param directionToUpdate is the direction vector to update with the result
  88685. * @param particle is the particle we are computed the direction for
  88686. */
  88687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88688. /**
  88689. * Called by the particle System when the position is computed for the created particle.
  88690. * @param worldMatrix is the world matrix of the particle system
  88691. * @param positionToUpdate is the position vector to update with the result
  88692. * @param particle is the particle we are computed the position for
  88693. */
  88694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88695. /**
  88696. * Clones the current emitter and returns a copy of it
  88697. * @returns the new emitter
  88698. */
  88699. clone(): BoxParticleEmitter;
  88700. /**
  88701. * Called by the GPUParticleSystem to setup the update shader
  88702. * @param effect defines the update shader
  88703. */
  88704. applyToShader(effect: Effect): void;
  88705. /**
  88706. * Returns a string to use to update the GPU particles update shader
  88707. * @returns a string containng the defines string
  88708. */
  88709. getEffectDefines(): string;
  88710. /**
  88711. * Returns the string "BoxParticleEmitter"
  88712. * @returns a string containing the class name
  88713. */
  88714. getClassName(): string;
  88715. /**
  88716. * Serializes the particle system to a JSON object.
  88717. * @returns the JSON object
  88718. */
  88719. serialize(): any;
  88720. /**
  88721. * Parse properties from a JSON object
  88722. * @param serializationObject defines the JSON object
  88723. */
  88724. parse(serializationObject: any): void;
  88725. }
  88726. }
  88727. declare module BABYLON {
  88728. /**
  88729. * Particle emitter emitting particles from the inside of a cone.
  88730. * It emits the particles alongside the cone volume from the base to the particle.
  88731. * The emission direction might be randomized.
  88732. */
  88733. export class ConeParticleEmitter implements IParticleEmitterType {
  88734. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88735. directionRandomizer: number;
  88736. private _radius;
  88737. private _angle;
  88738. private _height;
  88739. /**
  88740. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88741. */
  88742. radiusRange: number;
  88743. /**
  88744. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88745. */
  88746. heightRange: number;
  88747. /**
  88748. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88749. */
  88750. emitFromSpawnPointOnly: boolean;
  88751. /**
  88752. * Gets or sets the radius of the emission cone
  88753. */
  88754. get radius(): number;
  88755. set radius(value: number);
  88756. /**
  88757. * Gets or sets the angle of the emission cone
  88758. */
  88759. get angle(): number;
  88760. set angle(value: number);
  88761. private _buildHeight;
  88762. /**
  88763. * Creates a new instance ConeParticleEmitter
  88764. * @param radius the radius of the emission cone (1 by default)
  88765. * @param angle the cone base angle (PI by default)
  88766. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88767. */
  88768. constructor(radius?: number, angle?: number,
  88769. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88770. directionRandomizer?: number);
  88771. /**
  88772. * Called by the particle System when the direction is computed for the created particle.
  88773. * @param worldMatrix is the world matrix of the particle system
  88774. * @param directionToUpdate is the direction vector to update with the result
  88775. * @param particle is the particle we are computed the direction for
  88776. */
  88777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88778. /**
  88779. * Called by the particle System when the position is computed for the created particle.
  88780. * @param worldMatrix is the world matrix of the particle system
  88781. * @param positionToUpdate is the position vector to update with the result
  88782. * @param particle is the particle we are computed the position for
  88783. */
  88784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88785. /**
  88786. * Clones the current emitter and returns a copy of it
  88787. * @returns the new emitter
  88788. */
  88789. clone(): ConeParticleEmitter;
  88790. /**
  88791. * Called by the GPUParticleSystem to setup the update shader
  88792. * @param effect defines the update shader
  88793. */
  88794. applyToShader(effect: Effect): void;
  88795. /**
  88796. * Returns a string to use to update the GPU particles update shader
  88797. * @returns a string containng the defines string
  88798. */
  88799. getEffectDefines(): string;
  88800. /**
  88801. * Returns the string "ConeParticleEmitter"
  88802. * @returns a string containing the class name
  88803. */
  88804. getClassName(): string;
  88805. /**
  88806. * Serializes the particle system to a JSON object.
  88807. * @returns the JSON object
  88808. */
  88809. serialize(): any;
  88810. /**
  88811. * Parse properties from a JSON object
  88812. * @param serializationObject defines the JSON object
  88813. */
  88814. parse(serializationObject: any): void;
  88815. }
  88816. }
  88817. declare module BABYLON {
  88818. /**
  88819. * Particle emitter emitting particles from the inside of a cylinder.
  88820. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88821. */
  88822. export class CylinderParticleEmitter implements IParticleEmitterType {
  88823. /**
  88824. * The radius of the emission cylinder.
  88825. */
  88826. radius: number;
  88827. /**
  88828. * The height of the emission cylinder.
  88829. */
  88830. height: number;
  88831. /**
  88832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88833. */
  88834. radiusRange: number;
  88835. /**
  88836. * How much to randomize the particle direction [0-1].
  88837. */
  88838. directionRandomizer: number;
  88839. /**
  88840. * Creates a new instance CylinderParticleEmitter
  88841. * @param radius the radius of the emission cylinder (1 by default)
  88842. * @param height the height of the emission cylinder (1 by default)
  88843. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88844. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88845. */
  88846. constructor(
  88847. /**
  88848. * The radius of the emission cylinder.
  88849. */
  88850. radius?: number,
  88851. /**
  88852. * The height of the emission cylinder.
  88853. */
  88854. height?: number,
  88855. /**
  88856. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88857. */
  88858. radiusRange?: number,
  88859. /**
  88860. * How much to randomize the particle direction [0-1].
  88861. */
  88862. directionRandomizer?: number);
  88863. /**
  88864. * Called by the particle System when the direction is computed for the created particle.
  88865. * @param worldMatrix is the world matrix of the particle system
  88866. * @param directionToUpdate is the direction vector to update with the result
  88867. * @param particle is the particle we are computed the direction for
  88868. */
  88869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88870. /**
  88871. * Called by the particle System when the position is computed for the created particle.
  88872. * @param worldMatrix is the world matrix of the particle system
  88873. * @param positionToUpdate is the position vector to update with the result
  88874. * @param particle is the particle we are computed the position for
  88875. */
  88876. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88877. /**
  88878. * Clones the current emitter and returns a copy of it
  88879. * @returns the new emitter
  88880. */
  88881. clone(): CylinderParticleEmitter;
  88882. /**
  88883. * Called by the GPUParticleSystem to setup the update shader
  88884. * @param effect defines the update shader
  88885. */
  88886. applyToShader(effect: Effect): void;
  88887. /**
  88888. * Returns a string to use to update the GPU particles update shader
  88889. * @returns a string containng the defines string
  88890. */
  88891. getEffectDefines(): string;
  88892. /**
  88893. * Returns the string "CylinderParticleEmitter"
  88894. * @returns a string containing the class name
  88895. */
  88896. getClassName(): string;
  88897. /**
  88898. * Serializes the particle system to a JSON object.
  88899. * @returns the JSON object
  88900. */
  88901. serialize(): any;
  88902. /**
  88903. * Parse properties from a JSON object
  88904. * @param serializationObject defines the JSON object
  88905. */
  88906. parse(serializationObject: any): void;
  88907. }
  88908. /**
  88909. * Particle emitter emitting particles from the inside of a cylinder.
  88910. * It emits the particles randomly between two vectors.
  88911. */
  88912. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88913. /**
  88914. * The min limit of the emission direction.
  88915. */
  88916. direction1: Vector3;
  88917. /**
  88918. * The max limit of the emission direction.
  88919. */
  88920. direction2: Vector3;
  88921. /**
  88922. * Creates a new instance CylinderDirectedParticleEmitter
  88923. * @param radius the radius of the emission cylinder (1 by default)
  88924. * @param height the height of the emission cylinder (1 by default)
  88925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88926. * @param direction1 the min limit of the emission direction (up vector by default)
  88927. * @param direction2 the max limit of the emission direction (up vector by default)
  88928. */
  88929. constructor(radius?: number, height?: number, radiusRange?: number,
  88930. /**
  88931. * The min limit of the emission direction.
  88932. */
  88933. direction1?: Vector3,
  88934. /**
  88935. * The max limit of the emission direction.
  88936. */
  88937. direction2?: Vector3);
  88938. /**
  88939. * Called by the particle System when the direction is computed for the created particle.
  88940. * @param worldMatrix is the world matrix of the particle system
  88941. * @param directionToUpdate is the direction vector to update with the result
  88942. * @param particle is the particle we are computed the direction for
  88943. */
  88944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88945. /**
  88946. * Clones the current emitter and returns a copy of it
  88947. * @returns the new emitter
  88948. */
  88949. clone(): CylinderDirectedParticleEmitter;
  88950. /**
  88951. * Called by the GPUParticleSystem to setup the update shader
  88952. * @param effect defines the update shader
  88953. */
  88954. applyToShader(effect: Effect): void;
  88955. /**
  88956. * Returns a string to use to update the GPU particles update shader
  88957. * @returns a string containng the defines string
  88958. */
  88959. getEffectDefines(): string;
  88960. /**
  88961. * Returns the string "CylinderDirectedParticleEmitter"
  88962. * @returns a string containing the class name
  88963. */
  88964. getClassName(): string;
  88965. /**
  88966. * Serializes the particle system to a JSON object.
  88967. * @returns the JSON object
  88968. */
  88969. serialize(): any;
  88970. /**
  88971. * Parse properties from a JSON object
  88972. * @param serializationObject defines the JSON object
  88973. */
  88974. parse(serializationObject: any): void;
  88975. }
  88976. }
  88977. declare module BABYLON {
  88978. /**
  88979. * Particle emitter emitting particles from the inside of a hemisphere.
  88980. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88981. */
  88982. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88983. /**
  88984. * The radius of the emission hemisphere.
  88985. */
  88986. radius: number;
  88987. /**
  88988. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88989. */
  88990. radiusRange: number;
  88991. /**
  88992. * How much to randomize the particle direction [0-1].
  88993. */
  88994. directionRandomizer: number;
  88995. /**
  88996. * Creates a new instance HemisphericParticleEmitter
  88997. * @param radius the radius of the emission hemisphere (1 by default)
  88998. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88999. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89000. */
  89001. constructor(
  89002. /**
  89003. * The radius of the emission hemisphere.
  89004. */
  89005. radius?: number,
  89006. /**
  89007. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89008. */
  89009. radiusRange?: number,
  89010. /**
  89011. * How much to randomize the particle direction [0-1].
  89012. */
  89013. directionRandomizer?: number);
  89014. /**
  89015. * Called by the particle System when the direction is computed for the created particle.
  89016. * @param worldMatrix is the world matrix of the particle system
  89017. * @param directionToUpdate is the direction vector to update with the result
  89018. * @param particle is the particle we are computed the direction for
  89019. */
  89020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89021. /**
  89022. * Called by the particle System when the position is computed for the created particle.
  89023. * @param worldMatrix is the world matrix of the particle system
  89024. * @param positionToUpdate is the position vector to update with the result
  89025. * @param particle is the particle we are computed the position for
  89026. */
  89027. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89028. /**
  89029. * Clones the current emitter and returns a copy of it
  89030. * @returns the new emitter
  89031. */
  89032. clone(): HemisphericParticleEmitter;
  89033. /**
  89034. * Called by the GPUParticleSystem to setup the update shader
  89035. * @param effect defines the update shader
  89036. */
  89037. applyToShader(effect: Effect): void;
  89038. /**
  89039. * Returns a string to use to update the GPU particles update shader
  89040. * @returns a string containng the defines string
  89041. */
  89042. getEffectDefines(): string;
  89043. /**
  89044. * Returns the string "HemisphericParticleEmitter"
  89045. * @returns a string containing the class name
  89046. */
  89047. getClassName(): string;
  89048. /**
  89049. * Serializes the particle system to a JSON object.
  89050. * @returns the JSON object
  89051. */
  89052. serialize(): any;
  89053. /**
  89054. * Parse properties from a JSON object
  89055. * @param serializationObject defines the JSON object
  89056. */
  89057. parse(serializationObject: any): void;
  89058. }
  89059. }
  89060. declare module BABYLON {
  89061. /**
  89062. * Particle emitter emitting particles from a point.
  89063. * It emits the particles randomly between 2 given directions.
  89064. */
  89065. export class PointParticleEmitter implements IParticleEmitterType {
  89066. /**
  89067. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89068. */
  89069. direction1: Vector3;
  89070. /**
  89071. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89072. */
  89073. direction2: Vector3;
  89074. /**
  89075. * Creates a new instance PointParticleEmitter
  89076. */
  89077. constructor();
  89078. /**
  89079. * Called by the particle System when the direction is computed for the created particle.
  89080. * @param worldMatrix is the world matrix of the particle system
  89081. * @param directionToUpdate is the direction vector to update with the result
  89082. * @param particle is the particle we are computed the direction for
  89083. */
  89084. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89085. /**
  89086. * Called by the particle System when the position is computed for the created particle.
  89087. * @param worldMatrix is the world matrix of the particle system
  89088. * @param positionToUpdate is the position vector to update with the result
  89089. * @param particle is the particle we are computed the position for
  89090. */
  89091. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89092. /**
  89093. * Clones the current emitter and returns a copy of it
  89094. * @returns the new emitter
  89095. */
  89096. clone(): PointParticleEmitter;
  89097. /**
  89098. * Called by the GPUParticleSystem to setup the update shader
  89099. * @param effect defines the update shader
  89100. */
  89101. applyToShader(effect: Effect): void;
  89102. /**
  89103. * Returns a string to use to update the GPU particles update shader
  89104. * @returns a string containng the defines string
  89105. */
  89106. getEffectDefines(): string;
  89107. /**
  89108. * Returns the string "PointParticleEmitter"
  89109. * @returns a string containing the class name
  89110. */
  89111. getClassName(): string;
  89112. /**
  89113. * Serializes the particle system to a JSON object.
  89114. * @returns the JSON object
  89115. */
  89116. serialize(): any;
  89117. /**
  89118. * Parse properties from a JSON object
  89119. * @param serializationObject defines the JSON object
  89120. */
  89121. parse(serializationObject: any): void;
  89122. }
  89123. }
  89124. declare module BABYLON {
  89125. /**
  89126. * Particle emitter emitting particles from the inside of a sphere.
  89127. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89128. */
  89129. export class SphereParticleEmitter implements IParticleEmitterType {
  89130. /**
  89131. * The radius of the emission sphere.
  89132. */
  89133. radius: number;
  89134. /**
  89135. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89136. */
  89137. radiusRange: number;
  89138. /**
  89139. * How much to randomize the particle direction [0-1].
  89140. */
  89141. directionRandomizer: number;
  89142. /**
  89143. * Creates a new instance SphereParticleEmitter
  89144. * @param radius the radius of the emission sphere (1 by default)
  89145. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89146. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89147. */
  89148. constructor(
  89149. /**
  89150. * The radius of the emission sphere.
  89151. */
  89152. radius?: number,
  89153. /**
  89154. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89155. */
  89156. radiusRange?: number,
  89157. /**
  89158. * How much to randomize the particle direction [0-1].
  89159. */
  89160. directionRandomizer?: number);
  89161. /**
  89162. * Called by the particle System when the direction is computed for the created particle.
  89163. * @param worldMatrix is the world matrix of the particle system
  89164. * @param directionToUpdate is the direction vector to update with the result
  89165. * @param particle is the particle we are computed the direction for
  89166. */
  89167. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89168. /**
  89169. * Called by the particle System when the position is computed for the created particle.
  89170. * @param worldMatrix is the world matrix of the particle system
  89171. * @param positionToUpdate is the position vector to update with the result
  89172. * @param particle is the particle we are computed the position for
  89173. */
  89174. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89175. /**
  89176. * Clones the current emitter and returns a copy of it
  89177. * @returns the new emitter
  89178. */
  89179. clone(): SphereParticleEmitter;
  89180. /**
  89181. * Called by the GPUParticleSystem to setup the update shader
  89182. * @param effect defines the update shader
  89183. */
  89184. applyToShader(effect: Effect): void;
  89185. /**
  89186. * Returns a string to use to update the GPU particles update shader
  89187. * @returns a string containng the defines string
  89188. */
  89189. getEffectDefines(): string;
  89190. /**
  89191. * Returns the string "SphereParticleEmitter"
  89192. * @returns a string containing the class name
  89193. */
  89194. getClassName(): string;
  89195. /**
  89196. * Serializes the particle system to a JSON object.
  89197. * @returns the JSON object
  89198. */
  89199. serialize(): any;
  89200. /**
  89201. * Parse properties from a JSON object
  89202. * @param serializationObject defines the JSON object
  89203. */
  89204. parse(serializationObject: any): void;
  89205. }
  89206. /**
  89207. * Particle emitter emitting particles from the inside of a sphere.
  89208. * It emits the particles randomly between two vectors.
  89209. */
  89210. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89211. /**
  89212. * The min limit of the emission direction.
  89213. */
  89214. direction1: Vector3;
  89215. /**
  89216. * The max limit of the emission direction.
  89217. */
  89218. direction2: Vector3;
  89219. /**
  89220. * Creates a new instance SphereDirectedParticleEmitter
  89221. * @param radius the radius of the emission sphere (1 by default)
  89222. * @param direction1 the min limit of the emission direction (up vector by default)
  89223. * @param direction2 the max limit of the emission direction (up vector by default)
  89224. */
  89225. constructor(radius?: number,
  89226. /**
  89227. * The min limit of the emission direction.
  89228. */
  89229. direction1?: Vector3,
  89230. /**
  89231. * The max limit of the emission direction.
  89232. */
  89233. direction2?: Vector3);
  89234. /**
  89235. * Called by the particle System when the direction is computed for the created particle.
  89236. * @param worldMatrix is the world matrix of the particle system
  89237. * @param directionToUpdate is the direction vector to update with the result
  89238. * @param particle is the particle we are computed the direction for
  89239. */
  89240. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89241. /**
  89242. * Clones the current emitter and returns a copy of it
  89243. * @returns the new emitter
  89244. */
  89245. clone(): SphereDirectedParticleEmitter;
  89246. /**
  89247. * Called by the GPUParticleSystem to setup the update shader
  89248. * @param effect defines the update shader
  89249. */
  89250. applyToShader(effect: Effect): void;
  89251. /**
  89252. * Returns a string to use to update the GPU particles update shader
  89253. * @returns a string containng the defines string
  89254. */
  89255. getEffectDefines(): string;
  89256. /**
  89257. * Returns the string "SphereDirectedParticleEmitter"
  89258. * @returns a string containing the class name
  89259. */
  89260. getClassName(): string;
  89261. /**
  89262. * Serializes the particle system to a JSON object.
  89263. * @returns the JSON object
  89264. */
  89265. serialize(): any;
  89266. /**
  89267. * Parse properties from a JSON object
  89268. * @param serializationObject defines the JSON object
  89269. */
  89270. parse(serializationObject: any): void;
  89271. }
  89272. }
  89273. declare module BABYLON {
  89274. /**
  89275. * Interface representing a particle system in Babylon.js.
  89276. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89277. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89278. */
  89279. export interface IParticleSystem {
  89280. /**
  89281. * List of animations used by the particle system.
  89282. */
  89283. animations: Animation[];
  89284. /**
  89285. * The id of the Particle system.
  89286. */
  89287. id: string;
  89288. /**
  89289. * The name of the Particle system.
  89290. */
  89291. name: string;
  89292. /**
  89293. * The emitter represents the Mesh or position we are attaching the particle system to.
  89294. */
  89295. emitter: Nullable<AbstractMesh | Vector3>;
  89296. /**
  89297. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89298. */
  89299. isBillboardBased: boolean;
  89300. /**
  89301. * The rendering group used by the Particle system to chose when to render.
  89302. */
  89303. renderingGroupId: number;
  89304. /**
  89305. * The layer mask we are rendering the particles through.
  89306. */
  89307. layerMask: number;
  89308. /**
  89309. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89310. */
  89311. updateSpeed: number;
  89312. /**
  89313. * The amount of time the particle system is running (depends of the overall update speed).
  89314. */
  89315. targetStopDuration: number;
  89316. /**
  89317. * The texture used to render each particle. (this can be a spritesheet)
  89318. */
  89319. particleTexture: Nullable<Texture>;
  89320. /**
  89321. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89322. */
  89323. blendMode: number;
  89324. /**
  89325. * Minimum life time of emitting particles.
  89326. */
  89327. minLifeTime: number;
  89328. /**
  89329. * Maximum life time of emitting particles.
  89330. */
  89331. maxLifeTime: number;
  89332. /**
  89333. * Minimum Size of emitting particles.
  89334. */
  89335. minSize: number;
  89336. /**
  89337. * Maximum Size of emitting particles.
  89338. */
  89339. maxSize: number;
  89340. /**
  89341. * Minimum scale of emitting particles on X axis.
  89342. */
  89343. minScaleX: number;
  89344. /**
  89345. * Maximum scale of emitting particles on X axis.
  89346. */
  89347. maxScaleX: number;
  89348. /**
  89349. * Minimum scale of emitting particles on Y axis.
  89350. */
  89351. minScaleY: number;
  89352. /**
  89353. * Maximum scale of emitting particles on Y axis.
  89354. */
  89355. maxScaleY: number;
  89356. /**
  89357. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89358. */
  89359. color1: Color4;
  89360. /**
  89361. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89362. */
  89363. color2: Color4;
  89364. /**
  89365. * Color the particle will have at the end of its lifetime.
  89366. */
  89367. colorDead: Color4;
  89368. /**
  89369. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89370. */
  89371. emitRate: number;
  89372. /**
  89373. * You can use gravity if you want to give an orientation to your particles.
  89374. */
  89375. gravity: Vector3;
  89376. /**
  89377. * Minimum power of emitting particles.
  89378. */
  89379. minEmitPower: number;
  89380. /**
  89381. * Maximum power of emitting particles.
  89382. */
  89383. maxEmitPower: number;
  89384. /**
  89385. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89386. */
  89387. minAngularSpeed: number;
  89388. /**
  89389. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89390. */
  89391. maxAngularSpeed: number;
  89392. /**
  89393. * Gets or sets the minimal initial rotation in radians.
  89394. */
  89395. minInitialRotation: number;
  89396. /**
  89397. * Gets or sets the maximal initial rotation in radians.
  89398. */
  89399. maxInitialRotation: number;
  89400. /**
  89401. * The particle emitter type defines the emitter used by the particle system.
  89402. * It can be for example box, sphere, or cone...
  89403. */
  89404. particleEmitterType: Nullable<IParticleEmitterType>;
  89405. /**
  89406. * Defines the delay in milliseconds before starting the system (0 by default)
  89407. */
  89408. startDelay: number;
  89409. /**
  89410. * 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
  89411. */
  89412. preWarmCycles: number;
  89413. /**
  89414. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89415. */
  89416. preWarmStepOffset: number;
  89417. /**
  89418. * 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)
  89419. */
  89420. spriteCellChangeSpeed: number;
  89421. /**
  89422. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89423. */
  89424. startSpriteCellID: number;
  89425. /**
  89426. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89427. */
  89428. endSpriteCellID: number;
  89429. /**
  89430. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89431. */
  89432. spriteCellWidth: number;
  89433. /**
  89434. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89435. */
  89436. spriteCellHeight: number;
  89437. /**
  89438. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89439. */
  89440. spriteRandomStartCell: boolean;
  89441. /**
  89442. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89443. */
  89444. isAnimationSheetEnabled: boolean;
  89445. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89446. translationPivot: Vector2;
  89447. /**
  89448. * Gets or sets a texture used to add random noise to particle positions
  89449. */
  89450. noiseTexture: Nullable<BaseTexture>;
  89451. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89452. noiseStrength: Vector3;
  89453. /**
  89454. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89455. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89456. */
  89457. billboardMode: number;
  89458. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89459. limitVelocityDamping: number;
  89460. /**
  89461. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89462. */
  89463. beginAnimationOnStart: boolean;
  89464. /**
  89465. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89466. */
  89467. beginAnimationFrom: number;
  89468. /**
  89469. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89470. */
  89471. beginAnimationTo: number;
  89472. /**
  89473. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89474. */
  89475. beginAnimationLoop: boolean;
  89476. /**
  89477. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89478. */
  89479. disposeOnStop: boolean;
  89480. /**
  89481. * Gets the maximum number of particles active at the same time.
  89482. * @returns The max number of active particles.
  89483. */
  89484. getCapacity(): number;
  89485. /**
  89486. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89487. * @returns True if it has been started, otherwise false.
  89488. */
  89489. isStarted(): boolean;
  89490. /**
  89491. * Animates the particle system for this frame.
  89492. */
  89493. animate(): void;
  89494. /**
  89495. * Renders the particle system in its current state.
  89496. * @returns the current number of particles
  89497. */
  89498. render(): number;
  89499. /**
  89500. * Dispose the particle system and frees its associated resources.
  89501. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89502. */
  89503. dispose(disposeTexture?: boolean): void;
  89504. /**
  89505. * Clones the particle system.
  89506. * @param name The name of the cloned object
  89507. * @param newEmitter The new emitter to use
  89508. * @returns the cloned particle system
  89509. */
  89510. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89511. /**
  89512. * Serializes the particle system to a JSON object.
  89513. * @returns the JSON object
  89514. */
  89515. serialize(): any;
  89516. /**
  89517. * Rebuild the particle system
  89518. */
  89519. rebuild(): void;
  89520. /**
  89521. * Starts the particle system and begins to emit
  89522. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89523. */
  89524. start(delay?: number): void;
  89525. /**
  89526. * Stops the particle system.
  89527. */
  89528. stop(): void;
  89529. /**
  89530. * Remove all active particles
  89531. */
  89532. reset(): void;
  89533. /**
  89534. * Is this system ready to be used/rendered
  89535. * @return true if the system is ready
  89536. */
  89537. isReady(): boolean;
  89538. /**
  89539. * Adds a new color gradient
  89540. * @param gradient defines the gradient to use (between 0 and 1)
  89541. * @param color1 defines the color to affect to the specified gradient
  89542. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89543. * @returns the current particle system
  89544. */
  89545. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89546. /**
  89547. * Remove a specific color gradient
  89548. * @param gradient defines the gradient to remove
  89549. * @returns the current particle system
  89550. */
  89551. removeColorGradient(gradient: number): IParticleSystem;
  89552. /**
  89553. * Adds a new size gradient
  89554. * @param gradient defines the gradient to use (between 0 and 1)
  89555. * @param factor defines the size factor to affect to the specified gradient
  89556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89557. * @returns the current particle system
  89558. */
  89559. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89560. /**
  89561. * Remove a specific size gradient
  89562. * @param gradient defines the gradient to remove
  89563. * @returns the current particle system
  89564. */
  89565. removeSizeGradient(gradient: number): IParticleSystem;
  89566. /**
  89567. * Gets the current list of color gradients.
  89568. * You must use addColorGradient and removeColorGradient to udpate this list
  89569. * @returns the list of color gradients
  89570. */
  89571. getColorGradients(): Nullable<Array<ColorGradient>>;
  89572. /**
  89573. * Gets the current list of size gradients.
  89574. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89575. * @returns the list of size gradients
  89576. */
  89577. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89578. /**
  89579. * Gets the current list of angular speed gradients.
  89580. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89581. * @returns the list of angular speed gradients
  89582. */
  89583. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89584. /**
  89585. * Adds a new angular speed gradient
  89586. * @param gradient defines the gradient to use (between 0 and 1)
  89587. * @param factor defines the angular speed to affect to the specified gradient
  89588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89589. * @returns the current particle system
  89590. */
  89591. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89592. /**
  89593. * Remove a specific angular speed gradient
  89594. * @param gradient defines the gradient to remove
  89595. * @returns the current particle system
  89596. */
  89597. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89598. /**
  89599. * Gets the current list of velocity gradients.
  89600. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89601. * @returns the list of velocity gradients
  89602. */
  89603. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89604. /**
  89605. * Adds a new velocity gradient
  89606. * @param gradient defines the gradient to use (between 0 and 1)
  89607. * @param factor defines the velocity to affect to the specified gradient
  89608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89609. * @returns the current particle system
  89610. */
  89611. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89612. /**
  89613. * Remove a specific velocity gradient
  89614. * @param gradient defines the gradient to remove
  89615. * @returns the current particle system
  89616. */
  89617. removeVelocityGradient(gradient: number): IParticleSystem;
  89618. /**
  89619. * Gets the current list of limit velocity gradients.
  89620. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89621. * @returns the list of limit velocity gradients
  89622. */
  89623. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89624. /**
  89625. * Adds a new limit velocity gradient
  89626. * @param gradient defines the gradient to use (between 0 and 1)
  89627. * @param factor defines the limit velocity to affect to the specified gradient
  89628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89629. * @returns the current particle system
  89630. */
  89631. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89632. /**
  89633. * Remove a specific limit velocity gradient
  89634. * @param gradient defines the gradient to remove
  89635. * @returns the current particle system
  89636. */
  89637. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89638. /**
  89639. * Adds a new drag gradient
  89640. * @param gradient defines the gradient to use (between 0 and 1)
  89641. * @param factor defines the drag to affect to the specified gradient
  89642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89643. * @returns the current particle system
  89644. */
  89645. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89646. /**
  89647. * Remove a specific drag gradient
  89648. * @param gradient defines the gradient to remove
  89649. * @returns the current particle system
  89650. */
  89651. removeDragGradient(gradient: number): IParticleSystem;
  89652. /**
  89653. * Gets the current list of drag gradients.
  89654. * You must use addDragGradient and removeDragGradient to udpate this list
  89655. * @returns the list of drag gradients
  89656. */
  89657. getDragGradients(): Nullable<Array<FactorGradient>>;
  89658. /**
  89659. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89660. * @param gradient defines the gradient to use (between 0 and 1)
  89661. * @param factor defines the emit rate to affect to the specified gradient
  89662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89663. * @returns the current particle system
  89664. */
  89665. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89666. /**
  89667. * Remove a specific emit rate gradient
  89668. * @param gradient defines the gradient to remove
  89669. * @returns the current particle system
  89670. */
  89671. removeEmitRateGradient(gradient: number): IParticleSystem;
  89672. /**
  89673. * Gets the current list of emit rate gradients.
  89674. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89675. * @returns the list of emit rate gradients
  89676. */
  89677. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89678. /**
  89679. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89680. * @param gradient defines the gradient to use (between 0 and 1)
  89681. * @param factor defines the start size to affect to the specified gradient
  89682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89683. * @returns the current particle system
  89684. */
  89685. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89686. /**
  89687. * Remove a specific start size gradient
  89688. * @param gradient defines the gradient to remove
  89689. * @returns the current particle system
  89690. */
  89691. removeStartSizeGradient(gradient: number): IParticleSystem;
  89692. /**
  89693. * Gets the current list of start size gradients.
  89694. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89695. * @returns the list of start size gradients
  89696. */
  89697. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89698. /**
  89699. * Adds a new life time gradient
  89700. * @param gradient defines the gradient to use (between 0 and 1)
  89701. * @param factor defines the life time factor to affect to the specified gradient
  89702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89703. * @returns the current particle system
  89704. */
  89705. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89706. /**
  89707. * Remove a specific life time gradient
  89708. * @param gradient defines the gradient to remove
  89709. * @returns the current particle system
  89710. */
  89711. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89712. /**
  89713. * Gets the current list of life time gradients.
  89714. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89715. * @returns the list of life time gradients
  89716. */
  89717. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89718. /**
  89719. * Gets the current list of color gradients.
  89720. * You must use addColorGradient and removeColorGradient to udpate this list
  89721. * @returns the list of color gradients
  89722. */
  89723. getColorGradients(): Nullable<Array<ColorGradient>>;
  89724. /**
  89725. * Adds a new ramp gradient used to remap particle colors
  89726. * @param gradient defines the gradient to use (between 0 and 1)
  89727. * @param color defines the color to affect to the specified gradient
  89728. * @returns the current particle system
  89729. */
  89730. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89731. /**
  89732. * Gets the current list of ramp gradients.
  89733. * You must use addRampGradient and removeRampGradient to udpate this list
  89734. * @returns the list of ramp gradients
  89735. */
  89736. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89737. /** Gets or sets a boolean indicating that ramp gradients must be used
  89738. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89739. */
  89740. useRampGradients: boolean;
  89741. /**
  89742. * Adds a new color remap gradient
  89743. * @param gradient defines the gradient to use (between 0 and 1)
  89744. * @param min defines the color remap minimal range
  89745. * @param max defines the color remap maximal range
  89746. * @returns the current particle system
  89747. */
  89748. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89749. /**
  89750. * Gets the current list of color remap gradients.
  89751. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89752. * @returns the list of color remap gradients
  89753. */
  89754. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89755. /**
  89756. * Adds a new alpha remap gradient
  89757. * @param gradient defines the gradient to use (between 0 and 1)
  89758. * @param min defines the alpha remap minimal range
  89759. * @param max defines the alpha remap maximal range
  89760. * @returns the current particle system
  89761. */
  89762. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89763. /**
  89764. * Gets the current list of alpha remap gradients.
  89765. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89766. * @returns the list of alpha remap gradients
  89767. */
  89768. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89769. /**
  89770. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89771. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89772. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89773. * @returns the emitter
  89774. */
  89775. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89776. /**
  89777. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89778. * @param radius The radius of the hemisphere to emit from
  89779. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89780. * @returns the emitter
  89781. */
  89782. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89783. /**
  89784. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89785. * @param radius The radius of the sphere to emit from
  89786. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89787. * @returns the emitter
  89788. */
  89789. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89790. /**
  89791. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89792. * @param radius The radius of the sphere to emit from
  89793. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89794. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89795. * @returns the emitter
  89796. */
  89797. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89798. /**
  89799. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89800. * @param radius The radius of the emission cylinder
  89801. * @param height The height of the emission cylinder
  89802. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89803. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89804. * @returns the emitter
  89805. */
  89806. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89807. /**
  89808. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89809. * @param radius The radius of the cylinder to emit from
  89810. * @param height The height of the emission cylinder
  89811. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89812. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89813. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89814. * @returns the emitter
  89815. */
  89816. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89817. /**
  89818. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89819. * @param radius The radius of the cone to emit from
  89820. * @param angle The base angle of the cone
  89821. * @returns the emitter
  89822. */
  89823. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89824. /**
  89825. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89826. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89827. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89828. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89829. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89830. * @returns the emitter
  89831. */
  89832. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89833. /**
  89834. * Get hosting scene
  89835. * @returns the scene
  89836. */
  89837. getScene(): Scene;
  89838. }
  89839. }
  89840. declare module BABYLON {
  89841. /**
  89842. * Creates an instance based on a source mesh.
  89843. */
  89844. export class InstancedMesh extends AbstractMesh {
  89845. private _sourceMesh;
  89846. private _currentLOD;
  89847. /** @hidden */
  89848. _indexInSourceMeshInstanceArray: number;
  89849. constructor(name: string, source: Mesh);
  89850. /**
  89851. * Returns the string "InstancedMesh".
  89852. */
  89853. getClassName(): string;
  89854. /** Gets the list of lights affecting that mesh */
  89855. get lightSources(): Light[];
  89856. _resyncLightSources(): void;
  89857. _resyncLightSource(light: Light): void;
  89858. _removeLightSource(light: Light, dispose: boolean): void;
  89859. /**
  89860. * If the source mesh receives shadows
  89861. */
  89862. get receiveShadows(): boolean;
  89863. /**
  89864. * The material of the source mesh
  89865. */
  89866. get material(): Nullable<Material>;
  89867. /**
  89868. * Visibility of the source mesh
  89869. */
  89870. get visibility(): number;
  89871. /**
  89872. * Skeleton of the source mesh
  89873. */
  89874. get skeleton(): Nullable<Skeleton>;
  89875. /**
  89876. * Rendering ground id of the source mesh
  89877. */
  89878. get renderingGroupId(): number;
  89879. set renderingGroupId(value: number);
  89880. /**
  89881. * Returns the total number of vertices (integer).
  89882. */
  89883. getTotalVertices(): number;
  89884. /**
  89885. * Returns a positive integer : the total number of indices in this mesh geometry.
  89886. * @returns the numner of indices or zero if the mesh has no geometry.
  89887. */
  89888. getTotalIndices(): number;
  89889. /**
  89890. * The source mesh of the instance
  89891. */
  89892. get sourceMesh(): Mesh;
  89893. /**
  89894. * Is this node ready to be used/rendered
  89895. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89896. * @return {boolean} is it ready
  89897. */
  89898. isReady(completeCheck?: boolean): boolean;
  89899. /**
  89900. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89901. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89902. * @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.
  89903. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89904. */
  89905. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89906. /**
  89907. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89908. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89909. * The `data` are either a numeric array either a Float32Array.
  89910. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89911. * 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).
  89912. * Note that a new underlying VertexBuffer object is created each call.
  89913. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89914. *
  89915. * Possible `kind` values :
  89916. * - VertexBuffer.PositionKind
  89917. * - VertexBuffer.UVKind
  89918. * - VertexBuffer.UV2Kind
  89919. * - VertexBuffer.UV3Kind
  89920. * - VertexBuffer.UV4Kind
  89921. * - VertexBuffer.UV5Kind
  89922. * - VertexBuffer.UV6Kind
  89923. * - VertexBuffer.ColorKind
  89924. * - VertexBuffer.MatricesIndicesKind
  89925. * - VertexBuffer.MatricesIndicesExtraKind
  89926. * - VertexBuffer.MatricesWeightsKind
  89927. * - VertexBuffer.MatricesWeightsExtraKind
  89928. *
  89929. * Returns the Mesh.
  89930. */
  89931. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89932. /**
  89933. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89934. * If the mesh has no geometry, it is simply returned as it is.
  89935. * The `data` are either a numeric array either a Float32Array.
  89936. * No new underlying VertexBuffer object is created.
  89937. * 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.
  89938. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89939. *
  89940. * Possible `kind` values :
  89941. * - VertexBuffer.PositionKind
  89942. * - VertexBuffer.UVKind
  89943. * - VertexBuffer.UV2Kind
  89944. * - VertexBuffer.UV3Kind
  89945. * - VertexBuffer.UV4Kind
  89946. * - VertexBuffer.UV5Kind
  89947. * - VertexBuffer.UV6Kind
  89948. * - VertexBuffer.ColorKind
  89949. * - VertexBuffer.MatricesIndicesKind
  89950. * - VertexBuffer.MatricesIndicesExtraKind
  89951. * - VertexBuffer.MatricesWeightsKind
  89952. * - VertexBuffer.MatricesWeightsExtraKind
  89953. *
  89954. * Returns the Mesh.
  89955. */
  89956. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89957. /**
  89958. * Sets the mesh indices.
  89959. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89960. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89961. * This method creates a new index buffer each call.
  89962. * Returns the Mesh.
  89963. */
  89964. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89965. /**
  89966. * Boolean : True if the mesh owns the requested kind of data.
  89967. */
  89968. isVerticesDataPresent(kind: string): boolean;
  89969. /**
  89970. * Returns an array of indices (IndicesArray).
  89971. */
  89972. getIndices(): Nullable<IndicesArray>;
  89973. get _positions(): Nullable<Vector3[]>;
  89974. /**
  89975. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89976. * This means the mesh underlying bounding box and sphere are recomputed.
  89977. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89978. * @returns the current mesh
  89979. */
  89980. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89981. /** @hidden */
  89982. _preActivate(): InstancedMesh;
  89983. /** @hidden */
  89984. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89985. /** @hidden */
  89986. _postActivate(): void;
  89987. getWorldMatrix(): Matrix;
  89988. get isAnInstance(): boolean;
  89989. /**
  89990. * Returns the current associated LOD AbstractMesh.
  89991. */
  89992. getLOD(camera: Camera): AbstractMesh;
  89993. /** @hidden */
  89994. _syncSubMeshes(): InstancedMesh;
  89995. /** @hidden */
  89996. _generatePointsArray(): boolean;
  89997. /**
  89998. * Creates a new InstancedMesh from the current mesh.
  89999. * - name (string) : the cloned mesh name
  90000. * - newParent (optional Node) : the optional Node to parent the clone to.
  90001. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  90002. *
  90003. * Returns the clone.
  90004. */
  90005. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90006. /**
  90007. * Disposes the InstancedMesh.
  90008. * Returns nothing.
  90009. */
  90010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90011. }
  90012. interface Mesh {
  90013. /**
  90014. * Register a custom buffer that will be instanced
  90015. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90016. * @param kind defines the buffer kind
  90017. * @param stride defines the stride in floats
  90018. */
  90019. registerInstancedBuffer(kind: string, stride: number): void;
  90020. /** @hidden */
  90021. _userInstancedBuffersStorage: {
  90022. data: {
  90023. [key: string]: Float32Array;
  90024. };
  90025. sizes: {
  90026. [key: string]: number;
  90027. };
  90028. vertexBuffers: {
  90029. [key: string]: Nullable<VertexBuffer>;
  90030. };
  90031. strides: {
  90032. [key: string]: number;
  90033. };
  90034. };
  90035. }
  90036. interface AbstractMesh {
  90037. /**
  90038. * Object used to store instanced buffers defined by user
  90039. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90040. */
  90041. instancedBuffers: {
  90042. [key: string]: any;
  90043. };
  90044. }
  90045. }
  90046. declare module BABYLON {
  90047. /**
  90048. * Defines the options associated with the creation of a shader material.
  90049. */
  90050. export interface IShaderMaterialOptions {
  90051. /**
  90052. * Does the material work in alpha blend mode
  90053. */
  90054. needAlphaBlending: boolean;
  90055. /**
  90056. * Does the material work in alpha test mode
  90057. */
  90058. needAlphaTesting: boolean;
  90059. /**
  90060. * The list of attribute names used in the shader
  90061. */
  90062. attributes: string[];
  90063. /**
  90064. * The list of unifrom names used in the shader
  90065. */
  90066. uniforms: string[];
  90067. /**
  90068. * The list of UBO names used in the shader
  90069. */
  90070. uniformBuffers: string[];
  90071. /**
  90072. * The list of sampler names used in the shader
  90073. */
  90074. samplers: string[];
  90075. /**
  90076. * The list of defines used in the shader
  90077. */
  90078. defines: string[];
  90079. }
  90080. /**
  90081. * 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.
  90082. *
  90083. * This returned material effects how the mesh will look based on the code in the shaders.
  90084. *
  90085. * @see http://doc.babylonjs.com/how_to/shader_material
  90086. */
  90087. export class ShaderMaterial extends Material {
  90088. private _shaderPath;
  90089. private _options;
  90090. private _textures;
  90091. private _textureArrays;
  90092. private _floats;
  90093. private _ints;
  90094. private _floatsArrays;
  90095. private _colors3;
  90096. private _colors3Arrays;
  90097. private _colors4;
  90098. private _colors4Arrays;
  90099. private _vectors2;
  90100. private _vectors3;
  90101. private _vectors4;
  90102. private _matrices;
  90103. private _matrixArrays;
  90104. private _matrices3x3;
  90105. private _matrices2x2;
  90106. private _vectors2Arrays;
  90107. private _vectors3Arrays;
  90108. private _vectors4Arrays;
  90109. private _cachedWorldViewMatrix;
  90110. private _cachedWorldViewProjectionMatrix;
  90111. private _renderId;
  90112. private _multiview;
  90113. /**
  90114. * Instantiate a new shader material.
  90115. * 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.
  90116. * This returned material effects how the mesh will look based on the code in the shaders.
  90117. * @see http://doc.babylonjs.com/how_to/shader_material
  90118. * @param name Define the name of the material in the scene
  90119. * @param scene Define the scene the material belongs to
  90120. * @param shaderPath Defines the route to the shader code in one of three ways:
  90121. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90122. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90123. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90124. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90125. * @param options Define the options used to create the shader
  90126. */
  90127. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90128. /**
  90129. * Gets the shader path used to define the shader code
  90130. * It can be modified to trigger a new compilation
  90131. */
  90132. get shaderPath(): any;
  90133. /**
  90134. * Sets the shader path used to define the shader code
  90135. * It can be modified to trigger a new compilation
  90136. */
  90137. set shaderPath(shaderPath: any);
  90138. /**
  90139. * Gets the options used to compile the shader.
  90140. * They can be modified to trigger a new compilation
  90141. */
  90142. get options(): IShaderMaterialOptions;
  90143. /**
  90144. * Gets the current class name of the material e.g. "ShaderMaterial"
  90145. * Mainly use in serialization.
  90146. * @returns the class name
  90147. */
  90148. getClassName(): string;
  90149. /**
  90150. * Specifies if the material will require alpha blending
  90151. * @returns a boolean specifying if alpha blending is needed
  90152. */
  90153. needAlphaBlending(): boolean;
  90154. /**
  90155. * Specifies if this material should be rendered in alpha test mode
  90156. * @returns a boolean specifying if an alpha test is needed.
  90157. */
  90158. needAlphaTesting(): boolean;
  90159. private _checkUniform;
  90160. /**
  90161. * Set a texture in the shader.
  90162. * @param name Define the name of the uniform samplers as defined in the shader
  90163. * @param texture Define the texture to bind to this sampler
  90164. * @return the material itself allowing "fluent" like uniform updates
  90165. */
  90166. setTexture(name: string, texture: Texture): ShaderMaterial;
  90167. /**
  90168. * Set a texture array in the shader.
  90169. * @param name Define the name of the uniform sampler array as defined in the shader
  90170. * @param textures Define the list of textures to bind to this sampler
  90171. * @return the material itself allowing "fluent" like uniform updates
  90172. */
  90173. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90174. /**
  90175. * Set a float in the shader.
  90176. * @param name Define the name of the uniform as defined in the shader
  90177. * @param value Define the value to give to the uniform
  90178. * @return the material itself allowing "fluent" like uniform updates
  90179. */
  90180. setFloat(name: string, value: number): ShaderMaterial;
  90181. /**
  90182. * Set a int in the shader.
  90183. * @param name Define the name of the uniform as defined in the shader
  90184. * @param value Define the value to give to the uniform
  90185. * @return the material itself allowing "fluent" like uniform updates
  90186. */
  90187. setInt(name: string, value: number): ShaderMaterial;
  90188. /**
  90189. * Set an array of floats in the shader.
  90190. * @param name Define the name of the uniform as defined in the shader
  90191. * @param value Define the value to give to the uniform
  90192. * @return the material itself allowing "fluent" like uniform updates
  90193. */
  90194. setFloats(name: string, value: number[]): ShaderMaterial;
  90195. /**
  90196. * Set a vec3 in the shader from a Color3.
  90197. * @param name Define the name of the uniform as defined in the shader
  90198. * @param value Define the value to give to the uniform
  90199. * @return the material itself allowing "fluent" like uniform updates
  90200. */
  90201. setColor3(name: string, value: Color3): ShaderMaterial;
  90202. /**
  90203. * Set a vec3 array in the shader from a Color3 array.
  90204. * @param name Define the name of the uniform as defined in the shader
  90205. * @param value Define the value to give to the uniform
  90206. * @return the material itself allowing "fluent" like uniform updates
  90207. */
  90208. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90209. /**
  90210. * Set a vec4 in the shader from a Color4.
  90211. * @param name Define the name of the uniform as defined in the shader
  90212. * @param value Define the value to give to the uniform
  90213. * @return the material itself allowing "fluent" like uniform updates
  90214. */
  90215. setColor4(name: string, value: Color4): ShaderMaterial;
  90216. /**
  90217. * Set a vec4 array in the shader from a Color4 array.
  90218. * @param name Define the name of the uniform as defined in the shader
  90219. * @param value Define the value to give to the uniform
  90220. * @return the material itself allowing "fluent" like uniform updates
  90221. */
  90222. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90223. /**
  90224. * Set a vec2 in the shader from a Vector2.
  90225. * @param name Define the name of the uniform as defined in the shader
  90226. * @param value Define the value to give to the uniform
  90227. * @return the material itself allowing "fluent" like uniform updates
  90228. */
  90229. setVector2(name: string, value: Vector2): ShaderMaterial;
  90230. /**
  90231. * Set a vec3 in the shader from a Vector3.
  90232. * @param name Define the name of the uniform as defined in the shader
  90233. * @param value Define the value to give to the uniform
  90234. * @return the material itself allowing "fluent" like uniform updates
  90235. */
  90236. setVector3(name: string, value: Vector3): ShaderMaterial;
  90237. /**
  90238. * Set a vec4 in the shader from a Vector4.
  90239. * @param name Define the name of the uniform as defined in the shader
  90240. * @param value Define the value to give to the uniform
  90241. * @return the material itself allowing "fluent" like uniform updates
  90242. */
  90243. setVector4(name: string, value: Vector4): ShaderMaterial;
  90244. /**
  90245. * Set a mat4 in the shader from a Matrix.
  90246. * @param name Define the name of the uniform as defined in the shader
  90247. * @param value Define the value to give to the uniform
  90248. * @return the material itself allowing "fluent" like uniform updates
  90249. */
  90250. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90251. /**
  90252. * Set a float32Array in the shader from a matrix array.
  90253. * @param name Define the name of the uniform as defined in the shader
  90254. * @param value Define the value to give to the uniform
  90255. * @return the material itself allowing "fluent" like uniform updates
  90256. */
  90257. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90258. /**
  90259. * Set a mat3 in the shader from a Float32Array.
  90260. * @param name Define the name of the uniform as defined in the shader
  90261. * @param value Define the value to give to the uniform
  90262. * @return the material itself allowing "fluent" like uniform updates
  90263. */
  90264. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90265. /**
  90266. * Set a mat2 in the shader from a Float32Array.
  90267. * @param name Define the name of the uniform as defined in the shader
  90268. * @param value Define the value to give to the uniform
  90269. * @return the material itself allowing "fluent" like uniform updates
  90270. */
  90271. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90272. /**
  90273. * Set a vec2 array in the shader from a number array.
  90274. * @param name Define the name of the uniform as defined in the shader
  90275. * @param value Define the value to give to the uniform
  90276. * @return the material itself allowing "fluent" like uniform updates
  90277. */
  90278. setArray2(name: string, value: number[]): ShaderMaterial;
  90279. /**
  90280. * Set a vec3 array in the shader from a number array.
  90281. * @param name Define the name of the uniform as defined in the shader
  90282. * @param value Define the value to give to the uniform
  90283. * @return the material itself allowing "fluent" like uniform updates
  90284. */
  90285. setArray3(name: string, value: number[]): ShaderMaterial;
  90286. /**
  90287. * Set a vec4 array in the shader from a number array.
  90288. * @param name Define the name of the uniform as defined in the shader
  90289. * @param value Define the value to give to the uniform
  90290. * @return the material itself allowing "fluent" like uniform updates
  90291. */
  90292. setArray4(name: string, value: number[]): ShaderMaterial;
  90293. private _checkCache;
  90294. /**
  90295. * Specifies that the submesh is ready to be used
  90296. * @param mesh defines the mesh to check
  90297. * @param subMesh defines which submesh to check
  90298. * @param useInstances specifies that instances should be used
  90299. * @returns a boolean indicating that the submesh is ready or not
  90300. */
  90301. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90302. /**
  90303. * Checks if the material is ready to render the requested mesh
  90304. * @param mesh Define the mesh to render
  90305. * @param useInstances Define whether or not the material is used with instances
  90306. * @returns true if ready, otherwise false
  90307. */
  90308. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90309. /**
  90310. * Binds the world matrix to the material
  90311. * @param world defines the world transformation matrix
  90312. */
  90313. bindOnlyWorldMatrix(world: Matrix): void;
  90314. /**
  90315. * Binds the material to the mesh
  90316. * @param world defines the world transformation matrix
  90317. * @param mesh defines the mesh to bind the material to
  90318. */
  90319. bind(world: Matrix, mesh?: Mesh): void;
  90320. /**
  90321. * Gets the active textures from the material
  90322. * @returns an array of textures
  90323. */
  90324. getActiveTextures(): BaseTexture[];
  90325. /**
  90326. * Specifies if the material uses a texture
  90327. * @param texture defines the texture to check against the material
  90328. * @returns a boolean specifying if the material uses the texture
  90329. */
  90330. hasTexture(texture: BaseTexture): boolean;
  90331. /**
  90332. * Makes a duplicate of the material, and gives it a new name
  90333. * @param name defines the new name for the duplicated material
  90334. * @returns the cloned material
  90335. */
  90336. clone(name: string): ShaderMaterial;
  90337. /**
  90338. * Disposes the material
  90339. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90340. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90341. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90342. */
  90343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90344. /**
  90345. * Serializes this material in a JSON representation
  90346. * @returns the serialized material object
  90347. */
  90348. serialize(): any;
  90349. /**
  90350. * Creates a shader material from parsed shader material data
  90351. * @param source defines the JSON represnetation of the material
  90352. * @param scene defines the hosting scene
  90353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90354. * @returns a new material
  90355. */
  90356. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90357. }
  90358. }
  90359. declare module BABYLON {
  90360. /** @hidden */
  90361. export var colorPixelShader: {
  90362. name: string;
  90363. shader: string;
  90364. };
  90365. }
  90366. declare module BABYLON {
  90367. /** @hidden */
  90368. export var colorVertexShader: {
  90369. name: string;
  90370. shader: string;
  90371. };
  90372. }
  90373. declare module BABYLON {
  90374. /**
  90375. * Line mesh
  90376. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90377. */
  90378. export class LinesMesh extends Mesh {
  90379. /**
  90380. * If vertex color should be applied to the mesh
  90381. */
  90382. readonly useVertexColor?: boolean | undefined;
  90383. /**
  90384. * If vertex alpha should be applied to the mesh
  90385. */
  90386. readonly useVertexAlpha?: boolean | undefined;
  90387. /**
  90388. * Color of the line (Default: White)
  90389. */
  90390. color: Color3;
  90391. /**
  90392. * Alpha of the line (Default: 1)
  90393. */
  90394. alpha: number;
  90395. /**
  90396. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90397. * This margin is expressed in world space coordinates, so its value may vary.
  90398. * Default value is 0.1
  90399. */
  90400. intersectionThreshold: number;
  90401. private _colorShader;
  90402. private color4;
  90403. /**
  90404. * Creates a new LinesMesh
  90405. * @param name defines the name
  90406. * @param scene defines the hosting scene
  90407. * @param parent defines the parent mesh if any
  90408. * @param source defines the optional source LinesMesh used to clone data from
  90409. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90410. * When false, achieved by calling a clone(), also passing False.
  90411. * This will make creation of children, recursive.
  90412. * @param useVertexColor defines if this LinesMesh supports vertex color
  90413. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90414. */
  90415. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90416. /**
  90417. * If vertex color should be applied to the mesh
  90418. */
  90419. useVertexColor?: boolean | undefined,
  90420. /**
  90421. * If vertex alpha should be applied to the mesh
  90422. */
  90423. useVertexAlpha?: boolean | undefined);
  90424. private _addClipPlaneDefine;
  90425. private _removeClipPlaneDefine;
  90426. isReady(): boolean;
  90427. /**
  90428. * Returns the string "LineMesh"
  90429. */
  90430. getClassName(): string;
  90431. /**
  90432. * @hidden
  90433. */
  90434. get material(): Material;
  90435. /**
  90436. * @hidden
  90437. */
  90438. set material(value: Material);
  90439. /**
  90440. * @hidden
  90441. */
  90442. get checkCollisions(): boolean;
  90443. /** @hidden */
  90444. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90445. /** @hidden */
  90446. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90447. /**
  90448. * Disposes of the line mesh
  90449. * @param doNotRecurse If children should be disposed
  90450. */
  90451. dispose(doNotRecurse?: boolean): void;
  90452. /**
  90453. * Returns a new LineMesh object cloned from the current one.
  90454. */
  90455. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90456. /**
  90457. * Creates a new InstancedLinesMesh object from the mesh model.
  90458. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90459. * @param name defines the name of the new instance
  90460. * @returns a new InstancedLinesMesh
  90461. */
  90462. createInstance(name: string): InstancedLinesMesh;
  90463. }
  90464. /**
  90465. * Creates an instance based on a source LinesMesh
  90466. */
  90467. export class InstancedLinesMesh extends InstancedMesh {
  90468. /**
  90469. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90470. * This margin is expressed in world space coordinates, so its value may vary.
  90471. * Initilized with the intersectionThreshold value of the source LinesMesh
  90472. */
  90473. intersectionThreshold: number;
  90474. constructor(name: string, source: LinesMesh);
  90475. /**
  90476. * Returns the string "InstancedLinesMesh".
  90477. */
  90478. getClassName(): string;
  90479. }
  90480. }
  90481. declare module BABYLON {
  90482. /** @hidden */
  90483. export var linePixelShader: {
  90484. name: string;
  90485. shader: string;
  90486. };
  90487. }
  90488. declare module BABYLON {
  90489. /** @hidden */
  90490. export var lineVertexShader: {
  90491. name: string;
  90492. shader: string;
  90493. };
  90494. }
  90495. declare module BABYLON {
  90496. interface AbstractMesh {
  90497. /**
  90498. * Gets the edgesRenderer associated with the mesh
  90499. */
  90500. edgesRenderer: Nullable<EdgesRenderer>;
  90501. }
  90502. interface LinesMesh {
  90503. /**
  90504. * Enables the edge rendering mode on the mesh.
  90505. * This mode makes the mesh edges visible
  90506. * @param epsilon defines the maximal distance between two angles to detect a face
  90507. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90508. * @returns the currentAbstractMesh
  90509. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90510. */
  90511. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90512. }
  90513. interface InstancedLinesMesh {
  90514. /**
  90515. * Enables the edge rendering mode on the mesh.
  90516. * This mode makes the mesh edges visible
  90517. * @param epsilon defines the maximal distance between two angles to detect a face
  90518. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90519. * @returns the current InstancedLinesMesh
  90520. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90521. */
  90522. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90523. }
  90524. /**
  90525. * Defines the minimum contract an Edges renderer should follow.
  90526. */
  90527. export interface IEdgesRenderer extends IDisposable {
  90528. /**
  90529. * Gets or sets a boolean indicating if the edgesRenderer is active
  90530. */
  90531. isEnabled: boolean;
  90532. /**
  90533. * Renders the edges of the attached mesh,
  90534. */
  90535. render(): void;
  90536. /**
  90537. * Checks wether or not the edges renderer is ready to render.
  90538. * @return true if ready, otherwise false.
  90539. */
  90540. isReady(): boolean;
  90541. }
  90542. /**
  90543. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90544. */
  90545. export class EdgesRenderer implements IEdgesRenderer {
  90546. /**
  90547. * Define the size of the edges with an orthographic camera
  90548. */
  90549. edgesWidthScalerForOrthographic: number;
  90550. /**
  90551. * Define the size of the edges with a perspective camera
  90552. */
  90553. edgesWidthScalerForPerspective: number;
  90554. protected _source: AbstractMesh;
  90555. protected _linesPositions: number[];
  90556. protected _linesNormals: number[];
  90557. protected _linesIndices: number[];
  90558. protected _epsilon: number;
  90559. protected _indicesCount: number;
  90560. protected _lineShader: ShaderMaterial;
  90561. protected _ib: DataBuffer;
  90562. protected _buffers: {
  90563. [key: string]: Nullable<VertexBuffer>;
  90564. };
  90565. protected _checkVerticesInsteadOfIndices: boolean;
  90566. private _meshRebuildObserver;
  90567. private _meshDisposeObserver;
  90568. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90569. isEnabled: boolean;
  90570. /**
  90571. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90572. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90573. * @param source Mesh used to create edges
  90574. * @param epsilon sum of angles in adjacency to check for edge
  90575. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90576. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90577. */
  90578. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90579. protected _prepareRessources(): void;
  90580. /** @hidden */
  90581. _rebuild(): void;
  90582. /**
  90583. * Releases the required resources for the edges renderer
  90584. */
  90585. dispose(): void;
  90586. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90587. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90588. /**
  90589. * Checks if the pair of p0 and p1 is en edge
  90590. * @param faceIndex
  90591. * @param edge
  90592. * @param faceNormals
  90593. * @param p0
  90594. * @param p1
  90595. * @private
  90596. */
  90597. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90598. /**
  90599. * push line into the position, normal and index buffer
  90600. * @protected
  90601. */
  90602. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90603. /**
  90604. * Generates lines edges from adjacencjes
  90605. * @private
  90606. */
  90607. _generateEdgesLines(): void;
  90608. /**
  90609. * Checks wether or not the edges renderer is ready to render.
  90610. * @return true if ready, otherwise false.
  90611. */
  90612. isReady(): boolean;
  90613. /**
  90614. * Renders the edges of the attached mesh,
  90615. */
  90616. render(): void;
  90617. }
  90618. /**
  90619. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90620. */
  90621. export class LineEdgesRenderer extends EdgesRenderer {
  90622. /**
  90623. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90624. * @param source LineMesh used to generate edges
  90625. * @param epsilon not important (specified angle for edge detection)
  90626. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90627. */
  90628. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90629. /**
  90630. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90631. */
  90632. _generateEdgesLines(): void;
  90633. }
  90634. }
  90635. declare module BABYLON {
  90636. /**
  90637. * This represents the object necessary to create a rendering group.
  90638. * This is exclusively used and created by the rendering manager.
  90639. * To modify the behavior, you use the available helpers in your scene or meshes.
  90640. * @hidden
  90641. */
  90642. export class RenderingGroup {
  90643. index: number;
  90644. private static _zeroVector;
  90645. private _scene;
  90646. private _opaqueSubMeshes;
  90647. private _transparentSubMeshes;
  90648. private _alphaTestSubMeshes;
  90649. private _depthOnlySubMeshes;
  90650. private _particleSystems;
  90651. private _spriteManagers;
  90652. private _opaqueSortCompareFn;
  90653. private _alphaTestSortCompareFn;
  90654. private _transparentSortCompareFn;
  90655. private _renderOpaque;
  90656. private _renderAlphaTest;
  90657. private _renderTransparent;
  90658. /** @hidden */
  90659. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90660. onBeforeTransparentRendering: () => void;
  90661. /**
  90662. * Set the opaque sort comparison function.
  90663. * If null the sub meshes will be render in the order they were created
  90664. */
  90665. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90666. /**
  90667. * Set the alpha test sort comparison function.
  90668. * If null the sub meshes will be render in the order they were created
  90669. */
  90670. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90671. /**
  90672. * Set the transparent sort comparison function.
  90673. * If null the sub meshes will be render in the order they were created
  90674. */
  90675. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90676. /**
  90677. * Creates a new rendering group.
  90678. * @param index The rendering group index
  90679. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90680. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90681. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90682. */
  90683. 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>);
  90684. /**
  90685. * Render all the sub meshes contained in the group.
  90686. * @param customRenderFunction Used to override the default render behaviour of the group.
  90687. * @returns true if rendered some submeshes.
  90688. */
  90689. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90690. /**
  90691. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90692. * @param subMeshes The submeshes to render
  90693. */
  90694. private renderOpaqueSorted;
  90695. /**
  90696. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90697. * @param subMeshes The submeshes to render
  90698. */
  90699. private renderAlphaTestSorted;
  90700. /**
  90701. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90702. * @param subMeshes The submeshes to render
  90703. */
  90704. private renderTransparentSorted;
  90705. /**
  90706. * Renders the submeshes in a specified order.
  90707. * @param subMeshes The submeshes to sort before render
  90708. * @param sortCompareFn The comparison function use to sort
  90709. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90710. * @param transparent Specifies to activate blending if true
  90711. */
  90712. private static renderSorted;
  90713. /**
  90714. * Renders the submeshes in the order they were dispatched (no sort applied).
  90715. * @param subMeshes The submeshes to render
  90716. */
  90717. private static renderUnsorted;
  90718. /**
  90719. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90720. * are rendered back to front if in the same alpha index.
  90721. *
  90722. * @param a The first submesh
  90723. * @param b The second submesh
  90724. * @returns The result of the comparison
  90725. */
  90726. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90727. /**
  90728. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90729. * are rendered back to front.
  90730. *
  90731. * @param a The first submesh
  90732. * @param b The second submesh
  90733. * @returns The result of the comparison
  90734. */
  90735. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90736. /**
  90737. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90738. * are rendered front to back (prevent overdraw).
  90739. *
  90740. * @param a The first submesh
  90741. * @param b The second submesh
  90742. * @returns The result of the comparison
  90743. */
  90744. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90745. /**
  90746. * Resets the different lists of submeshes to prepare a new frame.
  90747. */
  90748. prepare(): void;
  90749. dispose(): void;
  90750. /**
  90751. * Inserts the submesh in its correct queue depending on its material.
  90752. * @param subMesh The submesh to dispatch
  90753. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90754. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90755. */
  90756. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90757. dispatchSprites(spriteManager: ISpriteManager): void;
  90758. dispatchParticles(particleSystem: IParticleSystem): void;
  90759. private _renderParticles;
  90760. private _renderSprites;
  90761. }
  90762. }
  90763. declare module BABYLON {
  90764. /**
  90765. * Interface describing the different options available in the rendering manager
  90766. * regarding Auto Clear between groups.
  90767. */
  90768. export interface IRenderingManagerAutoClearSetup {
  90769. /**
  90770. * Defines whether or not autoclear is enable.
  90771. */
  90772. autoClear: boolean;
  90773. /**
  90774. * Defines whether or not to autoclear the depth buffer.
  90775. */
  90776. depth: boolean;
  90777. /**
  90778. * Defines whether or not to autoclear the stencil buffer.
  90779. */
  90780. stencil: boolean;
  90781. }
  90782. /**
  90783. * This class is used by the onRenderingGroupObservable
  90784. */
  90785. export class RenderingGroupInfo {
  90786. /**
  90787. * The Scene that being rendered
  90788. */
  90789. scene: Scene;
  90790. /**
  90791. * The camera currently used for the rendering pass
  90792. */
  90793. camera: Nullable<Camera>;
  90794. /**
  90795. * The ID of the renderingGroup being processed
  90796. */
  90797. renderingGroupId: number;
  90798. }
  90799. /**
  90800. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90801. * It is enable to manage the different groups as well as the different necessary sort functions.
  90802. * This should not be used directly aside of the few static configurations
  90803. */
  90804. export class RenderingManager {
  90805. /**
  90806. * The max id used for rendering groups (not included)
  90807. */
  90808. static MAX_RENDERINGGROUPS: number;
  90809. /**
  90810. * The min id used for rendering groups (included)
  90811. */
  90812. static MIN_RENDERINGGROUPS: number;
  90813. /**
  90814. * Used to globally prevent autoclearing scenes.
  90815. */
  90816. static AUTOCLEAR: boolean;
  90817. /**
  90818. * @hidden
  90819. */
  90820. _useSceneAutoClearSetup: boolean;
  90821. private _scene;
  90822. private _renderingGroups;
  90823. private _depthStencilBufferAlreadyCleaned;
  90824. private _autoClearDepthStencil;
  90825. private _customOpaqueSortCompareFn;
  90826. private _customAlphaTestSortCompareFn;
  90827. private _customTransparentSortCompareFn;
  90828. private _renderingGroupInfo;
  90829. /**
  90830. * Instantiates a new rendering group for a particular scene
  90831. * @param scene Defines the scene the groups belongs to
  90832. */
  90833. constructor(scene: Scene);
  90834. private _clearDepthStencilBuffer;
  90835. /**
  90836. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90837. * @hidden
  90838. */
  90839. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90840. /**
  90841. * Resets the different information of the group to prepare a new frame
  90842. * @hidden
  90843. */
  90844. reset(): void;
  90845. /**
  90846. * Dispose and release the group and its associated resources.
  90847. * @hidden
  90848. */
  90849. dispose(): void;
  90850. /**
  90851. * Clear the info related to rendering groups preventing retention points during dispose.
  90852. */
  90853. freeRenderingGroups(): void;
  90854. private _prepareRenderingGroup;
  90855. /**
  90856. * Add a sprite manager to the rendering manager in order to render it this frame.
  90857. * @param spriteManager Define the sprite manager to render
  90858. */
  90859. dispatchSprites(spriteManager: ISpriteManager): void;
  90860. /**
  90861. * Add a particle system to the rendering manager in order to render it this frame.
  90862. * @param particleSystem Define the particle system to render
  90863. */
  90864. dispatchParticles(particleSystem: IParticleSystem): void;
  90865. /**
  90866. * Add a submesh to the manager in order to render it this frame
  90867. * @param subMesh The submesh to dispatch
  90868. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90869. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90870. */
  90871. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90872. /**
  90873. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90874. * This allowed control for front to back rendering or reversly depending of the special needs.
  90875. *
  90876. * @param renderingGroupId The rendering group id corresponding to its index
  90877. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90878. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90879. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90880. */
  90881. 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;
  90882. /**
  90883. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90884. *
  90885. * @param renderingGroupId The rendering group id corresponding to its index
  90886. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90887. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90888. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90889. */
  90890. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90891. /**
  90892. * Gets the current auto clear configuration for one rendering group of the rendering
  90893. * manager.
  90894. * @param index the rendering group index to get the information for
  90895. * @returns The auto clear setup for the requested rendering group
  90896. */
  90897. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90898. }
  90899. }
  90900. declare module BABYLON {
  90901. /**
  90902. * This Helps creating a texture that will be created from a camera in your scene.
  90903. * It is basically a dynamic texture that could be used to create special effects for instance.
  90904. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90905. */
  90906. export class RenderTargetTexture extends Texture {
  90907. isCube: boolean;
  90908. /**
  90909. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90910. */
  90911. static readonly REFRESHRATE_RENDER_ONCE: number;
  90912. /**
  90913. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90914. */
  90915. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90916. /**
  90917. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90918. * the central point of your effect and can save a lot of performances.
  90919. */
  90920. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90921. /**
  90922. * Use this predicate to dynamically define the list of mesh you want to render.
  90923. * If set, the renderList property will be overwritten.
  90924. */
  90925. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90926. private _renderList;
  90927. /**
  90928. * Use this list to define the list of mesh you want to render.
  90929. */
  90930. get renderList(): Nullable<Array<AbstractMesh>>;
  90931. set renderList(value: Nullable<Array<AbstractMesh>>);
  90932. private _hookArray;
  90933. /**
  90934. * Define if particles should be rendered in your texture.
  90935. */
  90936. renderParticles: boolean;
  90937. /**
  90938. * Define if sprites should be rendered in your texture.
  90939. */
  90940. renderSprites: boolean;
  90941. /**
  90942. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90943. */
  90944. coordinatesMode: number;
  90945. /**
  90946. * Define the camera used to render the texture.
  90947. */
  90948. activeCamera: Nullable<Camera>;
  90949. /**
  90950. * Override the render function of the texture with your own one.
  90951. */
  90952. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90953. /**
  90954. * Define if camera post processes should be use while rendering the texture.
  90955. */
  90956. useCameraPostProcesses: boolean;
  90957. /**
  90958. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90959. */
  90960. ignoreCameraViewport: boolean;
  90961. private _postProcessManager;
  90962. private _postProcesses;
  90963. private _resizeObserver;
  90964. /**
  90965. * An event triggered when the texture is unbind.
  90966. */
  90967. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90968. /**
  90969. * An event triggered when the texture is unbind.
  90970. */
  90971. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90972. private _onAfterUnbindObserver;
  90973. /**
  90974. * Set a after unbind callback in the texture.
  90975. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90976. */
  90977. set onAfterUnbind(callback: () => void);
  90978. /**
  90979. * An event triggered before rendering the texture
  90980. */
  90981. onBeforeRenderObservable: Observable<number>;
  90982. private _onBeforeRenderObserver;
  90983. /**
  90984. * Set a before render callback in the texture.
  90985. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90986. */
  90987. set onBeforeRender(callback: (faceIndex: number) => void);
  90988. /**
  90989. * An event triggered after rendering the texture
  90990. */
  90991. onAfterRenderObservable: Observable<number>;
  90992. private _onAfterRenderObserver;
  90993. /**
  90994. * Set a after render callback in the texture.
  90995. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90996. */
  90997. set onAfterRender(callback: (faceIndex: number) => void);
  90998. /**
  90999. * An event triggered after the texture clear
  91000. */
  91001. onClearObservable: Observable<Engine>;
  91002. private _onClearObserver;
  91003. /**
  91004. * Set a clear callback in the texture.
  91005. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  91006. */
  91007. set onClear(callback: (Engine: Engine) => void);
  91008. /**
  91009. * An event triggered when the texture is resized.
  91010. */
  91011. onResizeObservable: Observable<RenderTargetTexture>;
  91012. /**
  91013. * Define the clear color of the Render Target if it should be different from the scene.
  91014. */
  91015. clearColor: Color4;
  91016. protected _size: number | {
  91017. width: number;
  91018. height: number;
  91019. };
  91020. protected _initialSizeParameter: number | {
  91021. width: number;
  91022. height: number;
  91023. } | {
  91024. ratio: number;
  91025. };
  91026. protected _sizeRatio: Nullable<number>;
  91027. /** @hidden */
  91028. _generateMipMaps: boolean;
  91029. protected _renderingManager: RenderingManager;
  91030. /** @hidden */
  91031. _waitingRenderList: string[];
  91032. protected _doNotChangeAspectRatio: boolean;
  91033. protected _currentRefreshId: number;
  91034. protected _refreshRate: number;
  91035. protected _textureMatrix: Matrix;
  91036. protected _samples: number;
  91037. protected _renderTargetOptions: RenderTargetCreationOptions;
  91038. /**
  91039. * Gets render target creation options that were used.
  91040. */
  91041. get renderTargetOptions(): RenderTargetCreationOptions;
  91042. protected _engine: Engine;
  91043. protected _onRatioRescale(): void;
  91044. /**
  91045. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  91046. * It must define where the camera used to render the texture is set
  91047. */
  91048. boundingBoxPosition: Vector3;
  91049. private _boundingBoxSize;
  91050. /**
  91051. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91052. * When defined, the cubemap will switch to local mode
  91053. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91054. * @example https://www.babylonjs-playground.com/#RNASML
  91055. */
  91056. set boundingBoxSize(value: Vector3);
  91057. get boundingBoxSize(): Vector3;
  91058. /**
  91059. * In case the RTT has been created with a depth texture, get the associated
  91060. * depth texture.
  91061. * Otherwise, return null.
  91062. */
  91063. depthStencilTexture: Nullable<InternalTexture>;
  91064. /**
  91065. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91066. * or used a shadow, depth texture...
  91067. * @param name The friendly name of the texture
  91068. * @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)
  91069. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91070. * @param generateMipMaps True if mip maps need to be generated after render.
  91071. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91072. * @param type The type of the buffer in the RTT (int, half float, float...)
  91073. * @param isCube True if a cube texture needs to be created
  91074. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91075. * @param generateDepthBuffer True to generate a depth buffer
  91076. * @param generateStencilBuffer True to generate a stencil buffer
  91077. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91078. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91079. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91080. */
  91081. constructor(name: string, size: number | {
  91082. width: number;
  91083. height: number;
  91084. } | {
  91085. ratio: number;
  91086. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91087. /**
  91088. * Creates a depth stencil texture.
  91089. * This is only available in WebGL 2 or with the depth texture extension available.
  91090. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91091. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91092. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91093. */
  91094. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91095. private _processSizeParameter;
  91096. /**
  91097. * Define the number of samples to use in case of MSAA.
  91098. * It defaults to one meaning no MSAA has been enabled.
  91099. */
  91100. get samples(): number;
  91101. set samples(value: number);
  91102. /**
  91103. * Resets the refresh counter of the texture and start bak from scratch.
  91104. * Could be useful to regenerate the texture if it is setup to render only once.
  91105. */
  91106. resetRefreshCounter(): void;
  91107. /**
  91108. * Define the refresh rate of the texture or the rendering frequency.
  91109. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91110. */
  91111. get refreshRate(): number;
  91112. set refreshRate(value: number);
  91113. /**
  91114. * Adds a post process to the render target rendering passes.
  91115. * @param postProcess define the post process to add
  91116. */
  91117. addPostProcess(postProcess: PostProcess): void;
  91118. /**
  91119. * Clear all the post processes attached to the render target
  91120. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91121. */
  91122. clearPostProcesses(dispose?: boolean): void;
  91123. /**
  91124. * Remove one of the post process from the list of attached post processes to the texture
  91125. * @param postProcess define the post process to remove from the list
  91126. */
  91127. removePostProcess(postProcess: PostProcess): void;
  91128. /** @hidden */
  91129. _shouldRender(): boolean;
  91130. /**
  91131. * Gets the actual render size of the texture.
  91132. * @returns the width of the render size
  91133. */
  91134. getRenderSize(): number;
  91135. /**
  91136. * Gets the actual render width of the texture.
  91137. * @returns the width of the render size
  91138. */
  91139. getRenderWidth(): number;
  91140. /**
  91141. * Gets the actual render height of the texture.
  91142. * @returns the height of the render size
  91143. */
  91144. getRenderHeight(): number;
  91145. /**
  91146. * Get if the texture can be rescaled or not.
  91147. */
  91148. get canRescale(): boolean;
  91149. /**
  91150. * Resize the texture using a ratio.
  91151. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91152. */
  91153. scale(ratio: number): void;
  91154. /**
  91155. * Get the texture reflection matrix used to rotate/transform the reflection.
  91156. * @returns the reflection matrix
  91157. */
  91158. getReflectionTextureMatrix(): Matrix;
  91159. /**
  91160. * Resize the texture to a new desired size.
  91161. * Be carrefull as it will recreate all the data in the new texture.
  91162. * @param size Define the new size. It can be:
  91163. * - a number for squared texture,
  91164. * - an object containing { width: number, height: number }
  91165. * - or an object containing a ratio { ratio: number }
  91166. */
  91167. resize(size: number | {
  91168. width: number;
  91169. height: number;
  91170. } | {
  91171. ratio: number;
  91172. }): void;
  91173. /**
  91174. * Renders all the objects from the render list into the texture.
  91175. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91176. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91177. */
  91178. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91179. private _bestReflectionRenderTargetDimension;
  91180. /**
  91181. * @hidden
  91182. * @param faceIndex face index to bind to if this is a cubetexture
  91183. */
  91184. _bindFrameBuffer(faceIndex?: number): void;
  91185. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91186. private renderToTarget;
  91187. /**
  91188. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91189. * This allowed control for front to back rendering or reversly depending of the special needs.
  91190. *
  91191. * @param renderingGroupId The rendering group id corresponding to its index
  91192. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91193. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91194. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91195. */
  91196. 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;
  91197. /**
  91198. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91199. *
  91200. * @param renderingGroupId The rendering group id corresponding to its index
  91201. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91202. */
  91203. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91204. /**
  91205. * Clones the texture.
  91206. * @returns the cloned texture
  91207. */
  91208. clone(): RenderTargetTexture;
  91209. /**
  91210. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91211. * @returns The JSON representation of the texture
  91212. */
  91213. serialize(): any;
  91214. /**
  91215. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91216. */
  91217. disposeFramebufferObjects(): void;
  91218. /**
  91219. * Dispose the texture and release its associated resources.
  91220. */
  91221. dispose(): void;
  91222. /** @hidden */
  91223. _rebuild(): void;
  91224. /**
  91225. * Clear the info related to rendering groups preventing retention point in material dispose.
  91226. */
  91227. freeRenderingGroups(): void;
  91228. /**
  91229. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91230. * @returns the view count
  91231. */
  91232. getViewCount(): number;
  91233. }
  91234. }
  91235. declare module BABYLON {
  91236. /**
  91237. * Options for compiling materials.
  91238. */
  91239. export interface IMaterialCompilationOptions {
  91240. /**
  91241. * Defines whether clip planes are enabled.
  91242. */
  91243. clipPlane: boolean;
  91244. /**
  91245. * Defines whether instances are enabled.
  91246. */
  91247. useInstances: boolean;
  91248. }
  91249. /**
  91250. * Base class for the main features of a material in Babylon.js
  91251. */
  91252. export class Material implements IAnimatable {
  91253. /**
  91254. * Returns the triangle fill mode
  91255. */
  91256. static readonly TriangleFillMode: number;
  91257. /**
  91258. * Returns the wireframe mode
  91259. */
  91260. static readonly WireFrameFillMode: number;
  91261. /**
  91262. * Returns the point fill mode
  91263. */
  91264. static readonly PointFillMode: number;
  91265. /**
  91266. * Returns the point list draw mode
  91267. */
  91268. static readonly PointListDrawMode: number;
  91269. /**
  91270. * Returns the line list draw mode
  91271. */
  91272. static readonly LineListDrawMode: number;
  91273. /**
  91274. * Returns the line loop draw mode
  91275. */
  91276. static readonly LineLoopDrawMode: number;
  91277. /**
  91278. * Returns the line strip draw mode
  91279. */
  91280. static readonly LineStripDrawMode: number;
  91281. /**
  91282. * Returns the triangle strip draw mode
  91283. */
  91284. static readonly TriangleStripDrawMode: number;
  91285. /**
  91286. * Returns the triangle fan draw mode
  91287. */
  91288. static readonly TriangleFanDrawMode: number;
  91289. /**
  91290. * Stores the clock-wise side orientation
  91291. */
  91292. static readonly ClockWiseSideOrientation: number;
  91293. /**
  91294. * Stores the counter clock-wise side orientation
  91295. */
  91296. static readonly CounterClockWiseSideOrientation: number;
  91297. /**
  91298. * The dirty texture flag value
  91299. */
  91300. static readonly TextureDirtyFlag: number;
  91301. /**
  91302. * The dirty light flag value
  91303. */
  91304. static readonly LightDirtyFlag: number;
  91305. /**
  91306. * The dirty fresnel flag value
  91307. */
  91308. static readonly FresnelDirtyFlag: number;
  91309. /**
  91310. * The dirty attribute flag value
  91311. */
  91312. static readonly AttributesDirtyFlag: number;
  91313. /**
  91314. * The dirty misc flag value
  91315. */
  91316. static readonly MiscDirtyFlag: number;
  91317. /**
  91318. * The all dirty flag value
  91319. */
  91320. static readonly AllDirtyFlag: number;
  91321. /**
  91322. * The ID of the material
  91323. */
  91324. id: string;
  91325. /**
  91326. * Gets or sets the unique id of the material
  91327. */
  91328. uniqueId: number;
  91329. /**
  91330. * The name of the material
  91331. */
  91332. name: string;
  91333. /**
  91334. * Gets or sets user defined metadata
  91335. */
  91336. metadata: any;
  91337. /**
  91338. * For internal use only. Please do not use.
  91339. */
  91340. reservedDataStore: any;
  91341. /**
  91342. * Specifies if the ready state should be checked on each call
  91343. */
  91344. checkReadyOnEveryCall: boolean;
  91345. /**
  91346. * Specifies if the ready state should be checked once
  91347. */
  91348. checkReadyOnlyOnce: boolean;
  91349. /**
  91350. * The state of the material
  91351. */
  91352. state: string;
  91353. /**
  91354. * The alpha value of the material
  91355. */
  91356. protected _alpha: number;
  91357. /**
  91358. * List of inspectable custom properties (used by the Inspector)
  91359. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91360. */
  91361. inspectableCustomProperties: IInspectable[];
  91362. /**
  91363. * Sets the alpha value of the material
  91364. */
  91365. set alpha(value: number);
  91366. /**
  91367. * Gets the alpha value of the material
  91368. */
  91369. get alpha(): number;
  91370. /**
  91371. * Specifies if back face culling is enabled
  91372. */
  91373. protected _backFaceCulling: boolean;
  91374. /**
  91375. * Sets the back-face culling state
  91376. */
  91377. set backFaceCulling(value: boolean);
  91378. /**
  91379. * Gets the back-face culling state
  91380. */
  91381. get backFaceCulling(): boolean;
  91382. /**
  91383. * Stores the value for side orientation
  91384. */
  91385. sideOrientation: number;
  91386. /**
  91387. * Callback triggered when the material is compiled
  91388. */
  91389. onCompiled: Nullable<(effect: Effect) => void>;
  91390. /**
  91391. * Callback triggered when an error occurs
  91392. */
  91393. onError: Nullable<(effect: Effect, errors: string) => void>;
  91394. /**
  91395. * Callback triggered to get the render target textures
  91396. */
  91397. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91398. /**
  91399. * Gets a boolean indicating that current material needs to register RTT
  91400. */
  91401. get hasRenderTargetTextures(): boolean;
  91402. /**
  91403. * Specifies if the material should be serialized
  91404. */
  91405. doNotSerialize: boolean;
  91406. /**
  91407. * @hidden
  91408. */
  91409. _storeEffectOnSubMeshes: boolean;
  91410. /**
  91411. * Stores the animations for the material
  91412. */
  91413. animations: Nullable<Array<Animation>>;
  91414. /**
  91415. * An event triggered when the material is disposed
  91416. */
  91417. onDisposeObservable: Observable<Material>;
  91418. /**
  91419. * An observer which watches for dispose events
  91420. */
  91421. private _onDisposeObserver;
  91422. private _onUnBindObservable;
  91423. /**
  91424. * Called during a dispose event
  91425. */
  91426. set onDispose(callback: () => void);
  91427. private _onBindObservable;
  91428. /**
  91429. * An event triggered when the material is bound
  91430. */
  91431. get onBindObservable(): Observable<AbstractMesh>;
  91432. /**
  91433. * An observer which watches for bind events
  91434. */
  91435. private _onBindObserver;
  91436. /**
  91437. * Called during a bind event
  91438. */
  91439. set onBind(callback: (Mesh: AbstractMesh) => void);
  91440. /**
  91441. * An event triggered when the material is unbound
  91442. */
  91443. get onUnBindObservable(): Observable<Material>;
  91444. /**
  91445. * Stores the value of the alpha mode
  91446. */
  91447. private _alphaMode;
  91448. /**
  91449. * Sets the value of the alpha mode.
  91450. *
  91451. * | Value | Type | Description |
  91452. * | --- | --- | --- |
  91453. * | 0 | ALPHA_DISABLE | |
  91454. * | 1 | ALPHA_ADD | |
  91455. * | 2 | ALPHA_COMBINE | |
  91456. * | 3 | ALPHA_SUBTRACT | |
  91457. * | 4 | ALPHA_MULTIPLY | |
  91458. * | 5 | ALPHA_MAXIMIZED | |
  91459. * | 6 | ALPHA_ONEONE | |
  91460. * | 7 | ALPHA_PREMULTIPLIED | |
  91461. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91462. * | 9 | ALPHA_INTERPOLATE | |
  91463. * | 10 | ALPHA_SCREENMODE | |
  91464. *
  91465. */
  91466. set alphaMode(value: number);
  91467. /**
  91468. * Gets the value of the alpha mode
  91469. */
  91470. get alphaMode(): number;
  91471. /**
  91472. * Stores the state of the need depth pre-pass value
  91473. */
  91474. private _needDepthPrePass;
  91475. /**
  91476. * Sets the need depth pre-pass value
  91477. */
  91478. set needDepthPrePass(value: boolean);
  91479. /**
  91480. * Gets the depth pre-pass value
  91481. */
  91482. get needDepthPrePass(): boolean;
  91483. /**
  91484. * Specifies if depth writing should be disabled
  91485. */
  91486. disableDepthWrite: boolean;
  91487. /**
  91488. * Specifies if depth writing should be forced
  91489. */
  91490. forceDepthWrite: boolean;
  91491. /**
  91492. * Specifies the depth function that should be used. 0 means the default engine function
  91493. */
  91494. depthFunction: number;
  91495. /**
  91496. * Specifies if there should be a separate pass for culling
  91497. */
  91498. separateCullingPass: boolean;
  91499. /**
  91500. * Stores the state specifing if fog should be enabled
  91501. */
  91502. private _fogEnabled;
  91503. /**
  91504. * Sets the state for enabling fog
  91505. */
  91506. set fogEnabled(value: boolean);
  91507. /**
  91508. * Gets the value of the fog enabled state
  91509. */
  91510. get fogEnabled(): boolean;
  91511. /**
  91512. * Stores the size of points
  91513. */
  91514. pointSize: number;
  91515. /**
  91516. * Stores the z offset value
  91517. */
  91518. zOffset: number;
  91519. /**
  91520. * Gets a value specifying if wireframe mode is enabled
  91521. */
  91522. get wireframe(): boolean;
  91523. /**
  91524. * Sets the state of wireframe mode
  91525. */
  91526. set wireframe(value: boolean);
  91527. /**
  91528. * Gets the value specifying if point clouds are enabled
  91529. */
  91530. get pointsCloud(): boolean;
  91531. /**
  91532. * Sets the state of point cloud mode
  91533. */
  91534. set pointsCloud(value: boolean);
  91535. /**
  91536. * Gets the material fill mode
  91537. */
  91538. get fillMode(): number;
  91539. /**
  91540. * Sets the material fill mode
  91541. */
  91542. set fillMode(value: number);
  91543. /**
  91544. * @hidden
  91545. * Stores the effects for the material
  91546. */
  91547. _effect: Nullable<Effect>;
  91548. /**
  91549. * Specifies if uniform buffers should be used
  91550. */
  91551. private _useUBO;
  91552. /**
  91553. * Stores a reference to the scene
  91554. */
  91555. private _scene;
  91556. /**
  91557. * Stores the fill mode state
  91558. */
  91559. private _fillMode;
  91560. /**
  91561. * Specifies if the depth write state should be cached
  91562. */
  91563. private _cachedDepthWriteState;
  91564. /**
  91565. * Specifies if the depth function state should be cached
  91566. */
  91567. private _cachedDepthFunctionState;
  91568. /**
  91569. * Stores the uniform buffer
  91570. */
  91571. protected _uniformBuffer: UniformBuffer;
  91572. /** @hidden */
  91573. _indexInSceneMaterialArray: number;
  91574. /** @hidden */
  91575. meshMap: Nullable<{
  91576. [id: string]: AbstractMesh | undefined;
  91577. }>;
  91578. /**
  91579. * Creates a material instance
  91580. * @param name defines the name of the material
  91581. * @param scene defines the scene to reference
  91582. * @param doNotAdd specifies if the material should be added to the scene
  91583. */
  91584. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91585. /**
  91586. * Returns a string representation of the current material
  91587. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91588. * @returns a string with material information
  91589. */
  91590. toString(fullDetails?: boolean): string;
  91591. /**
  91592. * Gets the class name of the material
  91593. * @returns a string with the class name of the material
  91594. */
  91595. getClassName(): string;
  91596. /**
  91597. * Specifies if updates for the material been locked
  91598. */
  91599. get isFrozen(): boolean;
  91600. /**
  91601. * Locks updates for the material
  91602. */
  91603. freeze(): void;
  91604. /**
  91605. * Unlocks updates for the material
  91606. */
  91607. unfreeze(): void;
  91608. /**
  91609. * Specifies if the material is ready to be used
  91610. * @param mesh defines the mesh to check
  91611. * @param useInstances specifies if instances should be used
  91612. * @returns a boolean indicating if the material is ready to be used
  91613. */
  91614. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91615. /**
  91616. * Specifies that the submesh is ready to be used
  91617. * @param mesh defines the mesh to check
  91618. * @param subMesh defines which submesh to check
  91619. * @param useInstances specifies that instances should be used
  91620. * @returns a boolean indicating that the submesh is ready or not
  91621. */
  91622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91623. /**
  91624. * Returns the material effect
  91625. * @returns the effect associated with the material
  91626. */
  91627. getEffect(): Nullable<Effect>;
  91628. /**
  91629. * Returns the current scene
  91630. * @returns a Scene
  91631. */
  91632. getScene(): Scene;
  91633. /**
  91634. * Specifies if the material will require alpha blending
  91635. * @returns a boolean specifying if alpha blending is needed
  91636. */
  91637. needAlphaBlending(): boolean;
  91638. /**
  91639. * Specifies if the mesh will require alpha blending
  91640. * @param mesh defines the mesh to check
  91641. * @returns a boolean specifying if alpha blending is needed for the mesh
  91642. */
  91643. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91644. /**
  91645. * Specifies if this material should be rendered in alpha test mode
  91646. * @returns a boolean specifying if an alpha test is needed.
  91647. */
  91648. needAlphaTesting(): boolean;
  91649. /**
  91650. * Gets the texture used for the alpha test
  91651. * @returns the texture to use for alpha testing
  91652. */
  91653. getAlphaTestTexture(): Nullable<BaseTexture>;
  91654. /**
  91655. * Marks the material to indicate that it needs to be re-calculated
  91656. */
  91657. markDirty(): void;
  91658. /** @hidden */
  91659. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91660. /**
  91661. * Binds the material to the mesh
  91662. * @param world defines the world transformation matrix
  91663. * @param mesh defines the mesh to bind the material to
  91664. */
  91665. bind(world: Matrix, mesh?: Mesh): void;
  91666. /**
  91667. * Binds the submesh to the material
  91668. * @param world defines the world transformation matrix
  91669. * @param mesh defines the mesh containing the submesh
  91670. * @param subMesh defines the submesh to bind the material to
  91671. */
  91672. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91673. /**
  91674. * Binds the world matrix to the material
  91675. * @param world defines the world transformation matrix
  91676. */
  91677. bindOnlyWorldMatrix(world: Matrix): void;
  91678. /**
  91679. * Binds the scene's uniform buffer to the effect.
  91680. * @param effect defines the effect to bind to the scene uniform buffer
  91681. * @param sceneUbo defines the uniform buffer storing scene data
  91682. */
  91683. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91684. /**
  91685. * Binds the view matrix to the effect
  91686. * @param effect defines the effect to bind the view matrix to
  91687. */
  91688. bindView(effect: Effect): void;
  91689. /**
  91690. * Binds the view projection matrix to the effect
  91691. * @param effect defines the effect to bind the view projection matrix to
  91692. */
  91693. bindViewProjection(effect: Effect): void;
  91694. /**
  91695. * Specifies if material alpha testing should be turned on for the mesh
  91696. * @param mesh defines the mesh to check
  91697. */
  91698. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91699. /**
  91700. * Processes to execute after binding the material to a mesh
  91701. * @param mesh defines the rendered mesh
  91702. */
  91703. protected _afterBind(mesh?: Mesh): void;
  91704. /**
  91705. * Unbinds the material from the mesh
  91706. */
  91707. unbind(): void;
  91708. /**
  91709. * Gets the active textures from the material
  91710. * @returns an array of textures
  91711. */
  91712. getActiveTextures(): BaseTexture[];
  91713. /**
  91714. * Specifies if the material uses a texture
  91715. * @param texture defines the texture to check against the material
  91716. * @returns a boolean specifying if the material uses the texture
  91717. */
  91718. hasTexture(texture: BaseTexture): boolean;
  91719. /**
  91720. * Makes a duplicate of the material, and gives it a new name
  91721. * @param name defines the new name for the duplicated material
  91722. * @returns the cloned material
  91723. */
  91724. clone(name: string): Nullable<Material>;
  91725. /**
  91726. * Gets the meshes bound to the material
  91727. * @returns an array of meshes bound to the material
  91728. */
  91729. getBindedMeshes(): AbstractMesh[];
  91730. /**
  91731. * Force shader compilation
  91732. * @param mesh defines the mesh associated with this material
  91733. * @param onCompiled defines a function to execute once the material is compiled
  91734. * @param options defines the options to configure the compilation
  91735. * @param onError defines a function to execute if the material fails compiling
  91736. */
  91737. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91738. /**
  91739. * Force shader compilation
  91740. * @param mesh defines the mesh that will use this material
  91741. * @param options defines additional options for compiling the shaders
  91742. * @returns a promise that resolves when the compilation completes
  91743. */
  91744. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91745. private static readonly _AllDirtyCallBack;
  91746. private static readonly _ImageProcessingDirtyCallBack;
  91747. private static readonly _TextureDirtyCallBack;
  91748. private static readonly _FresnelDirtyCallBack;
  91749. private static readonly _MiscDirtyCallBack;
  91750. private static readonly _LightsDirtyCallBack;
  91751. private static readonly _AttributeDirtyCallBack;
  91752. private static _FresnelAndMiscDirtyCallBack;
  91753. private static _TextureAndMiscDirtyCallBack;
  91754. private static readonly _DirtyCallbackArray;
  91755. private static readonly _RunDirtyCallBacks;
  91756. /**
  91757. * Marks a define in the material to indicate that it needs to be re-computed
  91758. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91759. */
  91760. markAsDirty(flag: number): void;
  91761. /**
  91762. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91763. * @param func defines a function which checks material defines against the submeshes
  91764. */
  91765. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91766. /**
  91767. * Indicates that we need to re-calculated for all submeshes
  91768. */
  91769. protected _markAllSubMeshesAsAllDirty(): void;
  91770. /**
  91771. * Indicates that image processing needs to be re-calculated for all submeshes
  91772. */
  91773. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91774. /**
  91775. * Indicates that textures need to be re-calculated for all submeshes
  91776. */
  91777. protected _markAllSubMeshesAsTexturesDirty(): void;
  91778. /**
  91779. * Indicates that fresnel needs to be re-calculated for all submeshes
  91780. */
  91781. protected _markAllSubMeshesAsFresnelDirty(): void;
  91782. /**
  91783. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91784. */
  91785. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91786. /**
  91787. * Indicates that lights need to be re-calculated for all submeshes
  91788. */
  91789. protected _markAllSubMeshesAsLightsDirty(): void;
  91790. /**
  91791. * Indicates that attributes need to be re-calculated for all submeshes
  91792. */
  91793. protected _markAllSubMeshesAsAttributesDirty(): void;
  91794. /**
  91795. * Indicates that misc needs to be re-calculated for all submeshes
  91796. */
  91797. protected _markAllSubMeshesAsMiscDirty(): void;
  91798. /**
  91799. * Indicates that textures and misc need to be re-calculated for all submeshes
  91800. */
  91801. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91802. /**
  91803. * Disposes the material
  91804. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91805. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91806. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91807. */
  91808. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91809. /** @hidden */
  91810. private releaseVertexArrayObject;
  91811. /**
  91812. * Serializes this material
  91813. * @returns the serialized material object
  91814. */
  91815. serialize(): any;
  91816. /**
  91817. * Creates a material from parsed material data
  91818. * @param parsedMaterial defines parsed material data
  91819. * @param scene defines the hosting scene
  91820. * @param rootUrl defines the root URL to use to load textures
  91821. * @returns a new material
  91822. */
  91823. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91824. }
  91825. }
  91826. declare module BABYLON {
  91827. /**
  91828. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91829. * separate meshes. This can be use to improve performances.
  91830. * @see http://doc.babylonjs.com/how_to/multi_materials
  91831. */
  91832. export class MultiMaterial extends Material {
  91833. private _subMaterials;
  91834. /**
  91835. * Gets or Sets the list of Materials used within the multi material.
  91836. * They need to be ordered according to the submeshes order in the associated mesh
  91837. */
  91838. get subMaterials(): Nullable<Material>[];
  91839. set subMaterials(value: Nullable<Material>[]);
  91840. /**
  91841. * Function used to align with Node.getChildren()
  91842. * @returns the list of Materials used within the multi material
  91843. */
  91844. getChildren(): Nullable<Material>[];
  91845. /**
  91846. * Instantiates a new Multi Material
  91847. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91848. * separate meshes. This can be use to improve performances.
  91849. * @see http://doc.babylonjs.com/how_to/multi_materials
  91850. * @param name Define the name in the scene
  91851. * @param scene Define the scene the material belongs to
  91852. */
  91853. constructor(name: string, scene: Scene);
  91854. private _hookArray;
  91855. /**
  91856. * Get one of the submaterial by its index in the submaterials array
  91857. * @param index The index to look the sub material at
  91858. * @returns The Material if the index has been defined
  91859. */
  91860. getSubMaterial(index: number): Nullable<Material>;
  91861. /**
  91862. * Get the list of active textures for the whole sub materials list.
  91863. * @returns All the textures that will be used during the rendering
  91864. */
  91865. getActiveTextures(): BaseTexture[];
  91866. /**
  91867. * Gets the current class name of the material e.g. "MultiMaterial"
  91868. * Mainly use in serialization.
  91869. * @returns the class name
  91870. */
  91871. getClassName(): string;
  91872. /**
  91873. * Checks if the material is ready to render the requested sub mesh
  91874. * @param mesh Define the mesh the submesh belongs to
  91875. * @param subMesh Define the sub mesh to look readyness for
  91876. * @param useInstances Define whether or not the material is used with instances
  91877. * @returns true if ready, otherwise false
  91878. */
  91879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91880. /**
  91881. * Clones the current material and its related sub materials
  91882. * @param name Define the name of the newly cloned material
  91883. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91884. * @returns the cloned material
  91885. */
  91886. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91887. /**
  91888. * Serializes the materials into a JSON representation.
  91889. * @returns the JSON representation
  91890. */
  91891. serialize(): any;
  91892. /**
  91893. * Dispose the material and release its associated resources
  91894. * @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)
  91895. * @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)
  91896. * @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)
  91897. */
  91898. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91899. /**
  91900. * Creates a MultiMaterial from parsed MultiMaterial data.
  91901. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91902. * @param scene defines the hosting scene
  91903. * @returns a new MultiMaterial
  91904. */
  91905. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91906. }
  91907. }
  91908. declare module BABYLON {
  91909. /**
  91910. * Base class for submeshes
  91911. */
  91912. export class BaseSubMesh {
  91913. /** @hidden */
  91914. _materialDefines: Nullable<MaterialDefines>;
  91915. /** @hidden */
  91916. _materialEffect: Nullable<Effect>;
  91917. /**
  91918. * Gets material defines used by the effect associated to the sub mesh
  91919. */
  91920. get materialDefines(): Nullable<MaterialDefines>;
  91921. /**
  91922. * Sets material defines used by the effect associated to the sub mesh
  91923. */
  91924. set materialDefines(defines: Nullable<MaterialDefines>);
  91925. /**
  91926. * Gets associated effect
  91927. */
  91928. get effect(): Nullable<Effect>;
  91929. /**
  91930. * Sets associated effect (effect used to render this submesh)
  91931. * @param effect defines the effect to associate with
  91932. * @param defines defines the set of defines used to compile this effect
  91933. */
  91934. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91935. }
  91936. /**
  91937. * Defines a subdivision inside a mesh
  91938. */
  91939. export class SubMesh extends BaseSubMesh implements ICullable {
  91940. /** the material index to use */
  91941. materialIndex: number;
  91942. /** vertex index start */
  91943. verticesStart: number;
  91944. /** vertices count */
  91945. verticesCount: number;
  91946. /** index start */
  91947. indexStart: number;
  91948. /** indices count */
  91949. indexCount: number;
  91950. /** @hidden */
  91951. _linesIndexCount: number;
  91952. private _mesh;
  91953. private _renderingMesh;
  91954. private _boundingInfo;
  91955. private _linesIndexBuffer;
  91956. /** @hidden */
  91957. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91958. /** @hidden */
  91959. _trianglePlanes: Plane[];
  91960. /** @hidden */
  91961. _lastColliderTransformMatrix: Nullable<Matrix>;
  91962. /** @hidden */
  91963. _renderId: number;
  91964. /** @hidden */
  91965. _alphaIndex: number;
  91966. /** @hidden */
  91967. _distanceToCamera: number;
  91968. /** @hidden */
  91969. _id: number;
  91970. private _currentMaterial;
  91971. /**
  91972. * Add a new submesh to a mesh
  91973. * @param materialIndex defines the material index to use
  91974. * @param verticesStart defines vertex index start
  91975. * @param verticesCount defines vertices count
  91976. * @param indexStart defines index start
  91977. * @param indexCount defines indices count
  91978. * @param mesh defines the parent mesh
  91979. * @param renderingMesh defines an optional rendering mesh
  91980. * @param createBoundingBox defines if bounding box should be created for this submesh
  91981. * @returns the new submesh
  91982. */
  91983. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91984. /**
  91985. * Creates a new submesh
  91986. * @param materialIndex defines the material index to use
  91987. * @param verticesStart defines vertex index start
  91988. * @param verticesCount defines vertices count
  91989. * @param indexStart defines index start
  91990. * @param indexCount defines indices count
  91991. * @param mesh defines the parent mesh
  91992. * @param renderingMesh defines an optional rendering mesh
  91993. * @param createBoundingBox defines if bounding box should be created for this submesh
  91994. */
  91995. constructor(
  91996. /** the material index to use */
  91997. materialIndex: number,
  91998. /** vertex index start */
  91999. verticesStart: number,
  92000. /** vertices count */
  92001. verticesCount: number,
  92002. /** index start */
  92003. indexStart: number,
  92004. /** indices count */
  92005. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  92006. /**
  92007. * Returns true if this submesh covers the entire parent mesh
  92008. * @ignorenaming
  92009. */
  92010. get IsGlobal(): boolean;
  92011. /**
  92012. * Returns the submesh BoudingInfo object
  92013. * @returns current bounding info (or mesh's one if the submesh is global)
  92014. */
  92015. getBoundingInfo(): BoundingInfo;
  92016. /**
  92017. * Sets the submesh BoundingInfo
  92018. * @param boundingInfo defines the new bounding info to use
  92019. * @returns the SubMesh
  92020. */
  92021. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  92022. /**
  92023. * Returns the mesh of the current submesh
  92024. * @return the parent mesh
  92025. */
  92026. getMesh(): AbstractMesh;
  92027. /**
  92028. * Returns the rendering mesh of the submesh
  92029. * @returns the rendering mesh (could be different from parent mesh)
  92030. */
  92031. getRenderingMesh(): Mesh;
  92032. /**
  92033. * Returns the submesh material
  92034. * @returns null or the current material
  92035. */
  92036. getMaterial(): Nullable<Material>;
  92037. /**
  92038. * Sets a new updated BoundingInfo object to the submesh
  92039. * @param data defines an optional position array to use to determine the bounding info
  92040. * @returns the SubMesh
  92041. */
  92042. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  92043. /** @hidden */
  92044. _checkCollision(collider: Collider): boolean;
  92045. /**
  92046. * Updates the submesh BoundingInfo
  92047. * @param world defines the world matrix to use to update the bounding info
  92048. * @returns the submesh
  92049. */
  92050. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92051. /**
  92052. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92053. * @param frustumPlanes defines the frustum planes
  92054. * @returns true if the submesh is intersecting with the frustum
  92055. */
  92056. isInFrustum(frustumPlanes: Plane[]): boolean;
  92057. /**
  92058. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92059. * @param frustumPlanes defines the frustum planes
  92060. * @returns true if the submesh is inside the frustum
  92061. */
  92062. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92063. /**
  92064. * Renders the submesh
  92065. * @param enableAlphaMode defines if alpha needs to be used
  92066. * @returns the submesh
  92067. */
  92068. render(enableAlphaMode: boolean): SubMesh;
  92069. /**
  92070. * @hidden
  92071. */
  92072. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92073. /**
  92074. * Checks if the submesh intersects with a ray
  92075. * @param ray defines the ray to test
  92076. * @returns true is the passed ray intersects the submesh bounding box
  92077. */
  92078. canIntersects(ray: Ray): boolean;
  92079. /**
  92080. * Intersects current submesh with a ray
  92081. * @param ray defines the ray to test
  92082. * @param positions defines mesh's positions array
  92083. * @param indices defines mesh's indices array
  92084. * @param fastCheck defines if only bounding info should be used
  92085. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92086. * @returns intersection info or null if no intersection
  92087. */
  92088. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92089. /** @hidden */
  92090. private _intersectLines;
  92091. /** @hidden */
  92092. private _intersectUnIndexedLines;
  92093. /** @hidden */
  92094. private _intersectTriangles;
  92095. /** @hidden */
  92096. private _intersectUnIndexedTriangles;
  92097. /** @hidden */
  92098. _rebuild(): void;
  92099. /**
  92100. * Creates a new submesh from the passed mesh
  92101. * @param newMesh defines the new hosting mesh
  92102. * @param newRenderingMesh defines an optional rendering mesh
  92103. * @returns the new submesh
  92104. */
  92105. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92106. /**
  92107. * Release associated resources
  92108. */
  92109. dispose(): void;
  92110. /**
  92111. * Gets the class name
  92112. * @returns the string "SubMesh".
  92113. */
  92114. getClassName(): string;
  92115. /**
  92116. * Creates a new submesh from indices data
  92117. * @param materialIndex the index of the main mesh material
  92118. * @param startIndex the index where to start the copy in the mesh indices array
  92119. * @param indexCount the number of indices to copy then from the startIndex
  92120. * @param mesh the main mesh to create the submesh from
  92121. * @param renderingMesh the optional rendering mesh
  92122. * @returns a new submesh
  92123. */
  92124. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92125. }
  92126. }
  92127. declare module BABYLON {
  92128. /**
  92129. * Class used to represent data loading progression
  92130. */
  92131. export class SceneLoaderFlags {
  92132. private static _ForceFullSceneLoadingForIncremental;
  92133. private static _ShowLoadingScreen;
  92134. private static _CleanBoneMatrixWeights;
  92135. private static _loggingLevel;
  92136. /**
  92137. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92138. */
  92139. static get ForceFullSceneLoadingForIncremental(): boolean;
  92140. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92141. /**
  92142. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92143. */
  92144. static get ShowLoadingScreen(): boolean;
  92145. static set ShowLoadingScreen(value: boolean);
  92146. /**
  92147. * Defines the current logging level (while loading the scene)
  92148. * @ignorenaming
  92149. */
  92150. static get loggingLevel(): number;
  92151. static set loggingLevel(value: number);
  92152. /**
  92153. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92154. */
  92155. static get CleanBoneMatrixWeights(): boolean;
  92156. static set CleanBoneMatrixWeights(value: boolean);
  92157. }
  92158. }
  92159. declare module BABYLON {
  92160. /**
  92161. * Class used to store geometry data (vertex buffers + index buffer)
  92162. */
  92163. export class Geometry implements IGetSetVerticesData {
  92164. /**
  92165. * Gets or sets the ID of the geometry
  92166. */
  92167. id: string;
  92168. /**
  92169. * Gets or sets the unique ID of the geometry
  92170. */
  92171. uniqueId: number;
  92172. /**
  92173. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92174. */
  92175. delayLoadState: number;
  92176. /**
  92177. * Gets the file containing the data to load when running in delay load state
  92178. */
  92179. delayLoadingFile: Nullable<string>;
  92180. /**
  92181. * Callback called when the geometry is updated
  92182. */
  92183. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92184. private _scene;
  92185. private _engine;
  92186. private _meshes;
  92187. private _totalVertices;
  92188. /** @hidden */
  92189. _indices: IndicesArray;
  92190. /** @hidden */
  92191. _vertexBuffers: {
  92192. [key: string]: VertexBuffer;
  92193. };
  92194. private _isDisposed;
  92195. private _extend;
  92196. private _boundingBias;
  92197. /** @hidden */
  92198. _delayInfo: Array<string>;
  92199. private _indexBuffer;
  92200. private _indexBufferIsUpdatable;
  92201. /** @hidden */
  92202. _boundingInfo: Nullable<BoundingInfo>;
  92203. /** @hidden */
  92204. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92205. /** @hidden */
  92206. _softwareSkinningFrameId: number;
  92207. private _vertexArrayObjects;
  92208. private _updatable;
  92209. /** @hidden */
  92210. _positions: Nullable<Vector3[]>;
  92211. /**
  92212. * 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
  92213. */
  92214. get boundingBias(): Vector2;
  92215. /**
  92216. * 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
  92217. */
  92218. set boundingBias(value: Vector2);
  92219. /**
  92220. * Static function used to attach a new empty geometry to a mesh
  92221. * @param mesh defines the mesh to attach the geometry to
  92222. * @returns the new Geometry
  92223. */
  92224. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92225. /**
  92226. * Creates a new geometry
  92227. * @param id defines the unique ID
  92228. * @param scene defines the hosting scene
  92229. * @param vertexData defines the VertexData used to get geometry data
  92230. * @param updatable defines if geometry must be updatable (false by default)
  92231. * @param mesh defines the mesh that will be associated with the geometry
  92232. */
  92233. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92234. /**
  92235. * Gets the current extend of the geometry
  92236. */
  92237. get extend(): {
  92238. minimum: Vector3;
  92239. maximum: Vector3;
  92240. };
  92241. /**
  92242. * Gets the hosting scene
  92243. * @returns the hosting Scene
  92244. */
  92245. getScene(): Scene;
  92246. /**
  92247. * Gets the hosting engine
  92248. * @returns the hosting Engine
  92249. */
  92250. getEngine(): Engine;
  92251. /**
  92252. * Defines if the geometry is ready to use
  92253. * @returns true if the geometry is ready to be used
  92254. */
  92255. isReady(): boolean;
  92256. /**
  92257. * Gets a value indicating that the geometry should not be serialized
  92258. */
  92259. get doNotSerialize(): boolean;
  92260. /** @hidden */
  92261. _rebuild(): void;
  92262. /**
  92263. * Affects all geometry data in one call
  92264. * @param vertexData defines the geometry data
  92265. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92266. */
  92267. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92268. /**
  92269. * Set specific vertex data
  92270. * @param kind defines the data kind (Position, normal, etc...)
  92271. * @param data defines the vertex data to use
  92272. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92273. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92274. */
  92275. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92276. /**
  92277. * Removes a specific vertex data
  92278. * @param kind defines the data kind (Position, normal, etc...)
  92279. */
  92280. removeVerticesData(kind: string): void;
  92281. /**
  92282. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92283. * @param buffer defines the vertex buffer to use
  92284. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92285. */
  92286. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92287. /**
  92288. * Update a specific vertex buffer
  92289. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92290. * It will do nothing if the buffer is not updatable
  92291. * @param kind defines the data kind (Position, normal, etc...)
  92292. * @param data defines the data to use
  92293. * @param offset defines the offset in the target buffer where to store the data
  92294. * @param useBytes set to true if the offset is in bytes
  92295. */
  92296. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92297. /**
  92298. * Update a specific vertex buffer
  92299. * This function will create a new buffer if the current one is not updatable
  92300. * @param kind defines the data kind (Position, normal, etc...)
  92301. * @param data defines the data to use
  92302. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92303. */
  92304. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92305. private _updateBoundingInfo;
  92306. /** @hidden */
  92307. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92308. /**
  92309. * Gets total number of vertices
  92310. * @returns the total number of vertices
  92311. */
  92312. getTotalVertices(): number;
  92313. /**
  92314. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92315. * @param kind defines the data kind (Position, normal, etc...)
  92316. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92317. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92318. * @returns a float array containing vertex data
  92319. */
  92320. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92321. /**
  92322. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92323. * @param kind defines the data kind (Position, normal, etc...)
  92324. * @returns true if the vertex buffer with the specified kind is updatable
  92325. */
  92326. isVertexBufferUpdatable(kind: string): boolean;
  92327. /**
  92328. * Gets a specific vertex buffer
  92329. * @param kind defines the data kind (Position, normal, etc...)
  92330. * @returns a VertexBuffer
  92331. */
  92332. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92333. /**
  92334. * Returns all vertex buffers
  92335. * @return an object holding all vertex buffers indexed by kind
  92336. */
  92337. getVertexBuffers(): Nullable<{
  92338. [key: string]: VertexBuffer;
  92339. }>;
  92340. /**
  92341. * Gets a boolean indicating if specific vertex buffer is present
  92342. * @param kind defines the data kind (Position, normal, etc...)
  92343. * @returns true if data is present
  92344. */
  92345. isVerticesDataPresent(kind: string): boolean;
  92346. /**
  92347. * Gets a list of all attached data kinds (Position, normal, etc...)
  92348. * @returns a list of string containing all kinds
  92349. */
  92350. getVerticesDataKinds(): string[];
  92351. /**
  92352. * Update index buffer
  92353. * @param indices defines the indices to store in the index buffer
  92354. * @param offset defines the offset in the target buffer where to store the data
  92355. * @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)
  92356. */
  92357. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92358. /**
  92359. * Creates a new index buffer
  92360. * @param indices defines the indices to store in the index buffer
  92361. * @param totalVertices defines the total number of vertices (could be null)
  92362. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92363. */
  92364. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92365. /**
  92366. * Return the total number of indices
  92367. * @returns the total number of indices
  92368. */
  92369. getTotalIndices(): number;
  92370. /**
  92371. * Gets the index buffer array
  92372. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92373. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92374. * @returns the index buffer array
  92375. */
  92376. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92377. /**
  92378. * Gets the index buffer
  92379. * @return the index buffer
  92380. */
  92381. getIndexBuffer(): Nullable<DataBuffer>;
  92382. /** @hidden */
  92383. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92384. /**
  92385. * Release the associated resources for a specific mesh
  92386. * @param mesh defines the source mesh
  92387. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92388. */
  92389. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92390. /**
  92391. * Apply current geometry to a given mesh
  92392. * @param mesh defines the mesh to apply geometry to
  92393. */
  92394. applyToMesh(mesh: Mesh): void;
  92395. private _updateExtend;
  92396. private _applyToMesh;
  92397. private notifyUpdate;
  92398. /**
  92399. * Load the geometry if it was flagged as delay loaded
  92400. * @param scene defines the hosting scene
  92401. * @param onLoaded defines a callback called when the geometry is loaded
  92402. */
  92403. load(scene: Scene, onLoaded?: () => void): void;
  92404. private _queueLoad;
  92405. /**
  92406. * Invert the geometry to move from a right handed system to a left handed one.
  92407. */
  92408. toLeftHanded(): void;
  92409. /** @hidden */
  92410. _resetPointsArrayCache(): void;
  92411. /** @hidden */
  92412. _generatePointsArray(): boolean;
  92413. /**
  92414. * Gets a value indicating if the geometry is disposed
  92415. * @returns true if the geometry was disposed
  92416. */
  92417. isDisposed(): boolean;
  92418. private _disposeVertexArrayObjects;
  92419. /**
  92420. * Free all associated resources
  92421. */
  92422. dispose(): void;
  92423. /**
  92424. * Clone the current geometry into a new geometry
  92425. * @param id defines the unique ID of the new geometry
  92426. * @returns a new geometry object
  92427. */
  92428. copy(id: string): Geometry;
  92429. /**
  92430. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92431. * @return a JSON representation of the current geometry data (without the vertices data)
  92432. */
  92433. serialize(): any;
  92434. private toNumberArray;
  92435. /**
  92436. * Serialize all vertices data into a JSON oject
  92437. * @returns a JSON representation of the current geometry data
  92438. */
  92439. serializeVerticeData(): any;
  92440. /**
  92441. * Extracts a clone of a mesh geometry
  92442. * @param mesh defines the source mesh
  92443. * @param id defines the unique ID of the new geometry object
  92444. * @returns the new geometry object
  92445. */
  92446. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92447. /**
  92448. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92449. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92450. * Be aware Math.random() could cause collisions, but:
  92451. * "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"
  92452. * @returns a string containing a new GUID
  92453. */
  92454. static RandomId(): string;
  92455. /** @hidden */
  92456. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92457. private static _CleanMatricesWeights;
  92458. /**
  92459. * Create a new geometry from persisted data (Using .babylon file format)
  92460. * @param parsedVertexData defines the persisted data
  92461. * @param scene defines the hosting scene
  92462. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92463. * @returns the new geometry object
  92464. */
  92465. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92466. }
  92467. }
  92468. declare module BABYLON {
  92469. /**
  92470. * Define an interface for all classes that will get and set the data on vertices
  92471. */
  92472. export interface IGetSetVerticesData {
  92473. /**
  92474. * Gets a boolean indicating if specific vertex data is present
  92475. * @param kind defines the vertex data kind to use
  92476. * @returns true is data kind is present
  92477. */
  92478. isVerticesDataPresent(kind: string): boolean;
  92479. /**
  92480. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92481. * @param kind defines the data kind (Position, normal, etc...)
  92482. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92483. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92484. * @returns a float array containing vertex data
  92485. */
  92486. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92487. /**
  92488. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92489. * @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.
  92490. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92491. * @returns the indices array or an empty array if the mesh has no geometry
  92492. */
  92493. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92494. /**
  92495. * Set specific vertex data
  92496. * @param kind defines the data kind (Position, normal, etc...)
  92497. * @param data defines the vertex data to use
  92498. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92499. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92500. */
  92501. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92502. /**
  92503. * Update a specific associated vertex buffer
  92504. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92505. * - VertexBuffer.PositionKind
  92506. * - VertexBuffer.UVKind
  92507. * - VertexBuffer.UV2Kind
  92508. * - VertexBuffer.UV3Kind
  92509. * - VertexBuffer.UV4Kind
  92510. * - VertexBuffer.UV5Kind
  92511. * - VertexBuffer.UV6Kind
  92512. * - VertexBuffer.ColorKind
  92513. * - VertexBuffer.MatricesIndicesKind
  92514. * - VertexBuffer.MatricesIndicesExtraKind
  92515. * - VertexBuffer.MatricesWeightsKind
  92516. * - VertexBuffer.MatricesWeightsExtraKind
  92517. * @param data defines the data source
  92518. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92519. * @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)
  92520. */
  92521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92522. /**
  92523. * Creates a new index buffer
  92524. * @param indices defines the indices to store in the index buffer
  92525. * @param totalVertices defines the total number of vertices (could be null)
  92526. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92527. */
  92528. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92529. }
  92530. /**
  92531. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92532. */
  92533. export class VertexData {
  92534. /**
  92535. * Mesh side orientation : usually the external or front surface
  92536. */
  92537. static readonly FRONTSIDE: number;
  92538. /**
  92539. * Mesh side orientation : usually the internal or back surface
  92540. */
  92541. static readonly BACKSIDE: number;
  92542. /**
  92543. * Mesh side orientation : both internal and external or front and back surfaces
  92544. */
  92545. static readonly DOUBLESIDE: number;
  92546. /**
  92547. * Mesh side orientation : by default, `FRONTSIDE`
  92548. */
  92549. static readonly DEFAULTSIDE: number;
  92550. /**
  92551. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92552. */
  92553. positions: Nullable<FloatArray>;
  92554. /**
  92555. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92556. */
  92557. normals: Nullable<FloatArray>;
  92558. /**
  92559. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92560. */
  92561. tangents: Nullable<FloatArray>;
  92562. /**
  92563. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92564. */
  92565. uvs: Nullable<FloatArray>;
  92566. /**
  92567. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92568. */
  92569. uvs2: Nullable<FloatArray>;
  92570. /**
  92571. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92572. */
  92573. uvs3: Nullable<FloatArray>;
  92574. /**
  92575. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92576. */
  92577. uvs4: Nullable<FloatArray>;
  92578. /**
  92579. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92580. */
  92581. uvs5: Nullable<FloatArray>;
  92582. /**
  92583. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92584. */
  92585. uvs6: Nullable<FloatArray>;
  92586. /**
  92587. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92588. */
  92589. colors: Nullable<FloatArray>;
  92590. /**
  92591. * 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).
  92592. */
  92593. matricesIndices: Nullable<FloatArray>;
  92594. /**
  92595. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92596. */
  92597. matricesWeights: Nullable<FloatArray>;
  92598. /**
  92599. * An array extending the number of possible indices
  92600. */
  92601. matricesIndicesExtra: Nullable<FloatArray>;
  92602. /**
  92603. * An array extending the number of possible weights when the number of indices is extended
  92604. */
  92605. matricesWeightsExtra: Nullable<FloatArray>;
  92606. /**
  92607. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92608. */
  92609. indices: Nullable<IndicesArray>;
  92610. /**
  92611. * Uses the passed data array to set the set the values for the specified kind of data
  92612. * @param data a linear array of floating numbers
  92613. * @param kind the type of data that is being set, eg positions, colors etc
  92614. */
  92615. set(data: FloatArray, kind: string): void;
  92616. /**
  92617. * Associates the vertexData to the passed Mesh.
  92618. * Sets it as updatable or not (default `false`)
  92619. * @param mesh the mesh the vertexData is applied to
  92620. * @param updatable when used and having the value true allows new data to update the vertexData
  92621. * @returns the VertexData
  92622. */
  92623. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92624. /**
  92625. * Associates the vertexData to the passed Geometry.
  92626. * Sets it as updatable or not (default `false`)
  92627. * @param geometry the geometry the vertexData is applied to
  92628. * @param updatable when used and having the value true allows new data to update the vertexData
  92629. * @returns VertexData
  92630. */
  92631. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92632. /**
  92633. * Updates the associated mesh
  92634. * @param mesh the mesh to be updated
  92635. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92636. * @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
  92637. * @returns VertexData
  92638. */
  92639. updateMesh(mesh: Mesh): VertexData;
  92640. /**
  92641. * Updates the associated geometry
  92642. * @param geometry the geometry to be updated
  92643. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92644. * @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
  92645. * @returns VertexData.
  92646. */
  92647. updateGeometry(geometry: Geometry): VertexData;
  92648. private _applyTo;
  92649. private _update;
  92650. /**
  92651. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92652. * @param matrix the transforming matrix
  92653. * @returns the VertexData
  92654. */
  92655. transform(matrix: Matrix): VertexData;
  92656. /**
  92657. * Merges the passed VertexData into the current one
  92658. * @param other the VertexData to be merged into the current one
  92659. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92660. * @returns the modified VertexData
  92661. */
  92662. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92663. private _mergeElement;
  92664. private _validate;
  92665. /**
  92666. * Serializes the VertexData
  92667. * @returns a serialized object
  92668. */
  92669. serialize(): any;
  92670. /**
  92671. * Extracts the vertexData from a mesh
  92672. * @param mesh the mesh from which to extract the VertexData
  92673. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92674. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92675. * @returns the object VertexData associated to the passed mesh
  92676. */
  92677. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92678. /**
  92679. * Extracts the vertexData from the geometry
  92680. * @param geometry the geometry from which to extract the VertexData
  92681. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92682. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92683. * @returns the object VertexData associated to the passed mesh
  92684. */
  92685. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92686. private static _ExtractFrom;
  92687. /**
  92688. * Creates the VertexData for a Ribbon
  92689. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92690. * * pathArray array of paths, each of which an array of successive Vector3
  92691. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92692. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92693. * * 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
  92694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92695. * * 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)
  92696. * * 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)
  92697. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92698. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92699. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92700. * @returns the VertexData of the ribbon
  92701. */
  92702. static CreateRibbon(options: {
  92703. pathArray: Vector3[][];
  92704. closeArray?: boolean;
  92705. closePath?: boolean;
  92706. offset?: number;
  92707. sideOrientation?: number;
  92708. frontUVs?: Vector4;
  92709. backUVs?: Vector4;
  92710. invertUV?: boolean;
  92711. uvs?: Vector2[];
  92712. colors?: Color4[];
  92713. }): VertexData;
  92714. /**
  92715. * Creates the VertexData for a box
  92716. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92717. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92718. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92719. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92720. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92721. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92722. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92724. * * 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)
  92725. * * 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)
  92726. * @returns the VertexData of the box
  92727. */
  92728. static CreateBox(options: {
  92729. size?: number;
  92730. width?: number;
  92731. height?: number;
  92732. depth?: number;
  92733. faceUV?: Vector4[];
  92734. faceColors?: Color4[];
  92735. sideOrientation?: number;
  92736. frontUVs?: Vector4;
  92737. backUVs?: Vector4;
  92738. }): VertexData;
  92739. /**
  92740. * Creates the VertexData for a tiled box
  92741. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92742. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92743. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92744. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92746. * @returns the VertexData of the box
  92747. */
  92748. static CreateTiledBox(options: {
  92749. pattern?: number;
  92750. width?: number;
  92751. height?: number;
  92752. depth?: number;
  92753. tileSize?: number;
  92754. tileWidth?: number;
  92755. tileHeight?: number;
  92756. alignHorizontal?: number;
  92757. alignVertical?: number;
  92758. faceUV?: Vector4[];
  92759. faceColors?: Color4[];
  92760. sideOrientation?: number;
  92761. }): VertexData;
  92762. /**
  92763. * Creates the VertexData for a tiled plane
  92764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92765. * * pattern a limited pattern arrangement depending on the number
  92766. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92767. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92768. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92770. * * 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)
  92771. * * 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)
  92772. * @returns the VertexData of the tiled plane
  92773. */
  92774. static CreateTiledPlane(options: {
  92775. pattern?: number;
  92776. tileSize?: number;
  92777. tileWidth?: number;
  92778. tileHeight?: number;
  92779. size?: number;
  92780. width?: number;
  92781. height?: number;
  92782. alignHorizontal?: number;
  92783. alignVertical?: number;
  92784. sideOrientation?: number;
  92785. frontUVs?: Vector4;
  92786. backUVs?: Vector4;
  92787. }): VertexData;
  92788. /**
  92789. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92791. * * segments sets the number of horizontal strips optional, default 32
  92792. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92793. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92794. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92795. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92796. * * 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
  92797. * * 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
  92798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92799. * * 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)
  92800. * * 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)
  92801. * @returns the VertexData of the ellipsoid
  92802. */
  92803. static CreateSphere(options: {
  92804. segments?: number;
  92805. diameter?: number;
  92806. diameterX?: number;
  92807. diameterY?: number;
  92808. diameterZ?: number;
  92809. arc?: number;
  92810. slice?: number;
  92811. sideOrientation?: number;
  92812. frontUVs?: Vector4;
  92813. backUVs?: Vector4;
  92814. }): VertexData;
  92815. /**
  92816. * Creates the VertexData for a cylinder, cone or prism
  92817. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92818. * * height sets the height (y direction) of the cylinder, optional, default 2
  92819. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92820. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92821. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92822. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92823. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92824. * * 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
  92825. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92826. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92827. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92828. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92830. * * 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)
  92831. * * 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)
  92832. * @returns the VertexData of the cylinder, cone or prism
  92833. */
  92834. static CreateCylinder(options: {
  92835. height?: number;
  92836. diameterTop?: number;
  92837. diameterBottom?: number;
  92838. diameter?: number;
  92839. tessellation?: number;
  92840. subdivisions?: number;
  92841. arc?: number;
  92842. faceColors?: Color4[];
  92843. faceUV?: Vector4[];
  92844. hasRings?: boolean;
  92845. enclose?: boolean;
  92846. sideOrientation?: number;
  92847. frontUVs?: Vector4;
  92848. backUVs?: Vector4;
  92849. }): VertexData;
  92850. /**
  92851. * Creates the VertexData for a torus
  92852. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92853. * * diameter the diameter of the torus, optional default 1
  92854. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92855. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92857. * * 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)
  92858. * * 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)
  92859. * @returns the VertexData of the torus
  92860. */
  92861. static CreateTorus(options: {
  92862. diameter?: number;
  92863. thickness?: number;
  92864. tessellation?: number;
  92865. sideOrientation?: number;
  92866. frontUVs?: Vector4;
  92867. backUVs?: Vector4;
  92868. }): VertexData;
  92869. /**
  92870. * Creates the VertexData of the LineSystem
  92871. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92872. * - lines an array of lines, each line being an array of successive Vector3
  92873. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92874. * @returns the VertexData of the LineSystem
  92875. */
  92876. static CreateLineSystem(options: {
  92877. lines: Vector3[][];
  92878. colors?: Nullable<Color4[][]>;
  92879. }): VertexData;
  92880. /**
  92881. * Create the VertexData for a DashedLines
  92882. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92883. * - points an array successive Vector3
  92884. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92885. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92886. * - dashNb the intended total number of dashes, optional, default 200
  92887. * @returns the VertexData for the DashedLines
  92888. */
  92889. static CreateDashedLines(options: {
  92890. points: Vector3[];
  92891. dashSize?: number;
  92892. gapSize?: number;
  92893. dashNb?: number;
  92894. }): VertexData;
  92895. /**
  92896. * Creates the VertexData for a Ground
  92897. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92898. * - width the width (x direction) of the ground, optional, default 1
  92899. * - height the height (z direction) of the ground, optional, default 1
  92900. * - subdivisions the number of subdivisions per side, optional, default 1
  92901. * @returns the VertexData of the Ground
  92902. */
  92903. static CreateGround(options: {
  92904. width?: number;
  92905. height?: number;
  92906. subdivisions?: number;
  92907. subdivisionsX?: number;
  92908. subdivisionsY?: number;
  92909. }): VertexData;
  92910. /**
  92911. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92912. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92913. * * xmin the ground minimum X coordinate, optional, default -1
  92914. * * zmin the ground minimum Z coordinate, optional, default -1
  92915. * * xmax the ground maximum X coordinate, optional, default 1
  92916. * * zmax the ground maximum Z coordinate, optional, default 1
  92917. * * 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}
  92918. * * 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}
  92919. * @returns the VertexData of the TiledGround
  92920. */
  92921. static CreateTiledGround(options: {
  92922. xmin: number;
  92923. zmin: number;
  92924. xmax: number;
  92925. zmax: number;
  92926. subdivisions?: {
  92927. w: number;
  92928. h: number;
  92929. };
  92930. precision?: {
  92931. w: number;
  92932. h: number;
  92933. };
  92934. }): VertexData;
  92935. /**
  92936. * Creates the VertexData of the Ground designed from a heightmap
  92937. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92938. * * width the width (x direction) of the ground
  92939. * * height the height (z direction) of the ground
  92940. * * subdivisions the number of subdivisions per side
  92941. * * minHeight the minimum altitude on the ground, optional, default 0
  92942. * * maxHeight the maximum altitude on the ground, optional default 1
  92943. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92944. * * buffer the array holding the image color data
  92945. * * bufferWidth the width of image
  92946. * * bufferHeight the height of image
  92947. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92948. * @returns the VertexData of the Ground designed from a heightmap
  92949. */
  92950. static CreateGroundFromHeightMap(options: {
  92951. width: number;
  92952. height: number;
  92953. subdivisions: number;
  92954. minHeight: number;
  92955. maxHeight: number;
  92956. colorFilter: Color3;
  92957. buffer: Uint8Array;
  92958. bufferWidth: number;
  92959. bufferHeight: number;
  92960. alphaFilter: number;
  92961. }): VertexData;
  92962. /**
  92963. * Creates the VertexData for a Plane
  92964. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92965. * * size sets the width and height of the plane to the value of size, optional default 1
  92966. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92967. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92969. * * 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)
  92970. * * 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)
  92971. * @returns the VertexData of the box
  92972. */
  92973. static CreatePlane(options: {
  92974. size?: number;
  92975. width?: number;
  92976. height?: number;
  92977. sideOrientation?: number;
  92978. frontUVs?: Vector4;
  92979. backUVs?: Vector4;
  92980. }): VertexData;
  92981. /**
  92982. * Creates the VertexData of the Disc or regular Polygon
  92983. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92984. * * radius the radius of the disc, optional default 0.5
  92985. * * tessellation the number of polygon sides, optional, default 64
  92986. * * 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
  92987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92988. * * 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)
  92989. * * 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)
  92990. * @returns the VertexData of the box
  92991. */
  92992. static CreateDisc(options: {
  92993. radius?: number;
  92994. tessellation?: number;
  92995. arc?: number;
  92996. sideOrientation?: number;
  92997. frontUVs?: Vector4;
  92998. backUVs?: Vector4;
  92999. }): VertexData;
  93000. /**
  93001. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  93002. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  93003. * @param polygon a mesh built from polygonTriangulation.build()
  93004. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93005. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93006. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93007. * @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)
  93008. * @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)
  93009. * @returns the VertexData of the Polygon
  93010. */
  93011. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  93012. /**
  93013. * Creates the VertexData of the IcoSphere
  93014. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  93015. * * radius the radius of the IcoSphere, optional default 1
  93016. * * radiusX allows stretching in the x direction, optional, default radius
  93017. * * radiusY allows stretching in the y direction, optional, default radius
  93018. * * radiusZ allows stretching in the z direction, optional, default radius
  93019. * * flat when true creates a flat shaded mesh, optional, default true
  93020. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93022. * * 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)
  93023. * * 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)
  93024. * @returns the VertexData of the IcoSphere
  93025. */
  93026. static CreateIcoSphere(options: {
  93027. radius?: number;
  93028. radiusX?: number;
  93029. radiusY?: number;
  93030. radiusZ?: number;
  93031. flat?: boolean;
  93032. subdivisions?: number;
  93033. sideOrientation?: number;
  93034. frontUVs?: Vector4;
  93035. backUVs?: Vector4;
  93036. }): VertexData;
  93037. /**
  93038. * Creates the VertexData for a Polyhedron
  93039. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  93040. * * type provided types are:
  93041. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  93042. * * 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)
  93043. * * size the size of the IcoSphere, optional default 1
  93044. * * sizeX allows stretching in the x direction, optional, default size
  93045. * * sizeY allows stretching in the y direction, optional, default size
  93046. * * sizeZ allows stretching in the z direction, optional, default size
  93047. * * 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
  93048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93049. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93050. * * flat when true creates a flat shaded mesh, optional, default true
  93051. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93053. * * 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)
  93054. * * 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)
  93055. * @returns the VertexData of the Polyhedron
  93056. */
  93057. static CreatePolyhedron(options: {
  93058. type?: number;
  93059. size?: number;
  93060. sizeX?: number;
  93061. sizeY?: number;
  93062. sizeZ?: number;
  93063. custom?: any;
  93064. faceUV?: Vector4[];
  93065. faceColors?: Color4[];
  93066. flat?: boolean;
  93067. sideOrientation?: number;
  93068. frontUVs?: Vector4;
  93069. backUVs?: Vector4;
  93070. }): VertexData;
  93071. /**
  93072. * Creates the VertexData for a TorusKnot
  93073. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93074. * * radius the radius of the torus knot, optional, default 2
  93075. * * tube the thickness of the tube, optional, default 0.5
  93076. * * radialSegments the number of sides on each tube segments, optional, default 32
  93077. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93078. * * p the number of windings around the z axis, optional, default 2
  93079. * * q the number of windings around the x axis, optional, default 3
  93080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93081. * * 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)
  93082. * * 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)
  93083. * @returns the VertexData of the Torus Knot
  93084. */
  93085. static CreateTorusKnot(options: {
  93086. radius?: number;
  93087. tube?: number;
  93088. radialSegments?: number;
  93089. tubularSegments?: number;
  93090. p?: number;
  93091. q?: number;
  93092. sideOrientation?: number;
  93093. frontUVs?: Vector4;
  93094. backUVs?: Vector4;
  93095. }): VertexData;
  93096. /**
  93097. * Compute normals for given positions and indices
  93098. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93099. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93100. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93101. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93102. * * facetNormals : optional array of facet normals (vector3)
  93103. * * facetPositions : optional array of facet positions (vector3)
  93104. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93105. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93106. * * bInfo : optional bounding info, required for facetPartitioning computation
  93107. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93108. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93109. * * useRightHandedSystem: optional boolean to for right handed system computation
  93110. * * depthSort : optional boolean to enable the facet depth sort computation
  93111. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93112. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93113. */
  93114. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93115. facetNormals?: any;
  93116. facetPositions?: any;
  93117. facetPartitioning?: any;
  93118. ratio?: number;
  93119. bInfo?: any;
  93120. bbSize?: Vector3;
  93121. subDiv?: any;
  93122. useRightHandedSystem?: boolean;
  93123. depthSort?: boolean;
  93124. distanceTo?: Vector3;
  93125. depthSortedFacets?: any;
  93126. }): void;
  93127. /** @hidden */
  93128. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93129. /**
  93130. * Applies VertexData created from the imported parameters to the geometry
  93131. * @param parsedVertexData the parsed data from an imported file
  93132. * @param geometry the geometry to apply the VertexData to
  93133. */
  93134. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93135. }
  93136. }
  93137. declare module BABYLON {
  93138. /**
  93139. * Defines a target to use with MorphTargetManager
  93140. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93141. */
  93142. export class MorphTarget implements IAnimatable {
  93143. /** defines the name of the target */
  93144. name: string;
  93145. /**
  93146. * Gets or sets the list of animations
  93147. */
  93148. animations: Animation[];
  93149. private _scene;
  93150. private _positions;
  93151. private _normals;
  93152. private _tangents;
  93153. private _uvs;
  93154. private _influence;
  93155. private _uniqueId;
  93156. /**
  93157. * Observable raised when the influence changes
  93158. */
  93159. onInfluenceChanged: Observable<boolean>;
  93160. /** @hidden */
  93161. _onDataLayoutChanged: Observable<void>;
  93162. /**
  93163. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93164. */
  93165. get influence(): number;
  93166. set influence(influence: number);
  93167. /**
  93168. * Gets or sets the id of the morph Target
  93169. */
  93170. id: string;
  93171. private _animationPropertiesOverride;
  93172. /**
  93173. * Gets or sets the animation properties override
  93174. */
  93175. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93176. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93177. /**
  93178. * Creates a new MorphTarget
  93179. * @param name defines the name of the target
  93180. * @param influence defines the influence to use
  93181. * @param scene defines the scene the morphtarget belongs to
  93182. */
  93183. constructor(
  93184. /** defines the name of the target */
  93185. name: string, influence?: number, scene?: Nullable<Scene>);
  93186. /**
  93187. * Gets the unique ID of this manager
  93188. */
  93189. get uniqueId(): number;
  93190. /**
  93191. * Gets a boolean defining if the target contains position data
  93192. */
  93193. get hasPositions(): boolean;
  93194. /**
  93195. * Gets a boolean defining if the target contains normal data
  93196. */
  93197. get hasNormals(): boolean;
  93198. /**
  93199. * Gets a boolean defining if the target contains tangent data
  93200. */
  93201. get hasTangents(): boolean;
  93202. /**
  93203. * Gets a boolean defining if the target contains texture coordinates data
  93204. */
  93205. get hasUVs(): boolean;
  93206. /**
  93207. * Affects position data to this target
  93208. * @param data defines the position data to use
  93209. */
  93210. setPositions(data: Nullable<FloatArray>): void;
  93211. /**
  93212. * Gets the position data stored in this target
  93213. * @returns a FloatArray containing the position data (or null if not present)
  93214. */
  93215. getPositions(): Nullable<FloatArray>;
  93216. /**
  93217. * Affects normal data to this target
  93218. * @param data defines the normal data to use
  93219. */
  93220. setNormals(data: Nullable<FloatArray>): void;
  93221. /**
  93222. * Gets the normal data stored in this target
  93223. * @returns a FloatArray containing the normal data (or null if not present)
  93224. */
  93225. getNormals(): Nullable<FloatArray>;
  93226. /**
  93227. * Affects tangent data to this target
  93228. * @param data defines the tangent data to use
  93229. */
  93230. setTangents(data: Nullable<FloatArray>): void;
  93231. /**
  93232. * Gets the tangent data stored in this target
  93233. * @returns a FloatArray containing the tangent data (or null if not present)
  93234. */
  93235. getTangents(): Nullable<FloatArray>;
  93236. /**
  93237. * Affects texture coordinates data to this target
  93238. * @param data defines the texture coordinates data to use
  93239. */
  93240. setUVs(data: Nullable<FloatArray>): void;
  93241. /**
  93242. * Gets the texture coordinates data stored in this target
  93243. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93244. */
  93245. getUVs(): Nullable<FloatArray>;
  93246. /**
  93247. * Clone the current target
  93248. * @returns a new MorphTarget
  93249. */
  93250. clone(): MorphTarget;
  93251. /**
  93252. * Serializes the current target into a Serialization object
  93253. * @returns the serialized object
  93254. */
  93255. serialize(): any;
  93256. /**
  93257. * Returns the string "MorphTarget"
  93258. * @returns "MorphTarget"
  93259. */
  93260. getClassName(): string;
  93261. /**
  93262. * Creates a new target from serialized data
  93263. * @param serializationObject defines the serialized data to use
  93264. * @returns a new MorphTarget
  93265. */
  93266. static Parse(serializationObject: any): MorphTarget;
  93267. /**
  93268. * Creates a MorphTarget from mesh data
  93269. * @param mesh defines the source mesh
  93270. * @param name defines the name to use for the new target
  93271. * @param influence defines the influence to attach to the target
  93272. * @returns a new MorphTarget
  93273. */
  93274. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93275. }
  93276. }
  93277. declare module BABYLON {
  93278. /**
  93279. * This class is used to deform meshes using morphing between different targets
  93280. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93281. */
  93282. export class MorphTargetManager {
  93283. private _targets;
  93284. private _targetInfluenceChangedObservers;
  93285. private _targetDataLayoutChangedObservers;
  93286. private _activeTargets;
  93287. private _scene;
  93288. private _influences;
  93289. private _supportsNormals;
  93290. private _supportsTangents;
  93291. private _supportsUVs;
  93292. private _vertexCount;
  93293. private _uniqueId;
  93294. private _tempInfluences;
  93295. /**
  93296. * Gets or sets a boolean indicating if normals must be morphed
  93297. */
  93298. enableNormalMorphing: boolean;
  93299. /**
  93300. * Gets or sets a boolean indicating if tangents must be morphed
  93301. */
  93302. enableTangentMorphing: boolean;
  93303. /**
  93304. * Gets or sets a boolean indicating if UV must be morphed
  93305. */
  93306. enableUVMorphing: boolean;
  93307. /**
  93308. * Creates a new MorphTargetManager
  93309. * @param scene defines the current scene
  93310. */
  93311. constructor(scene?: Nullable<Scene>);
  93312. /**
  93313. * Gets the unique ID of this manager
  93314. */
  93315. get uniqueId(): number;
  93316. /**
  93317. * Gets the number of vertices handled by this manager
  93318. */
  93319. get vertexCount(): number;
  93320. /**
  93321. * Gets a boolean indicating if this manager supports morphing of normals
  93322. */
  93323. get supportsNormals(): boolean;
  93324. /**
  93325. * Gets a boolean indicating if this manager supports morphing of tangents
  93326. */
  93327. get supportsTangents(): boolean;
  93328. /**
  93329. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93330. */
  93331. get supportsUVs(): boolean;
  93332. /**
  93333. * Gets the number of targets stored in this manager
  93334. */
  93335. get numTargets(): number;
  93336. /**
  93337. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93338. */
  93339. get numInfluencers(): number;
  93340. /**
  93341. * Gets the list of influences (one per target)
  93342. */
  93343. get influences(): Float32Array;
  93344. /**
  93345. * Gets the active target at specified index. An active target is a target with an influence > 0
  93346. * @param index defines the index to check
  93347. * @returns the requested target
  93348. */
  93349. getActiveTarget(index: number): MorphTarget;
  93350. /**
  93351. * Gets the target at specified index
  93352. * @param index defines the index to check
  93353. * @returns the requested target
  93354. */
  93355. getTarget(index: number): MorphTarget;
  93356. /**
  93357. * Add a new target to this manager
  93358. * @param target defines the target to add
  93359. */
  93360. addTarget(target: MorphTarget): void;
  93361. /**
  93362. * Removes a target from the manager
  93363. * @param target defines the target to remove
  93364. */
  93365. removeTarget(target: MorphTarget): void;
  93366. /**
  93367. * Clone the current manager
  93368. * @returns a new MorphTargetManager
  93369. */
  93370. clone(): MorphTargetManager;
  93371. /**
  93372. * Serializes the current manager into a Serialization object
  93373. * @returns the serialized object
  93374. */
  93375. serialize(): any;
  93376. private _syncActiveTargets;
  93377. /**
  93378. * Syncrhonize the targets with all the meshes using this morph target manager
  93379. */
  93380. synchronize(): void;
  93381. /**
  93382. * Creates a new MorphTargetManager from serialized data
  93383. * @param serializationObject defines the serialized data
  93384. * @param scene defines the hosting scene
  93385. * @returns the new MorphTargetManager
  93386. */
  93387. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93388. }
  93389. }
  93390. declare module BABYLON {
  93391. /**
  93392. * Class used to represent a specific level of detail of a mesh
  93393. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93394. */
  93395. export class MeshLODLevel {
  93396. /** Defines the distance where this level should start being displayed */
  93397. distance: number;
  93398. /** Defines the mesh to use to render this level */
  93399. mesh: Nullable<Mesh>;
  93400. /**
  93401. * Creates a new LOD level
  93402. * @param distance defines the distance where this level should star being displayed
  93403. * @param mesh defines the mesh to use to render this level
  93404. */
  93405. constructor(
  93406. /** Defines the distance where this level should start being displayed */
  93407. distance: number,
  93408. /** Defines the mesh to use to render this level */
  93409. mesh: Nullable<Mesh>);
  93410. }
  93411. }
  93412. declare module BABYLON {
  93413. /**
  93414. * Mesh representing the gorund
  93415. */
  93416. export class GroundMesh extends Mesh {
  93417. /** If octree should be generated */
  93418. generateOctree: boolean;
  93419. private _heightQuads;
  93420. /** @hidden */
  93421. _subdivisionsX: number;
  93422. /** @hidden */
  93423. _subdivisionsY: number;
  93424. /** @hidden */
  93425. _width: number;
  93426. /** @hidden */
  93427. _height: number;
  93428. /** @hidden */
  93429. _minX: number;
  93430. /** @hidden */
  93431. _maxX: number;
  93432. /** @hidden */
  93433. _minZ: number;
  93434. /** @hidden */
  93435. _maxZ: number;
  93436. constructor(name: string, scene: Scene);
  93437. /**
  93438. * "GroundMesh"
  93439. * @returns "GroundMesh"
  93440. */
  93441. getClassName(): string;
  93442. /**
  93443. * The minimum of x and y subdivisions
  93444. */
  93445. get subdivisions(): number;
  93446. /**
  93447. * X subdivisions
  93448. */
  93449. get subdivisionsX(): number;
  93450. /**
  93451. * Y subdivisions
  93452. */
  93453. get subdivisionsY(): number;
  93454. /**
  93455. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93456. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93457. * @param chunksCount the number of subdivisions for x and y
  93458. * @param octreeBlocksSize (Default: 32)
  93459. */
  93460. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93461. /**
  93462. * Returns a height (y) value in the Worl system :
  93463. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93464. * @param x x coordinate
  93465. * @param z z coordinate
  93466. * @returns the ground y position if (x, z) are outside the ground surface.
  93467. */
  93468. getHeightAtCoordinates(x: number, z: number): number;
  93469. /**
  93470. * Returns a normalized vector (Vector3) orthogonal to the ground
  93471. * at the ground coordinates (x, z) expressed in the World system.
  93472. * @param x x coordinate
  93473. * @param z z coordinate
  93474. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93475. */
  93476. getNormalAtCoordinates(x: number, z: number): Vector3;
  93477. /**
  93478. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93479. * at the ground coordinates (x, z) expressed in the World system.
  93480. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93481. * @param x x coordinate
  93482. * @param z z coordinate
  93483. * @param ref vector to store the result
  93484. * @returns the GroundMesh.
  93485. */
  93486. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93487. /**
  93488. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93489. * if the ground has been updated.
  93490. * This can be used in the render loop.
  93491. * @returns the GroundMesh.
  93492. */
  93493. updateCoordinateHeights(): GroundMesh;
  93494. private _getFacetAt;
  93495. private _initHeightQuads;
  93496. private _computeHeightQuads;
  93497. /**
  93498. * Serializes this ground mesh
  93499. * @param serializationObject object to write serialization to
  93500. */
  93501. serialize(serializationObject: any): void;
  93502. /**
  93503. * Parses a serialized ground mesh
  93504. * @param parsedMesh the serialized mesh
  93505. * @param scene the scene to create the ground mesh in
  93506. * @returns the created ground mesh
  93507. */
  93508. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93509. }
  93510. }
  93511. declare module BABYLON {
  93512. /**
  93513. * Interface for Physics-Joint data
  93514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93515. */
  93516. export interface PhysicsJointData {
  93517. /**
  93518. * The main pivot of the joint
  93519. */
  93520. mainPivot?: Vector3;
  93521. /**
  93522. * The connected pivot of the joint
  93523. */
  93524. connectedPivot?: Vector3;
  93525. /**
  93526. * The main axis of the joint
  93527. */
  93528. mainAxis?: Vector3;
  93529. /**
  93530. * The connected axis of the joint
  93531. */
  93532. connectedAxis?: Vector3;
  93533. /**
  93534. * The collision of the joint
  93535. */
  93536. collision?: boolean;
  93537. /**
  93538. * Native Oimo/Cannon/Energy data
  93539. */
  93540. nativeParams?: any;
  93541. }
  93542. /**
  93543. * This is a holder class for the physics joint created by the physics plugin
  93544. * It holds a set of functions to control the underlying joint
  93545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93546. */
  93547. export class PhysicsJoint {
  93548. /**
  93549. * The type of the physics joint
  93550. */
  93551. type: number;
  93552. /**
  93553. * The data for the physics joint
  93554. */
  93555. jointData: PhysicsJointData;
  93556. private _physicsJoint;
  93557. protected _physicsPlugin: IPhysicsEnginePlugin;
  93558. /**
  93559. * Initializes the physics joint
  93560. * @param type The type of the physics joint
  93561. * @param jointData The data for the physics joint
  93562. */
  93563. constructor(
  93564. /**
  93565. * The type of the physics joint
  93566. */
  93567. type: number,
  93568. /**
  93569. * The data for the physics joint
  93570. */
  93571. jointData: PhysicsJointData);
  93572. /**
  93573. * Gets the physics joint
  93574. */
  93575. get physicsJoint(): any;
  93576. /**
  93577. * Sets the physics joint
  93578. */
  93579. set physicsJoint(newJoint: any);
  93580. /**
  93581. * Sets the physics plugin
  93582. */
  93583. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93584. /**
  93585. * Execute a function that is physics-plugin specific.
  93586. * @param {Function} func the function that will be executed.
  93587. * It accepts two parameters: the physics world and the physics joint
  93588. */
  93589. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93590. /**
  93591. * Distance-Joint type
  93592. */
  93593. static DistanceJoint: number;
  93594. /**
  93595. * Hinge-Joint type
  93596. */
  93597. static HingeJoint: number;
  93598. /**
  93599. * Ball-and-Socket joint type
  93600. */
  93601. static BallAndSocketJoint: number;
  93602. /**
  93603. * Wheel-Joint type
  93604. */
  93605. static WheelJoint: number;
  93606. /**
  93607. * Slider-Joint type
  93608. */
  93609. static SliderJoint: number;
  93610. /**
  93611. * Prismatic-Joint type
  93612. */
  93613. static PrismaticJoint: number;
  93614. /**
  93615. * Universal-Joint type
  93616. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93617. */
  93618. static UniversalJoint: number;
  93619. /**
  93620. * Hinge-Joint 2 type
  93621. */
  93622. static Hinge2Joint: number;
  93623. /**
  93624. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93625. */
  93626. static PointToPointJoint: number;
  93627. /**
  93628. * Spring-Joint type
  93629. */
  93630. static SpringJoint: number;
  93631. /**
  93632. * Lock-Joint type
  93633. */
  93634. static LockJoint: number;
  93635. }
  93636. /**
  93637. * A class representing a physics distance joint
  93638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93639. */
  93640. export class DistanceJoint extends PhysicsJoint {
  93641. /**
  93642. *
  93643. * @param jointData The data for the Distance-Joint
  93644. */
  93645. constructor(jointData: DistanceJointData);
  93646. /**
  93647. * Update the predefined distance.
  93648. * @param maxDistance The maximum preferred distance
  93649. * @param minDistance The minimum preferred distance
  93650. */
  93651. updateDistance(maxDistance: number, minDistance?: number): void;
  93652. }
  93653. /**
  93654. * Represents a Motor-Enabled Joint
  93655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93656. */
  93657. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93658. /**
  93659. * Initializes the Motor-Enabled Joint
  93660. * @param type The type of the joint
  93661. * @param jointData The physica joint data for the joint
  93662. */
  93663. constructor(type: number, jointData: PhysicsJointData);
  93664. /**
  93665. * Set the motor values.
  93666. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93667. * @param force the force to apply
  93668. * @param maxForce max force for this motor.
  93669. */
  93670. setMotor(force?: number, maxForce?: number): void;
  93671. /**
  93672. * Set the motor's limits.
  93673. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93674. * @param upperLimit The upper limit of the motor
  93675. * @param lowerLimit The lower limit of the motor
  93676. */
  93677. setLimit(upperLimit: number, lowerLimit?: number): void;
  93678. }
  93679. /**
  93680. * This class represents a single physics Hinge-Joint
  93681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93682. */
  93683. export class HingeJoint extends MotorEnabledJoint {
  93684. /**
  93685. * Initializes the Hinge-Joint
  93686. * @param jointData The joint data for the Hinge-Joint
  93687. */
  93688. constructor(jointData: PhysicsJointData);
  93689. /**
  93690. * Set the motor values.
  93691. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93692. * @param {number} force the force to apply
  93693. * @param {number} maxForce max force for this motor.
  93694. */
  93695. setMotor(force?: number, maxForce?: number): void;
  93696. /**
  93697. * Set the motor's limits.
  93698. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93699. * @param upperLimit The upper limit of the motor
  93700. * @param lowerLimit The lower limit of the motor
  93701. */
  93702. setLimit(upperLimit: number, lowerLimit?: number): void;
  93703. }
  93704. /**
  93705. * This class represents a dual hinge physics joint (same as wheel joint)
  93706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93707. */
  93708. export class Hinge2Joint extends MotorEnabledJoint {
  93709. /**
  93710. * Initializes the Hinge2-Joint
  93711. * @param jointData The joint data for the Hinge2-Joint
  93712. */
  93713. constructor(jointData: PhysicsJointData);
  93714. /**
  93715. * Set the motor values.
  93716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93717. * @param {number} targetSpeed the speed the motor is to reach
  93718. * @param {number} maxForce max force for this motor.
  93719. * @param {motorIndex} the motor's index, 0 or 1.
  93720. */
  93721. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93722. /**
  93723. * Set the motor limits.
  93724. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93725. * @param {number} upperLimit the upper limit
  93726. * @param {number} lowerLimit lower limit
  93727. * @param {motorIndex} the motor's index, 0 or 1.
  93728. */
  93729. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93730. }
  93731. /**
  93732. * Interface for a motor enabled joint
  93733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93734. */
  93735. export interface IMotorEnabledJoint {
  93736. /**
  93737. * Physics joint
  93738. */
  93739. physicsJoint: any;
  93740. /**
  93741. * Sets the motor of the motor-enabled joint
  93742. * @param force The force of the motor
  93743. * @param maxForce The maximum force of the motor
  93744. * @param motorIndex The index of the motor
  93745. */
  93746. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93747. /**
  93748. * Sets the limit of the motor
  93749. * @param upperLimit The upper limit of the motor
  93750. * @param lowerLimit The lower limit of the motor
  93751. * @param motorIndex The index of the motor
  93752. */
  93753. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93754. }
  93755. /**
  93756. * Joint data for a Distance-Joint
  93757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93758. */
  93759. export interface DistanceJointData extends PhysicsJointData {
  93760. /**
  93761. * Max distance the 2 joint objects can be apart
  93762. */
  93763. maxDistance: number;
  93764. }
  93765. /**
  93766. * Joint data from a spring joint
  93767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93768. */
  93769. export interface SpringJointData extends PhysicsJointData {
  93770. /**
  93771. * Length of the spring
  93772. */
  93773. length: number;
  93774. /**
  93775. * Stiffness of the spring
  93776. */
  93777. stiffness: number;
  93778. /**
  93779. * Damping of the spring
  93780. */
  93781. damping: number;
  93782. /** this callback will be called when applying the force to the impostors. */
  93783. forceApplicationCallback: () => void;
  93784. }
  93785. }
  93786. declare module BABYLON {
  93787. /**
  93788. * Holds the data for the raycast result
  93789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93790. */
  93791. export class PhysicsRaycastResult {
  93792. private _hasHit;
  93793. private _hitDistance;
  93794. private _hitNormalWorld;
  93795. private _hitPointWorld;
  93796. private _rayFromWorld;
  93797. private _rayToWorld;
  93798. /**
  93799. * Gets if there was a hit
  93800. */
  93801. get hasHit(): boolean;
  93802. /**
  93803. * Gets the distance from the hit
  93804. */
  93805. get hitDistance(): number;
  93806. /**
  93807. * Gets the hit normal/direction in the world
  93808. */
  93809. get hitNormalWorld(): Vector3;
  93810. /**
  93811. * Gets the hit point in the world
  93812. */
  93813. get hitPointWorld(): Vector3;
  93814. /**
  93815. * Gets the ray "start point" of the ray in the world
  93816. */
  93817. get rayFromWorld(): Vector3;
  93818. /**
  93819. * Gets the ray "end point" of the ray in the world
  93820. */
  93821. get rayToWorld(): Vector3;
  93822. /**
  93823. * Sets the hit data (normal & point in world space)
  93824. * @param hitNormalWorld defines the normal in world space
  93825. * @param hitPointWorld defines the point in world space
  93826. */
  93827. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93828. /**
  93829. * Sets the distance from the start point to the hit point
  93830. * @param distance
  93831. */
  93832. setHitDistance(distance: number): void;
  93833. /**
  93834. * Calculates the distance manually
  93835. */
  93836. calculateHitDistance(): void;
  93837. /**
  93838. * Resets all the values to default
  93839. * @param from The from point on world space
  93840. * @param to The to point on world space
  93841. */
  93842. reset(from?: Vector3, to?: Vector3): void;
  93843. }
  93844. /**
  93845. * Interface for the size containing width and height
  93846. */
  93847. interface IXYZ {
  93848. /**
  93849. * X
  93850. */
  93851. x: number;
  93852. /**
  93853. * Y
  93854. */
  93855. y: number;
  93856. /**
  93857. * Z
  93858. */
  93859. z: number;
  93860. }
  93861. }
  93862. declare module BABYLON {
  93863. /**
  93864. * Interface used to describe a physics joint
  93865. */
  93866. export interface PhysicsImpostorJoint {
  93867. /** Defines the main impostor to which the joint is linked */
  93868. mainImpostor: PhysicsImpostor;
  93869. /** Defines the impostor that is connected to the main impostor using this joint */
  93870. connectedImpostor: PhysicsImpostor;
  93871. /** Defines the joint itself */
  93872. joint: PhysicsJoint;
  93873. }
  93874. /** @hidden */
  93875. export interface IPhysicsEnginePlugin {
  93876. world: any;
  93877. name: string;
  93878. setGravity(gravity: Vector3): void;
  93879. setTimeStep(timeStep: number): void;
  93880. getTimeStep(): number;
  93881. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93882. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93883. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93884. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93885. removePhysicsBody(impostor: PhysicsImpostor): void;
  93886. generateJoint(joint: PhysicsImpostorJoint): void;
  93887. removeJoint(joint: PhysicsImpostorJoint): void;
  93888. isSupported(): boolean;
  93889. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93890. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93891. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93892. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93893. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93894. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93895. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93896. getBodyMass(impostor: PhysicsImpostor): number;
  93897. getBodyFriction(impostor: PhysicsImpostor): number;
  93898. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93899. getBodyRestitution(impostor: PhysicsImpostor): number;
  93900. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93901. getBodyPressure?(impostor: PhysicsImpostor): number;
  93902. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93903. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93904. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93905. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93906. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93907. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93908. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93909. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93910. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93911. sleepBody(impostor: PhysicsImpostor): void;
  93912. wakeUpBody(impostor: PhysicsImpostor): void;
  93913. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93914. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93915. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93917. getRadius(impostor: PhysicsImpostor): number;
  93918. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93919. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93920. dispose(): void;
  93921. }
  93922. /**
  93923. * Interface used to define a physics engine
  93924. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93925. */
  93926. export interface IPhysicsEngine {
  93927. /**
  93928. * Gets the gravity vector used by the simulation
  93929. */
  93930. gravity: Vector3;
  93931. /**
  93932. * Sets the gravity vector used by the simulation
  93933. * @param gravity defines the gravity vector to use
  93934. */
  93935. setGravity(gravity: Vector3): void;
  93936. /**
  93937. * Set the time step of the physics engine.
  93938. * Default is 1/60.
  93939. * To slow it down, enter 1/600 for example.
  93940. * To speed it up, 1/30
  93941. * @param newTimeStep the new timestep to apply to this world.
  93942. */
  93943. setTimeStep(newTimeStep: number): void;
  93944. /**
  93945. * Get the time step of the physics engine.
  93946. * @returns the current time step
  93947. */
  93948. getTimeStep(): number;
  93949. /**
  93950. * Set the sub time step of the physics engine.
  93951. * Default is 0 meaning there is no sub steps
  93952. * To increase physics resolution precision, set a small value (like 1 ms)
  93953. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93954. */
  93955. setSubTimeStep(subTimeStep: number): void;
  93956. /**
  93957. * Get the sub time step of the physics engine.
  93958. * @returns the current sub time step
  93959. */
  93960. getSubTimeStep(): number;
  93961. /**
  93962. * Release all resources
  93963. */
  93964. dispose(): void;
  93965. /**
  93966. * Gets the name of the current physics plugin
  93967. * @returns the name of the plugin
  93968. */
  93969. getPhysicsPluginName(): string;
  93970. /**
  93971. * Adding a new impostor for the impostor tracking.
  93972. * This will be done by the impostor itself.
  93973. * @param impostor the impostor to add
  93974. */
  93975. addImpostor(impostor: PhysicsImpostor): void;
  93976. /**
  93977. * Remove an impostor from the engine.
  93978. * This impostor and its mesh will not longer be updated by the physics engine.
  93979. * @param impostor the impostor to remove
  93980. */
  93981. removeImpostor(impostor: PhysicsImpostor): void;
  93982. /**
  93983. * Add a joint to the physics engine
  93984. * @param mainImpostor defines the main impostor to which the joint is added.
  93985. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93986. * @param joint defines the joint that will connect both impostors.
  93987. */
  93988. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93989. /**
  93990. * Removes a joint from the simulation
  93991. * @param mainImpostor defines the impostor used with the joint
  93992. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93993. * @param joint defines the joint to remove
  93994. */
  93995. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93996. /**
  93997. * Gets the current plugin used to run the simulation
  93998. * @returns current plugin
  93999. */
  94000. getPhysicsPlugin(): IPhysicsEnginePlugin;
  94001. /**
  94002. * Gets the list of physic impostors
  94003. * @returns an array of PhysicsImpostor
  94004. */
  94005. getImpostors(): Array<PhysicsImpostor>;
  94006. /**
  94007. * Gets the impostor for a physics enabled object
  94008. * @param object defines the object impersonated by the impostor
  94009. * @returns the PhysicsImpostor or null if not found
  94010. */
  94011. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94012. /**
  94013. * Gets the impostor for a physics body object
  94014. * @param body defines physics body used by the impostor
  94015. * @returns the PhysicsImpostor or null if not found
  94016. */
  94017. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  94018. /**
  94019. * Does a raycast in the physics world
  94020. * @param from when should the ray start?
  94021. * @param to when should the ray end?
  94022. * @returns PhysicsRaycastResult
  94023. */
  94024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94025. /**
  94026. * Called by the scene. No need to call it.
  94027. * @param delta defines the timespam between frames
  94028. */
  94029. _step(delta: number): void;
  94030. }
  94031. }
  94032. declare module BABYLON {
  94033. /**
  94034. * The interface for the physics imposter parameters
  94035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94036. */
  94037. export interface PhysicsImpostorParameters {
  94038. /**
  94039. * The mass of the physics imposter
  94040. */
  94041. mass: number;
  94042. /**
  94043. * The friction of the physics imposter
  94044. */
  94045. friction?: number;
  94046. /**
  94047. * The coefficient of restitution of the physics imposter
  94048. */
  94049. restitution?: number;
  94050. /**
  94051. * The native options of the physics imposter
  94052. */
  94053. nativeOptions?: any;
  94054. /**
  94055. * Specifies if the parent should be ignored
  94056. */
  94057. ignoreParent?: boolean;
  94058. /**
  94059. * Specifies if bi-directional transformations should be disabled
  94060. */
  94061. disableBidirectionalTransformation?: boolean;
  94062. /**
  94063. * The pressure inside the physics imposter, soft object only
  94064. */
  94065. pressure?: number;
  94066. /**
  94067. * The stiffness the physics imposter, soft object only
  94068. */
  94069. stiffness?: number;
  94070. /**
  94071. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94072. */
  94073. velocityIterations?: number;
  94074. /**
  94075. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94076. */
  94077. positionIterations?: number;
  94078. /**
  94079. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94080. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94081. * Add to fix multiple points
  94082. */
  94083. fixedPoints?: number;
  94084. /**
  94085. * The collision margin around a soft object
  94086. */
  94087. margin?: number;
  94088. /**
  94089. * The collision margin around a soft object
  94090. */
  94091. damping?: number;
  94092. /**
  94093. * The path for a rope based on an extrusion
  94094. */
  94095. path?: any;
  94096. /**
  94097. * The shape of an extrusion used for a rope based on an extrusion
  94098. */
  94099. shape?: any;
  94100. }
  94101. /**
  94102. * Interface for a physics-enabled object
  94103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94104. */
  94105. export interface IPhysicsEnabledObject {
  94106. /**
  94107. * The position of the physics-enabled object
  94108. */
  94109. position: Vector3;
  94110. /**
  94111. * The rotation of the physics-enabled object
  94112. */
  94113. rotationQuaternion: Nullable<Quaternion>;
  94114. /**
  94115. * The scale of the physics-enabled object
  94116. */
  94117. scaling: Vector3;
  94118. /**
  94119. * The rotation of the physics-enabled object
  94120. */
  94121. rotation?: Vector3;
  94122. /**
  94123. * The parent of the physics-enabled object
  94124. */
  94125. parent?: any;
  94126. /**
  94127. * The bounding info of the physics-enabled object
  94128. * @returns The bounding info of the physics-enabled object
  94129. */
  94130. getBoundingInfo(): BoundingInfo;
  94131. /**
  94132. * Computes the world matrix
  94133. * @param force Specifies if the world matrix should be computed by force
  94134. * @returns A world matrix
  94135. */
  94136. computeWorldMatrix(force: boolean): Matrix;
  94137. /**
  94138. * Gets the world matrix
  94139. * @returns A world matrix
  94140. */
  94141. getWorldMatrix?(): Matrix;
  94142. /**
  94143. * Gets the child meshes
  94144. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94145. * @returns An array of abstract meshes
  94146. */
  94147. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94148. /**
  94149. * Gets the vertex data
  94150. * @param kind The type of vertex data
  94151. * @returns A nullable array of numbers, or a float32 array
  94152. */
  94153. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94154. /**
  94155. * Gets the indices from the mesh
  94156. * @returns A nullable array of index arrays
  94157. */
  94158. getIndices?(): Nullable<IndicesArray>;
  94159. /**
  94160. * Gets the scene from the mesh
  94161. * @returns the indices array or null
  94162. */
  94163. getScene?(): Scene;
  94164. /**
  94165. * Gets the absolute position from the mesh
  94166. * @returns the absolute position
  94167. */
  94168. getAbsolutePosition(): Vector3;
  94169. /**
  94170. * Gets the absolute pivot point from the mesh
  94171. * @returns the absolute pivot point
  94172. */
  94173. getAbsolutePivotPoint(): Vector3;
  94174. /**
  94175. * Rotates the mesh
  94176. * @param axis The axis of rotation
  94177. * @param amount The amount of rotation
  94178. * @param space The space of the rotation
  94179. * @returns The rotation transform node
  94180. */
  94181. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94182. /**
  94183. * Translates the mesh
  94184. * @param axis The axis of translation
  94185. * @param distance The distance of translation
  94186. * @param space The space of the translation
  94187. * @returns The transform node
  94188. */
  94189. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94190. /**
  94191. * Sets the absolute position of the mesh
  94192. * @param absolutePosition The absolute position of the mesh
  94193. * @returns The transform node
  94194. */
  94195. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94196. /**
  94197. * Gets the class name of the mesh
  94198. * @returns The class name
  94199. */
  94200. getClassName(): string;
  94201. }
  94202. /**
  94203. * Represents a physics imposter
  94204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94205. */
  94206. export class PhysicsImpostor {
  94207. /**
  94208. * The physics-enabled object used as the physics imposter
  94209. */
  94210. object: IPhysicsEnabledObject;
  94211. /**
  94212. * The type of the physics imposter
  94213. */
  94214. type: number;
  94215. private _options;
  94216. private _scene?;
  94217. /**
  94218. * The default object size of the imposter
  94219. */
  94220. static DEFAULT_OBJECT_SIZE: Vector3;
  94221. /**
  94222. * The identity quaternion of the imposter
  94223. */
  94224. static IDENTITY_QUATERNION: Quaternion;
  94225. /** @hidden */
  94226. _pluginData: any;
  94227. private _physicsEngine;
  94228. private _physicsBody;
  94229. private _bodyUpdateRequired;
  94230. private _onBeforePhysicsStepCallbacks;
  94231. private _onAfterPhysicsStepCallbacks;
  94232. /** @hidden */
  94233. _onPhysicsCollideCallbacks: Array<{
  94234. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94235. otherImpostors: Array<PhysicsImpostor>;
  94236. }>;
  94237. private _deltaPosition;
  94238. private _deltaRotation;
  94239. private _deltaRotationConjugated;
  94240. /** @hidden */
  94241. _isFromLine: boolean;
  94242. private _parent;
  94243. private _isDisposed;
  94244. private static _tmpVecs;
  94245. private static _tmpQuat;
  94246. /**
  94247. * Specifies if the physics imposter is disposed
  94248. */
  94249. get isDisposed(): boolean;
  94250. /**
  94251. * Gets the mass of the physics imposter
  94252. */
  94253. get mass(): number;
  94254. set mass(value: number);
  94255. /**
  94256. * Gets the coefficient of friction
  94257. */
  94258. get friction(): number;
  94259. /**
  94260. * Sets the coefficient of friction
  94261. */
  94262. set friction(value: number);
  94263. /**
  94264. * Gets the coefficient of restitution
  94265. */
  94266. get restitution(): number;
  94267. /**
  94268. * Sets the coefficient of restitution
  94269. */
  94270. set restitution(value: number);
  94271. /**
  94272. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94273. */
  94274. get pressure(): number;
  94275. /**
  94276. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94277. */
  94278. set pressure(value: number);
  94279. /**
  94280. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94281. */
  94282. get stiffness(): number;
  94283. /**
  94284. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94285. */
  94286. set stiffness(value: number);
  94287. /**
  94288. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94289. */
  94290. get velocityIterations(): number;
  94291. /**
  94292. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94293. */
  94294. set velocityIterations(value: number);
  94295. /**
  94296. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94297. */
  94298. get positionIterations(): number;
  94299. /**
  94300. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94301. */
  94302. set positionIterations(value: number);
  94303. /**
  94304. * The unique id of the physics imposter
  94305. * set by the physics engine when adding this impostor to the array
  94306. */
  94307. uniqueId: number;
  94308. /**
  94309. * @hidden
  94310. */
  94311. soft: boolean;
  94312. /**
  94313. * @hidden
  94314. */
  94315. segments: number;
  94316. private _joints;
  94317. /**
  94318. * Initializes the physics imposter
  94319. * @param object The physics-enabled object used as the physics imposter
  94320. * @param type The type of the physics imposter
  94321. * @param _options The options for the physics imposter
  94322. * @param _scene The Babylon scene
  94323. */
  94324. constructor(
  94325. /**
  94326. * The physics-enabled object used as the physics imposter
  94327. */
  94328. object: IPhysicsEnabledObject,
  94329. /**
  94330. * The type of the physics imposter
  94331. */
  94332. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94333. /**
  94334. * This function will completly initialize this impostor.
  94335. * It will create a new body - but only if this mesh has no parent.
  94336. * If it has, this impostor will not be used other than to define the impostor
  94337. * of the child mesh.
  94338. * @hidden
  94339. */
  94340. _init(): void;
  94341. private _getPhysicsParent;
  94342. /**
  94343. * Should a new body be generated.
  94344. * @returns boolean specifying if body initialization is required
  94345. */
  94346. isBodyInitRequired(): boolean;
  94347. /**
  94348. * Sets the updated scaling
  94349. * @param updated Specifies if the scaling is updated
  94350. */
  94351. setScalingUpdated(): void;
  94352. /**
  94353. * Force a regeneration of this or the parent's impostor's body.
  94354. * Use under cautious - This will remove all joints already implemented.
  94355. */
  94356. forceUpdate(): void;
  94357. /**
  94358. * Gets the body that holds this impostor. Either its own, or its parent.
  94359. */
  94360. get physicsBody(): any;
  94361. /**
  94362. * Get the parent of the physics imposter
  94363. * @returns Physics imposter or null
  94364. */
  94365. get parent(): Nullable<PhysicsImpostor>;
  94366. /**
  94367. * Sets the parent of the physics imposter
  94368. */
  94369. set parent(value: Nullable<PhysicsImpostor>);
  94370. /**
  94371. * Set the physics body. Used mainly by the physics engine/plugin
  94372. */
  94373. set physicsBody(physicsBody: any);
  94374. /**
  94375. * Resets the update flags
  94376. */
  94377. resetUpdateFlags(): void;
  94378. /**
  94379. * Gets the object extend size
  94380. * @returns the object extend size
  94381. */
  94382. getObjectExtendSize(): Vector3;
  94383. /**
  94384. * Gets the object center
  94385. * @returns The object center
  94386. */
  94387. getObjectCenter(): Vector3;
  94388. /**
  94389. * Get a specific parametes from the options parameter
  94390. * @param paramName The object parameter name
  94391. * @returns The object parameter
  94392. */
  94393. getParam(paramName: string): any;
  94394. /**
  94395. * Sets a specific parameter in the options given to the physics plugin
  94396. * @param paramName The parameter name
  94397. * @param value The value of the parameter
  94398. */
  94399. setParam(paramName: string, value: number): void;
  94400. /**
  94401. * Specifically change the body's mass option. Won't recreate the physics body object
  94402. * @param mass The mass of the physics imposter
  94403. */
  94404. setMass(mass: number): void;
  94405. /**
  94406. * Gets the linear velocity
  94407. * @returns linear velocity or null
  94408. */
  94409. getLinearVelocity(): Nullable<Vector3>;
  94410. /**
  94411. * Sets the linear velocity
  94412. * @param velocity linear velocity or null
  94413. */
  94414. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94415. /**
  94416. * Gets the angular velocity
  94417. * @returns angular velocity or null
  94418. */
  94419. getAngularVelocity(): Nullable<Vector3>;
  94420. /**
  94421. * Sets the angular velocity
  94422. * @param velocity The velocity or null
  94423. */
  94424. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94425. /**
  94426. * Execute a function with the physics plugin native code
  94427. * Provide a function the will have two variables - the world object and the physics body object
  94428. * @param func The function to execute with the physics plugin native code
  94429. */
  94430. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94431. /**
  94432. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94436. /**
  94437. * Unregister a function that will be executed before the physics world is stepping forward
  94438. * @param func The function to execute before the physics world is stepped forward
  94439. */
  94440. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94441. /**
  94442. * Register a function that will be executed after the physics step
  94443. * @param func The function to execute after physics step
  94444. */
  94445. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94446. /**
  94447. * Unregisters a function that will be executed after the physics step
  94448. * @param func The function to execute after physics step
  94449. */
  94450. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94451. /**
  94452. * register a function that will be executed when this impostor collides against a different body
  94453. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94454. * @param func Callback that is executed on collision
  94455. */
  94456. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94457. /**
  94458. * Unregisters the physics imposter on contact
  94459. * @param collideAgainst The physics object to collide against
  94460. * @param func Callback to execute on collision
  94461. */
  94462. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94463. private _tmpQuat;
  94464. private _tmpQuat2;
  94465. /**
  94466. * Get the parent rotation
  94467. * @returns The parent rotation
  94468. */
  94469. getParentsRotation(): Quaternion;
  94470. /**
  94471. * this function is executed by the physics engine.
  94472. */
  94473. beforeStep: () => void;
  94474. /**
  94475. * this function is executed by the physics engine
  94476. */
  94477. afterStep: () => void;
  94478. /**
  94479. * Legacy collision detection event support
  94480. */
  94481. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94482. /**
  94483. * event and body object due to cannon's event-based architecture.
  94484. */
  94485. onCollide: (e: {
  94486. body: any;
  94487. }) => void;
  94488. /**
  94489. * Apply a force
  94490. * @param force The force to apply
  94491. * @param contactPoint The contact point for the force
  94492. * @returns The physics imposter
  94493. */
  94494. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94495. /**
  94496. * Apply an impulse
  94497. * @param force The impulse force
  94498. * @param contactPoint The contact point for the impulse force
  94499. * @returns The physics imposter
  94500. */
  94501. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94502. /**
  94503. * A help function to create a joint
  94504. * @param otherImpostor A physics imposter used to create a joint
  94505. * @param jointType The type of joint
  94506. * @param jointData The data for the joint
  94507. * @returns The physics imposter
  94508. */
  94509. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94510. /**
  94511. * Add a joint to this impostor with a different impostor
  94512. * @param otherImpostor A physics imposter used to add a joint
  94513. * @param joint The joint to add
  94514. * @returns The physics imposter
  94515. */
  94516. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94517. /**
  94518. * Add an anchor to a cloth impostor
  94519. * @param otherImpostor rigid impostor to anchor to
  94520. * @param width ratio across width from 0 to 1
  94521. * @param height ratio up height from 0 to 1
  94522. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94523. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94524. * @returns impostor the soft imposter
  94525. */
  94526. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94527. /**
  94528. * Add a hook to a rope impostor
  94529. * @param otherImpostor rigid impostor to anchor to
  94530. * @param length ratio across rope from 0 to 1
  94531. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94532. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94533. * @returns impostor the rope imposter
  94534. */
  94535. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94536. /**
  94537. * Will keep this body still, in a sleep mode.
  94538. * @returns the physics imposter
  94539. */
  94540. sleep(): PhysicsImpostor;
  94541. /**
  94542. * Wake the body up.
  94543. * @returns The physics imposter
  94544. */
  94545. wakeUp(): PhysicsImpostor;
  94546. /**
  94547. * Clones the physics imposter
  94548. * @param newObject The physics imposter clones to this physics-enabled object
  94549. * @returns A nullable physics imposter
  94550. */
  94551. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94552. /**
  94553. * Disposes the physics imposter
  94554. */
  94555. dispose(): void;
  94556. /**
  94557. * Sets the delta position
  94558. * @param position The delta position amount
  94559. */
  94560. setDeltaPosition(position: Vector3): void;
  94561. /**
  94562. * Sets the delta rotation
  94563. * @param rotation The delta rotation amount
  94564. */
  94565. setDeltaRotation(rotation: Quaternion): void;
  94566. /**
  94567. * Gets the box size of the physics imposter and stores the result in the input parameter
  94568. * @param result Stores the box size
  94569. * @returns The physics imposter
  94570. */
  94571. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94572. /**
  94573. * Gets the radius of the physics imposter
  94574. * @returns Radius of the physics imposter
  94575. */
  94576. getRadius(): number;
  94577. /**
  94578. * Sync a bone with this impostor
  94579. * @param bone The bone to sync to the impostor.
  94580. * @param boneMesh The mesh that the bone is influencing.
  94581. * @param jointPivot The pivot of the joint / bone in local space.
  94582. * @param distToJoint Optional distance from the impostor to the joint.
  94583. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94584. */
  94585. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94586. /**
  94587. * Sync impostor to a bone
  94588. * @param bone The bone that the impostor will be synced to.
  94589. * @param boneMesh The mesh that the bone is influencing.
  94590. * @param jointPivot The pivot of the joint / bone in local space.
  94591. * @param distToJoint Optional distance from the impostor to the joint.
  94592. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94593. * @param boneAxis Optional vector3 axis the bone is aligned with
  94594. */
  94595. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94596. /**
  94597. * No-Imposter type
  94598. */
  94599. static NoImpostor: number;
  94600. /**
  94601. * Sphere-Imposter type
  94602. */
  94603. static SphereImpostor: number;
  94604. /**
  94605. * Box-Imposter type
  94606. */
  94607. static BoxImpostor: number;
  94608. /**
  94609. * Plane-Imposter type
  94610. */
  94611. static PlaneImpostor: number;
  94612. /**
  94613. * Mesh-imposter type
  94614. */
  94615. static MeshImpostor: number;
  94616. /**
  94617. * Capsule-Impostor type (Ammo.js plugin only)
  94618. */
  94619. static CapsuleImpostor: number;
  94620. /**
  94621. * Cylinder-Imposter type
  94622. */
  94623. static CylinderImpostor: number;
  94624. /**
  94625. * Particle-Imposter type
  94626. */
  94627. static ParticleImpostor: number;
  94628. /**
  94629. * Heightmap-Imposter type
  94630. */
  94631. static HeightmapImpostor: number;
  94632. /**
  94633. * ConvexHull-Impostor type (Ammo.js plugin only)
  94634. */
  94635. static ConvexHullImpostor: number;
  94636. /**
  94637. * Custom-Imposter type (Ammo.js plugin only)
  94638. */
  94639. static CustomImpostor: number;
  94640. /**
  94641. * Rope-Imposter type
  94642. */
  94643. static RopeImpostor: number;
  94644. /**
  94645. * Cloth-Imposter type
  94646. */
  94647. static ClothImpostor: number;
  94648. /**
  94649. * Softbody-Imposter type
  94650. */
  94651. static SoftbodyImpostor: number;
  94652. }
  94653. }
  94654. declare module BABYLON {
  94655. /**
  94656. * @hidden
  94657. **/
  94658. export class _CreationDataStorage {
  94659. closePath?: boolean;
  94660. closeArray?: boolean;
  94661. idx: number[];
  94662. dashSize: number;
  94663. gapSize: number;
  94664. path3D: Path3D;
  94665. pathArray: Vector3[][];
  94666. arc: number;
  94667. radius: number;
  94668. cap: number;
  94669. tessellation: number;
  94670. }
  94671. /**
  94672. * @hidden
  94673. **/
  94674. class _InstanceDataStorage {
  94675. visibleInstances: any;
  94676. batchCache: _InstancesBatch;
  94677. instancesBufferSize: number;
  94678. instancesBuffer: Nullable<Buffer>;
  94679. instancesData: Float32Array;
  94680. overridenInstanceCount: number;
  94681. isFrozen: boolean;
  94682. previousBatch: Nullable<_InstancesBatch>;
  94683. hardwareInstancedRendering: boolean;
  94684. sideOrientation: number;
  94685. manualUpdate: boolean;
  94686. }
  94687. /**
  94688. * @hidden
  94689. **/
  94690. export class _InstancesBatch {
  94691. mustReturn: boolean;
  94692. visibleInstances: Nullable<InstancedMesh[]>[];
  94693. renderSelf: boolean[];
  94694. hardwareInstancedRendering: boolean[];
  94695. }
  94696. /**
  94697. * Class used to represent renderable models
  94698. */
  94699. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94700. /**
  94701. * Mesh side orientation : usually the external or front surface
  94702. */
  94703. static readonly FRONTSIDE: number;
  94704. /**
  94705. * Mesh side orientation : usually the internal or back surface
  94706. */
  94707. static readonly BACKSIDE: number;
  94708. /**
  94709. * Mesh side orientation : both internal and external or front and back surfaces
  94710. */
  94711. static readonly DOUBLESIDE: number;
  94712. /**
  94713. * Mesh side orientation : by default, `FRONTSIDE`
  94714. */
  94715. static readonly DEFAULTSIDE: number;
  94716. /**
  94717. * Mesh cap setting : no cap
  94718. */
  94719. static readonly NO_CAP: number;
  94720. /**
  94721. * Mesh cap setting : one cap at the beginning of the mesh
  94722. */
  94723. static readonly CAP_START: number;
  94724. /**
  94725. * Mesh cap setting : one cap at the end of the mesh
  94726. */
  94727. static readonly CAP_END: number;
  94728. /**
  94729. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94730. */
  94731. static readonly CAP_ALL: number;
  94732. /**
  94733. * Mesh pattern setting : no flip or rotate
  94734. */
  94735. static readonly NO_FLIP: number;
  94736. /**
  94737. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94738. */
  94739. static readonly FLIP_TILE: number;
  94740. /**
  94741. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94742. */
  94743. static readonly ROTATE_TILE: number;
  94744. /**
  94745. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94746. */
  94747. static readonly FLIP_ROW: number;
  94748. /**
  94749. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94750. */
  94751. static readonly ROTATE_ROW: number;
  94752. /**
  94753. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94754. */
  94755. static readonly FLIP_N_ROTATE_TILE: number;
  94756. /**
  94757. * Mesh pattern setting : rotate pattern and rotate
  94758. */
  94759. static readonly FLIP_N_ROTATE_ROW: number;
  94760. /**
  94761. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94762. */
  94763. static readonly CENTER: number;
  94764. /**
  94765. * Mesh tile positioning : part tiles on left
  94766. */
  94767. static readonly LEFT: number;
  94768. /**
  94769. * Mesh tile positioning : part tiles on right
  94770. */
  94771. static readonly RIGHT: number;
  94772. /**
  94773. * Mesh tile positioning : part tiles on top
  94774. */
  94775. static readonly TOP: number;
  94776. /**
  94777. * Mesh tile positioning : part tiles on bottom
  94778. */
  94779. static readonly BOTTOM: number;
  94780. /**
  94781. * Gets the default side orientation.
  94782. * @param orientation the orientation to value to attempt to get
  94783. * @returns the default orientation
  94784. * @hidden
  94785. */
  94786. static _GetDefaultSideOrientation(orientation?: number): number;
  94787. private _internalMeshDataInfo;
  94788. /**
  94789. * An event triggered before rendering the mesh
  94790. */
  94791. get onBeforeRenderObservable(): Observable<Mesh>;
  94792. /**
  94793. * An event triggered before binding the mesh
  94794. */
  94795. get onBeforeBindObservable(): Observable<Mesh>;
  94796. /**
  94797. * An event triggered after rendering the mesh
  94798. */
  94799. get onAfterRenderObservable(): Observable<Mesh>;
  94800. /**
  94801. * An event triggered before drawing the mesh
  94802. */
  94803. get onBeforeDrawObservable(): Observable<Mesh>;
  94804. private _onBeforeDrawObserver;
  94805. /**
  94806. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94807. */
  94808. set onBeforeDraw(callback: () => void);
  94809. get hasInstances(): boolean;
  94810. /**
  94811. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94812. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94813. */
  94814. delayLoadState: number;
  94815. /**
  94816. * Gets the list of instances created from this mesh
  94817. * it is not supposed to be modified manually.
  94818. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94819. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94820. */
  94821. instances: InstancedMesh[];
  94822. /**
  94823. * Gets the file containing delay loading data for this mesh
  94824. */
  94825. delayLoadingFile: string;
  94826. /** @hidden */
  94827. _binaryInfo: any;
  94828. /**
  94829. * User defined function used to change how LOD level selection is done
  94830. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94831. */
  94832. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94833. /**
  94834. * Gets or sets the morph target manager
  94835. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94836. */
  94837. get morphTargetManager(): Nullable<MorphTargetManager>;
  94838. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94839. /** @hidden */
  94840. _creationDataStorage: Nullable<_CreationDataStorage>;
  94841. /** @hidden */
  94842. _geometry: Nullable<Geometry>;
  94843. /** @hidden */
  94844. _delayInfo: Array<string>;
  94845. /** @hidden */
  94846. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94847. /** @hidden */
  94848. _instanceDataStorage: _InstanceDataStorage;
  94849. private _effectiveMaterial;
  94850. /** @hidden */
  94851. _shouldGenerateFlatShading: boolean;
  94852. /** @hidden */
  94853. _originalBuilderSideOrientation: number;
  94854. /**
  94855. * Use this property to change the original side orientation defined at construction time
  94856. */
  94857. overrideMaterialSideOrientation: Nullable<number>;
  94858. /**
  94859. * Gets the source mesh (the one used to clone this one from)
  94860. */
  94861. get source(): Nullable<Mesh>;
  94862. /**
  94863. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94864. */
  94865. get isUnIndexed(): boolean;
  94866. set isUnIndexed(value: boolean);
  94867. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94868. get worldMatrixInstancedBuffer(): Float32Array;
  94869. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94870. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94871. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94872. /**
  94873. * @constructor
  94874. * @param name The value used by scene.getMeshByName() to do a lookup.
  94875. * @param scene The scene to add this mesh to.
  94876. * @param parent The parent of this mesh, if it has one
  94877. * @param source An optional Mesh from which geometry is shared, cloned.
  94878. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94879. * When false, achieved by calling a clone(), also passing False.
  94880. * This will make creation of children, recursive.
  94881. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94882. */
  94883. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94884. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94885. doNotInstantiate: boolean;
  94886. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94887. /**
  94888. * Gets the class name
  94889. * @returns the string "Mesh".
  94890. */
  94891. getClassName(): string;
  94892. /** @hidden */
  94893. get _isMesh(): boolean;
  94894. /**
  94895. * Returns a description of this mesh
  94896. * @param fullDetails define if full details about this mesh must be used
  94897. * @returns a descriptive string representing this mesh
  94898. */
  94899. toString(fullDetails?: boolean): string;
  94900. /** @hidden */
  94901. _unBindEffect(): void;
  94902. /**
  94903. * Gets a boolean indicating if this mesh has LOD
  94904. */
  94905. get hasLODLevels(): boolean;
  94906. /**
  94907. * Gets the list of MeshLODLevel associated with the current mesh
  94908. * @returns an array of MeshLODLevel
  94909. */
  94910. getLODLevels(): MeshLODLevel[];
  94911. private _sortLODLevels;
  94912. /**
  94913. * Add a mesh as LOD level triggered at the given distance.
  94914. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94915. * @param distance The distance from the center of the object to show this level
  94916. * @param mesh The mesh to be added as LOD level (can be null)
  94917. * @return This mesh (for chaining)
  94918. */
  94919. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94920. /**
  94921. * Returns the LOD level mesh at the passed distance or null if not found.
  94922. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94923. * @param distance The distance from the center of the object to show this level
  94924. * @returns a Mesh or `null`
  94925. */
  94926. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94927. /**
  94928. * Remove a mesh from the LOD array
  94929. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94930. * @param mesh defines the mesh to be removed
  94931. * @return This mesh (for chaining)
  94932. */
  94933. removeLODLevel(mesh: Mesh): Mesh;
  94934. /**
  94935. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94936. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94937. * @param camera defines the camera to use to compute distance
  94938. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94939. * @return This mesh (for chaining)
  94940. */
  94941. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94942. /**
  94943. * Gets the mesh internal Geometry object
  94944. */
  94945. get geometry(): Nullable<Geometry>;
  94946. /**
  94947. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94948. * @returns the total number of vertices
  94949. */
  94950. getTotalVertices(): number;
  94951. /**
  94952. * Returns the content of an associated vertex buffer
  94953. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94954. * - VertexBuffer.PositionKind
  94955. * - VertexBuffer.UVKind
  94956. * - VertexBuffer.UV2Kind
  94957. * - VertexBuffer.UV3Kind
  94958. * - VertexBuffer.UV4Kind
  94959. * - VertexBuffer.UV5Kind
  94960. * - VertexBuffer.UV6Kind
  94961. * - VertexBuffer.ColorKind
  94962. * - VertexBuffer.MatricesIndicesKind
  94963. * - VertexBuffer.MatricesIndicesExtraKind
  94964. * - VertexBuffer.MatricesWeightsKind
  94965. * - VertexBuffer.MatricesWeightsExtraKind
  94966. * @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
  94967. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94968. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94969. */
  94970. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94971. /**
  94972. * Returns the mesh VertexBuffer object from the requested `kind`
  94973. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94974. * - VertexBuffer.PositionKind
  94975. * - VertexBuffer.NormalKind
  94976. * - VertexBuffer.UVKind
  94977. * - VertexBuffer.UV2Kind
  94978. * - VertexBuffer.UV3Kind
  94979. * - VertexBuffer.UV4Kind
  94980. * - VertexBuffer.UV5Kind
  94981. * - VertexBuffer.UV6Kind
  94982. * - VertexBuffer.ColorKind
  94983. * - VertexBuffer.MatricesIndicesKind
  94984. * - VertexBuffer.MatricesIndicesExtraKind
  94985. * - VertexBuffer.MatricesWeightsKind
  94986. * - VertexBuffer.MatricesWeightsExtraKind
  94987. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94988. */
  94989. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94990. /**
  94991. * Tests if a specific vertex buffer is associated with this mesh
  94992. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94993. * - VertexBuffer.PositionKind
  94994. * - VertexBuffer.NormalKind
  94995. * - VertexBuffer.UVKind
  94996. * - VertexBuffer.UV2Kind
  94997. * - VertexBuffer.UV3Kind
  94998. * - VertexBuffer.UV4Kind
  94999. * - VertexBuffer.UV5Kind
  95000. * - VertexBuffer.UV6Kind
  95001. * - VertexBuffer.ColorKind
  95002. * - VertexBuffer.MatricesIndicesKind
  95003. * - VertexBuffer.MatricesIndicesExtraKind
  95004. * - VertexBuffer.MatricesWeightsKind
  95005. * - VertexBuffer.MatricesWeightsExtraKind
  95006. * @returns a boolean
  95007. */
  95008. isVerticesDataPresent(kind: string): boolean;
  95009. /**
  95010. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  95011. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95012. * - VertexBuffer.PositionKind
  95013. * - VertexBuffer.UVKind
  95014. * - VertexBuffer.UV2Kind
  95015. * - VertexBuffer.UV3Kind
  95016. * - VertexBuffer.UV4Kind
  95017. * - VertexBuffer.UV5Kind
  95018. * - VertexBuffer.UV6Kind
  95019. * - VertexBuffer.ColorKind
  95020. * - VertexBuffer.MatricesIndicesKind
  95021. * - VertexBuffer.MatricesIndicesExtraKind
  95022. * - VertexBuffer.MatricesWeightsKind
  95023. * - VertexBuffer.MatricesWeightsExtraKind
  95024. * @returns a boolean
  95025. */
  95026. isVertexBufferUpdatable(kind: string): boolean;
  95027. /**
  95028. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  95029. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95030. * - VertexBuffer.PositionKind
  95031. * - VertexBuffer.NormalKind
  95032. * - VertexBuffer.UVKind
  95033. * - VertexBuffer.UV2Kind
  95034. * - VertexBuffer.UV3Kind
  95035. * - VertexBuffer.UV4Kind
  95036. * - VertexBuffer.UV5Kind
  95037. * - VertexBuffer.UV6Kind
  95038. * - VertexBuffer.ColorKind
  95039. * - VertexBuffer.MatricesIndicesKind
  95040. * - VertexBuffer.MatricesIndicesExtraKind
  95041. * - VertexBuffer.MatricesWeightsKind
  95042. * - VertexBuffer.MatricesWeightsExtraKind
  95043. * @returns an array of strings
  95044. */
  95045. getVerticesDataKinds(): string[];
  95046. /**
  95047. * Returns a positive integer : the total number of indices in this mesh geometry.
  95048. * @returns the numner of indices or zero if the mesh has no geometry.
  95049. */
  95050. getTotalIndices(): number;
  95051. /**
  95052. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95053. * @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.
  95054. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95055. * @returns the indices array or an empty array if the mesh has no geometry
  95056. */
  95057. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95058. get isBlocked(): boolean;
  95059. /**
  95060. * Determine if the current mesh is ready to be rendered
  95061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95062. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95063. * @returns true if all associated assets are ready (material, textures, shaders)
  95064. */
  95065. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95066. /**
  95067. * 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.
  95068. */
  95069. get areNormalsFrozen(): boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  95072. * @returns the current mesh
  95073. */
  95074. freezeNormals(): Mesh;
  95075. /**
  95076. * 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
  95077. * @returns the current mesh
  95078. */
  95079. unfreezeNormals(): Mesh;
  95080. /**
  95081. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95082. */
  95083. set overridenInstanceCount(count: number);
  95084. /** @hidden */
  95085. _preActivate(): Mesh;
  95086. /** @hidden */
  95087. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95088. /** @hidden */
  95089. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95090. /**
  95091. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95092. * This means the mesh underlying bounding box and sphere are recomputed.
  95093. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95094. * @returns the current mesh
  95095. */
  95096. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95097. /** @hidden */
  95098. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95099. /**
  95100. * This function will subdivide the mesh into multiple submeshes
  95101. * @param count defines the expected number of submeshes
  95102. */
  95103. subdivide(count: number): void;
  95104. /**
  95105. * Copy a FloatArray into a specific associated vertex buffer
  95106. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95107. * - VertexBuffer.PositionKind
  95108. * - VertexBuffer.UVKind
  95109. * - VertexBuffer.UV2Kind
  95110. * - VertexBuffer.UV3Kind
  95111. * - VertexBuffer.UV4Kind
  95112. * - VertexBuffer.UV5Kind
  95113. * - VertexBuffer.UV6Kind
  95114. * - VertexBuffer.ColorKind
  95115. * - VertexBuffer.MatricesIndicesKind
  95116. * - VertexBuffer.MatricesIndicesExtraKind
  95117. * - VertexBuffer.MatricesWeightsKind
  95118. * - VertexBuffer.MatricesWeightsExtraKind
  95119. * @param data defines the data source
  95120. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95121. * @param stride defines the data stride size (can be null)
  95122. * @returns the current mesh
  95123. */
  95124. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95125. /**
  95126. * Delete a vertex buffer associated with this mesh
  95127. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95128. * - VertexBuffer.PositionKind
  95129. * - VertexBuffer.UVKind
  95130. * - VertexBuffer.UV2Kind
  95131. * - VertexBuffer.UV3Kind
  95132. * - VertexBuffer.UV4Kind
  95133. * - VertexBuffer.UV5Kind
  95134. * - VertexBuffer.UV6Kind
  95135. * - VertexBuffer.ColorKind
  95136. * - VertexBuffer.MatricesIndicesKind
  95137. * - VertexBuffer.MatricesIndicesExtraKind
  95138. * - VertexBuffer.MatricesWeightsKind
  95139. * - VertexBuffer.MatricesWeightsExtraKind
  95140. */
  95141. removeVerticesData(kind: string): void;
  95142. /**
  95143. * Flags an associated vertex buffer as updatable
  95144. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95145. * - VertexBuffer.PositionKind
  95146. * - VertexBuffer.UVKind
  95147. * - VertexBuffer.UV2Kind
  95148. * - VertexBuffer.UV3Kind
  95149. * - VertexBuffer.UV4Kind
  95150. * - VertexBuffer.UV5Kind
  95151. * - VertexBuffer.UV6Kind
  95152. * - VertexBuffer.ColorKind
  95153. * - VertexBuffer.MatricesIndicesKind
  95154. * - VertexBuffer.MatricesIndicesExtraKind
  95155. * - VertexBuffer.MatricesWeightsKind
  95156. * - VertexBuffer.MatricesWeightsExtraKind
  95157. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95158. */
  95159. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95160. /**
  95161. * Sets the mesh global Vertex Buffer
  95162. * @param buffer defines the buffer to use
  95163. * @returns the current mesh
  95164. */
  95165. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95166. /**
  95167. * Update a specific associated vertex buffer
  95168. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95169. * - VertexBuffer.PositionKind
  95170. * - VertexBuffer.UVKind
  95171. * - VertexBuffer.UV2Kind
  95172. * - VertexBuffer.UV3Kind
  95173. * - VertexBuffer.UV4Kind
  95174. * - VertexBuffer.UV5Kind
  95175. * - VertexBuffer.UV6Kind
  95176. * - VertexBuffer.ColorKind
  95177. * - VertexBuffer.MatricesIndicesKind
  95178. * - VertexBuffer.MatricesIndicesExtraKind
  95179. * - VertexBuffer.MatricesWeightsKind
  95180. * - VertexBuffer.MatricesWeightsExtraKind
  95181. * @param data defines the data source
  95182. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95183. * @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)
  95184. * @returns the current mesh
  95185. */
  95186. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95187. /**
  95188. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95189. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95190. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95191. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95192. * @returns the current mesh
  95193. */
  95194. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95195. /**
  95196. * Creates a un-shared specific occurence of the geometry for the mesh.
  95197. * @returns the current mesh
  95198. */
  95199. makeGeometryUnique(): Mesh;
  95200. /**
  95201. * Set the index buffer of this mesh
  95202. * @param indices defines the source data
  95203. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95204. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95205. * @returns the current mesh
  95206. */
  95207. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95208. /**
  95209. * Update the current index buffer
  95210. * @param indices defines the source data
  95211. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95212. * @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)
  95213. * @returns the current mesh
  95214. */
  95215. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95216. /**
  95217. * Invert the geometry to move from a right handed system to a left handed one.
  95218. * @returns the current mesh
  95219. */
  95220. toLeftHanded(): Mesh;
  95221. /** @hidden */
  95222. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95223. /** @hidden */
  95224. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95225. /**
  95226. * Registers for this mesh a javascript function called just before the rendering process
  95227. * @param func defines the function to call before rendering this mesh
  95228. * @returns the current mesh
  95229. */
  95230. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95231. /**
  95232. * Disposes a previously registered javascript function called before the rendering
  95233. * @param func defines the function to remove
  95234. * @returns the current mesh
  95235. */
  95236. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95237. /**
  95238. * Registers for this mesh a javascript function called just after the rendering is complete
  95239. * @param func defines the function to call after rendering this mesh
  95240. * @returns the current mesh
  95241. */
  95242. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95243. /**
  95244. * Disposes a previously registered javascript function called after the rendering.
  95245. * @param func defines the function to remove
  95246. * @returns the current mesh
  95247. */
  95248. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95249. /** @hidden */
  95250. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95251. /** @hidden */
  95252. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95253. /** @hidden */
  95254. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95255. /** @hidden */
  95256. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95257. /** @hidden */
  95258. _rebuild(): void;
  95259. /** @hidden */
  95260. _freeze(): void;
  95261. /** @hidden */
  95262. _unFreeze(): void;
  95263. /**
  95264. * 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
  95265. * @param subMesh defines the subMesh to render
  95266. * @param enableAlphaMode defines if alpha mode can be changed
  95267. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95268. * @returns the current mesh
  95269. */
  95270. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95271. private _onBeforeDraw;
  95272. /**
  95273. * Renormalize the mesh and patch it up if there are no weights
  95274. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95275. * However in the case of zero weights then we set just a single influence to 1.
  95276. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95277. */
  95278. cleanMatrixWeights(): void;
  95279. private normalizeSkinFourWeights;
  95280. private normalizeSkinWeightsAndExtra;
  95281. /**
  95282. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95283. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95284. * the user know there was an issue with importing the mesh
  95285. * @returns a validation object with skinned, valid and report string
  95286. */
  95287. validateSkinning(): {
  95288. skinned: boolean;
  95289. valid: boolean;
  95290. report: string;
  95291. };
  95292. /** @hidden */
  95293. _checkDelayState(): Mesh;
  95294. private _queueLoad;
  95295. /**
  95296. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95297. * A mesh is in the frustum if its bounding box intersects the frustum
  95298. * @param frustumPlanes defines the frustum to test
  95299. * @returns true if the mesh is in the frustum planes
  95300. */
  95301. isInFrustum(frustumPlanes: Plane[]): boolean;
  95302. /**
  95303. * Sets the mesh material by the material or multiMaterial `id` property
  95304. * @param id is a string identifying the material or the multiMaterial
  95305. * @returns the current mesh
  95306. */
  95307. setMaterialByID(id: string): Mesh;
  95308. /**
  95309. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95310. * @returns an array of IAnimatable
  95311. */
  95312. getAnimatables(): IAnimatable[];
  95313. /**
  95314. * Modifies the mesh geometry according to the passed transformation matrix.
  95315. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95316. * The mesh normals are modified using the same transformation.
  95317. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95318. * @param transform defines the transform matrix to use
  95319. * @see http://doc.babylonjs.com/resources/baking_transformations
  95320. * @returns the current mesh
  95321. */
  95322. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95323. /**
  95324. * Modifies the mesh geometry according to its own current World Matrix.
  95325. * The mesh World Matrix is then reset.
  95326. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95327. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95328. * @see http://doc.babylonjs.com/resources/baking_transformations
  95329. * @returns the current mesh
  95330. */
  95331. bakeCurrentTransformIntoVertices(): Mesh;
  95332. /** @hidden */
  95333. get _positions(): Nullable<Vector3[]>;
  95334. /** @hidden */
  95335. _resetPointsArrayCache(): Mesh;
  95336. /** @hidden */
  95337. _generatePointsArray(): boolean;
  95338. /**
  95339. * Returns a new Mesh object generated from the current mesh properties.
  95340. * This method must not get confused with createInstance()
  95341. * @param name is a string, the name given to the new mesh
  95342. * @param newParent can be any Node object (default `null`)
  95343. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95344. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95345. * @returns a new mesh
  95346. */
  95347. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95348. /**
  95349. * Releases resources associated with this mesh.
  95350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95352. */
  95353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95354. /** @hidden */
  95355. _disposeInstanceSpecificData(): void;
  95356. /**
  95357. * Modifies the mesh geometry according to a displacement map.
  95358. * 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.
  95359. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95360. * @param url is a string, the URL from the image file is to be downloaded.
  95361. * @param minHeight is the lower limit of the displacement.
  95362. * @param maxHeight is the upper limit of the displacement.
  95363. * @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.
  95364. * @param uvOffset is an optional vector2 used to offset UV.
  95365. * @param uvScale is an optional vector2 used to scale UV.
  95366. * @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.
  95367. * @returns the Mesh.
  95368. */
  95369. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95370. /**
  95371. * Modifies the mesh geometry according to a displacementMap buffer.
  95372. * 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.
  95373. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95374. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95375. * @param heightMapWidth is the width of the buffer image.
  95376. * @param heightMapHeight is the height of the buffer image.
  95377. * @param minHeight is the lower limit of the displacement.
  95378. * @param maxHeight is the upper limit of the displacement.
  95379. * @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.
  95380. * @param uvOffset is an optional vector2 used to offset UV.
  95381. * @param uvScale is an optional vector2 used to scale UV.
  95382. * @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.
  95383. * @returns the Mesh.
  95384. */
  95385. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95386. /**
  95387. * Modify the mesh to get a flat shading rendering.
  95388. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95389. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95390. * @returns current mesh
  95391. */
  95392. convertToFlatShadedMesh(): Mesh;
  95393. /**
  95394. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95395. * In other words, more vertices, no more indices and a single bigger VBO.
  95396. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95397. * @returns current mesh
  95398. */
  95399. convertToUnIndexedMesh(): Mesh;
  95400. /**
  95401. * Inverses facet orientations.
  95402. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95403. * @param flipNormals will also inverts the normals
  95404. * @returns current mesh
  95405. */
  95406. flipFaces(flipNormals?: boolean): Mesh;
  95407. /**
  95408. * Increase the number of facets and hence vertices in a mesh
  95409. * Vertex normals are interpolated from existing vertex normals
  95410. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95411. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95412. */
  95413. increaseVertices(numberPerEdge: number): void;
  95414. /**
  95415. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95416. * This will undo any application of covertToFlatShadedMesh
  95417. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95418. */
  95419. forceSharedVertices(): void;
  95420. /** @hidden */
  95421. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95422. /** @hidden */
  95423. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95424. /**
  95425. * Creates a new InstancedMesh object from the mesh model.
  95426. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95427. * @param name defines the name of the new instance
  95428. * @returns a new InstancedMesh
  95429. */
  95430. createInstance(name: string): InstancedMesh;
  95431. /**
  95432. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95433. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95434. * @returns the current mesh
  95435. */
  95436. synchronizeInstances(): Mesh;
  95437. /**
  95438. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95439. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95440. * This should be used together with the simplification to avoid disappearing triangles.
  95441. * @param successCallback an optional success callback to be called after the optimization finished.
  95442. * @returns the current mesh
  95443. */
  95444. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95445. /**
  95446. * Serialize current mesh
  95447. * @param serializationObject defines the object which will receive the serialization data
  95448. */
  95449. serialize(serializationObject: any): void;
  95450. /** @hidden */
  95451. _syncGeometryWithMorphTargetManager(): void;
  95452. /** @hidden */
  95453. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95454. /**
  95455. * Returns a new Mesh object parsed from the source provided.
  95456. * @param parsedMesh is the source
  95457. * @param scene defines the hosting scene
  95458. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95459. * @returns a new Mesh
  95460. */
  95461. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95462. /**
  95463. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95464. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95465. * @param name defines the name of the mesh to create
  95466. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95467. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95468. * @param closePath creates a seam between the first and the last points of each path of the path array
  95469. * @param offset is taken in account only if the `pathArray` is containing a single path
  95470. * @param scene defines the hosting scene
  95471. * @param updatable defines if the mesh must be flagged as updatable
  95472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95473. * @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)
  95474. * @returns a new Mesh
  95475. */
  95476. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95477. /**
  95478. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95479. * @param name defines the name of the mesh to create
  95480. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95481. * @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
  95482. * @param scene defines the hosting scene
  95483. * @param updatable defines if the mesh must be flagged as updatable
  95484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95485. * @returns a new Mesh
  95486. */
  95487. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95488. /**
  95489. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95490. * @param name defines the name of the mesh to create
  95491. * @param size sets the size (float) of each box side (default 1)
  95492. * @param scene defines the hosting scene
  95493. * @param updatable defines if the mesh must be flagged as updatable
  95494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95495. * @returns a new Mesh
  95496. */
  95497. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95498. /**
  95499. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95500. * @param name defines the name of the mesh to create
  95501. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95502. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95503. * @param scene defines the hosting scene
  95504. * @param updatable defines if the mesh must be flagged as updatable
  95505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95506. * @returns a new Mesh
  95507. */
  95508. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95509. /**
  95510. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95511. * @param name defines the name of the mesh to create
  95512. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95513. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95514. * @param scene defines the hosting scene
  95515. * @returns a new Mesh
  95516. */
  95517. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95518. /**
  95519. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95520. * @param name defines the name of the mesh to create
  95521. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95522. * @param diameterTop set the top cap diameter (floats, default 1)
  95523. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95524. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95525. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95526. * @param scene defines the hosting scene
  95527. * @param updatable defines if the mesh must be flagged as updatable
  95528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95529. * @returns a new Mesh
  95530. */
  95531. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95532. /**
  95533. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95534. * @param name defines the name of the mesh to create
  95535. * @param diameter sets the diameter size (float) of the torus (default 1)
  95536. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95537. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95538. * @param scene defines the hosting scene
  95539. * @param updatable defines if the mesh must be flagged as updatable
  95540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95541. * @returns a new Mesh
  95542. */
  95543. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95544. /**
  95545. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95546. * @param name defines the name of the mesh to create
  95547. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95548. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95549. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95550. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95551. * @param p the number of windings on X axis (positive integers, default 2)
  95552. * @param q the number of windings on Y axis (positive integers, default 3)
  95553. * @param scene defines the hosting scene
  95554. * @param updatable defines if the mesh must be flagged as updatable
  95555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95556. * @returns a new Mesh
  95557. */
  95558. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95559. /**
  95560. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95561. * @param name defines the name of the mesh to create
  95562. * @param points is an array successive Vector3
  95563. * @param scene defines the hosting scene
  95564. * @param updatable defines if the mesh must be flagged as updatable
  95565. * @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).
  95566. * @returns a new Mesh
  95567. */
  95568. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95569. /**
  95570. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95571. * @param name defines the name of the mesh to create
  95572. * @param points is an array successive Vector3
  95573. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95574. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95575. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95576. * @param scene defines the hosting scene
  95577. * @param updatable defines if the mesh must be flagged as updatable
  95578. * @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)
  95579. * @returns a new Mesh
  95580. */
  95581. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95582. /**
  95583. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95584. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95585. * 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.
  95586. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95587. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95588. * Remember you can only change the shape positions, not their number when updating a polygon.
  95589. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95590. * @param name defines the name of the mesh to create
  95591. * @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
  95592. * @param scene defines the hosting scene
  95593. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95594. * @param updatable defines if the mesh must be flagged as updatable
  95595. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95596. * @param earcutInjection can be used to inject your own earcut reference
  95597. * @returns a new Mesh
  95598. */
  95599. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95600. /**
  95601. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95602. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95603. * @param name defines the name of the mesh to create
  95604. * @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
  95605. * @param depth defines the height of extrusion
  95606. * @param scene defines the hosting scene
  95607. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95608. * @param updatable defines if the mesh must be flagged as updatable
  95609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95610. * @param earcutInjection can be used to inject your own earcut reference
  95611. * @returns a new Mesh
  95612. */
  95613. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95614. /**
  95615. * Creates an extruded shape mesh.
  95616. * 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
  95617. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95618. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95619. * @param name defines the name of the mesh to create
  95620. * @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
  95621. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95622. * @param scale is the value to scale the shape
  95623. * @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
  95624. * @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
  95625. * @param scene defines the hosting scene
  95626. * @param updatable defines if the mesh must be flagged as updatable
  95627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95628. * @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)
  95629. * @returns a new Mesh
  95630. */
  95631. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95632. /**
  95633. * Creates an custom extruded shape mesh.
  95634. * The custom extrusion is a parametric shape.
  95635. * It has no predefined shape. Its final shape will depend on the input parameters.
  95636. * Please consider using the same method from the MeshBuilder class instead
  95637. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95638. * @param name defines the name of the mesh to create
  95639. * @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
  95640. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95641. * @param scaleFunction is a custom Javascript function called on each path point
  95642. * @param rotationFunction is a custom Javascript function called on each path point
  95643. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95644. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95645. * @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
  95646. * @param scene defines the hosting scene
  95647. * @param updatable defines if the mesh must be flagged as updatable
  95648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95649. * @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)
  95650. * @returns a new Mesh
  95651. */
  95652. 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;
  95653. /**
  95654. * Creates lathe mesh.
  95655. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95656. * Please consider using the same method from the MeshBuilder class instead
  95657. * @param name defines the name of the mesh to create
  95658. * @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
  95659. * @param radius is the radius value of the lathe
  95660. * @param tessellation is the side number of the lathe.
  95661. * @param scene defines the hosting scene
  95662. * @param updatable defines if the mesh must be flagged as updatable
  95663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95664. * @returns a new Mesh
  95665. */
  95666. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95667. /**
  95668. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95669. * @param name defines the name of the mesh to create
  95670. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95671. * @param scene defines the hosting scene
  95672. * @param updatable defines if the mesh must be flagged as updatable
  95673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95674. * @returns a new Mesh
  95675. */
  95676. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95677. /**
  95678. * Creates a ground mesh.
  95679. * Please consider using the same method from the MeshBuilder class instead
  95680. * @param name defines the name of the mesh to create
  95681. * @param width set the width of the ground
  95682. * @param height set the height of the ground
  95683. * @param subdivisions sets the number of subdivisions per side
  95684. * @param scene defines the hosting scene
  95685. * @param updatable defines if the mesh must be flagged as updatable
  95686. * @returns a new Mesh
  95687. */
  95688. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95689. /**
  95690. * Creates a tiled ground mesh.
  95691. * Please consider using the same method from the MeshBuilder class instead
  95692. * @param name defines the name of the mesh to create
  95693. * @param xmin set the ground minimum X coordinate
  95694. * @param zmin set the ground minimum Y coordinate
  95695. * @param xmax set the ground maximum X coordinate
  95696. * @param zmax set the ground maximum Z coordinate
  95697. * @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
  95698. * @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
  95699. * @param scene defines the hosting scene
  95700. * @param updatable defines if the mesh must be flagged as updatable
  95701. * @returns a new Mesh
  95702. */
  95703. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95704. w: number;
  95705. h: number;
  95706. }, precision: {
  95707. w: number;
  95708. h: number;
  95709. }, scene: Scene, updatable?: boolean): Mesh;
  95710. /**
  95711. * Creates a ground mesh from a height map.
  95712. * Please consider using the same method from the MeshBuilder class instead
  95713. * @see http://doc.babylonjs.com/babylon101/height_map
  95714. * @param name defines the name of the mesh to create
  95715. * @param url sets the URL of the height map image resource
  95716. * @param width set the ground width size
  95717. * @param height set the ground height size
  95718. * @param subdivisions sets the number of subdivision per side
  95719. * @param minHeight is the minimum altitude on the ground
  95720. * @param maxHeight is the maximum altitude on the ground
  95721. * @param scene defines the hosting scene
  95722. * @param updatable defines if the mesh must be flagged as updatable
  95723. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95724. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95725. * @returns a new Mesh
  95726. */
  95727. 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;
  95728. /**
  95729. * Creates a tube mesh.
  95730. * The tube is a parametric shape.
  95731. * It has no predefined shape. Its final shape will depend on the input parameters.
  95732. * Please consider using the same method from the MeshBuilder class instead
  95733. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95734. * @param name defines the name of the mesh to create
  95735. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95736. * @param radius sets the tube radius size
  95737. * @param tessellation is the number of sides on the tubular surface
  95738. * @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
  95739. * @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
  95740. * @param scene defines the hosting scene
  95741. * @param updatable defines if the mesh must be flagged as updatable
  95742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95743. * @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)
  95744. * @returns a new Mesh
  95745. */
  95746. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95747. (i: number, distance: number): number;
  95748. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95749. /**
  95750. * Creates a polyhedron mesh.
  95751. * Please consider using the same method from the MeshBuilder class instead.
  95752. * * 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
  95753. * * The parameter `size` (positive float, default 1) sets the polygon size
  95754. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95755. * * 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`
  95756. * * 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
  95757. * * 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)`)
  95758. * * 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
  95759. * * 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
  95760. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95761. * * If you create a double-sided mesh, you can choose what parts of 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
  95762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95763. * @param name defines the name of the mesh to create
  95764. * @param options defines the options used to create the mesh
  95765. * @param scene defines the hosting scene
  95766. * @returns a new Mesh
  95767. */
  95768. static CreatePolyhedron(name: string, options: {
  95769. type?: number;
  95770. size?: number;
  95771. sizeX?: number;
  95772. sizeY?: number;
  95773. sizeZ?: number;
  95774. custom?: any;
  95775. faceUV?: Vector4[];
  95776. faceColors?: Color4[];
  95777. updatable?: boolean;
  95778. sideOrientation?: number;
  95779. }, scene: Scene): Mesh;
  95780. /**
  95781. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95782. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95783. * * 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`)
  95784. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95785. * * 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
  95786. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95787. * * If you create a double-sided mesh, you can choose what parts of 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
  95788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95789. * @param name defines the name of the mesh
  95790. * @param options defines the options used to create the mesh
  95791. * @param scene defines the hosting scene
  95792. * @returns a new Mesh
  95793. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95794. */
  95795. static CreateIcoSphere(name: string, options: {
  95796. radius?: number;
  95797. flat?: boolean;
  95798. subdivisions?: number;
  95799. sideOrientation?: number;
  95800. updatable?: boolean;
  95801. }, scene: Scene): Mesh;
  95802. /**
  95803. * Creates a decal mesh.
  95804. * Please consider using the same method from the MeshBuilder class instead.
  95805. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95806. * @param name defines the name of the mesh
  95807. * @param sourceMesh defines the mesh receiving the decal
  95808. * @param position sets the position of the decal in world coordinates
  95809. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95810. * @param size sets the decal scaling
  95811. * @param angle sets the angle to rotate the decal
  95812. * @returns a new Mesh
  95813. */
  95814. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95815. /**
  95816. * Prepare internal position array for software CPU skinning
  95817. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95818. */
  95819. setPositionsForCPUSkinning(): Float32Array;
  95820. /**
  95821. * Prepare internal normal array for software CPU skinning
  95822. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95823. */
  95824. setNormalsForCPUSkinning(): Float32Array;
  95825. /**
  95826. * Updates the vertex buffer by applying transformation from the bones
  95827. * @param skeleton defines the skeleton to apply to current mesh
  95828. * @returns the current mesh
  95829. */
  95830. applySkeleton(skeleton: Skeleton): Mesh;
  95831. /**
  95832. * 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
  95833. * @param meshes defines the list of meshes to scan
  95834. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95835. */
  95836. static MinMax(meshes: AbstractMesh[]): {
  95837. min: Vector3;
  95838. max: Vector3;
  95839. };
  95840. /**
  95841. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95842. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95843. * @returns a vector3
  95844. */
  95845. static Center(meshesOrMinMaxVector: {
  95846. min: Vector3;
  95847. max: Vector3;
  95848. } | AbstractMesh[]): Vector3;
  95849. /**
  95850. * Merge the array of meshes into a single mesh for performance reasons.
  95851. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95852. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95853. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95854. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95855. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95856. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95857. * @returns a new mesh
  95858. */
  95859. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95860. /** @hidden */
  95861. addInstance(instance: InstancedMesh): void;
  95862. /** @hidden */
  95863. removeInstance(instance: InstancedMesh): void;
  95864. }
  95865. }
  95866. declare module BABYLON {
  95867. /**
  95868. * This is the base class of all the camera used in the application.
  95869. * @see http://doc.babylonjs.com/features/cameras
  95870. */
  95871. export class Camera extends Node {
  95872. /** @hidden */
  95873. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95874. /**
  95875. * This is the default projection mode used by the cameras.
  95876. * It helps recreating a feeling of perspective and better appreciate depth.
  95877. * This is the best way to simulate real life cameras.
  95878. */
  95879. static readonly PERSPECTIVE_CAMERA: number;
  95880. /**
  95881. * This helps creating camera with an orthographic mode.
  95882. * 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.
  95883. */
  95884. static readonly ORTHOGRAPHIC_CAMERA: number;
  95885. /**
  95886. * This is the default FOV mode for perspective cameras.
  95887. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95888. */
  95889. static readonly FOVMODE_VERTICAL_FIXED: number;
  95890. /**
  95891. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95892. */
  95893. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95894. /**
  95895. * This specifies ther is no need for a camera rig.
  95896. * Basically only one eye is rendered corresponding to the camera.
  95897. */
  95898. static readonly RIG_MODE_NONE: number;
  95899. /**
  95900. * Simulates a camera Rig with one blue eye and one red eye.
  95901. * This can be use with 3d blue and red glasses.
  95902. */
  95903. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95904. /**
  95905. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95906. */
  95907. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95908. /**
  95909. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95910. */
  95911. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95912. /**
  95913. * Defines that both eyes of the camera will be rendered over under each other.
  95914. */
  95915. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95916. /**
  95917. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95918. */
  95919. static readonly RIG_MODE_VR: number;
  95920. /**
  95921. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95922. */
  95923. static readonly RIG_MODE_WEBVR: number;
  95924. /**
  95925. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95926. */
  95927. static readonly RIG_MODE_CUSTOM: number;
  95928. /**
  95929. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95930. */
  95931. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95932. /**
  95933. * Define the input manager associated with the camera.
  95934. */
  95935. inputs: CameraInputsManager<Camera>;
  95936. /** @hidden */
  95937. _position: Vector3;
  95938. /**
  95939. * Define the current local position of the camera in the scene
  95940. */
  95941. get position(): Vector3;
  95942. set position(newPosition: Vector3);
  95943. /**
  95944. * The vector the camera should consider as up.
  95945. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95946. */
  95947. upVector: Vector3;
  95948. /**
  95949. * Define the current limit on the left side for an orthographic camera
  95950. * In scene unit
  95951. */
  95952. orthoLeft: Nullable<number>;
  95953. /**
  95954. * Define the current limit on the right side for an orthographic camera
  95955. * In scene unit
  95956. */
  95957. orthoRight: Nullable<number>;
  95958. /**
  95959. * Define the current limit on the bottom side for an orthographic camera
  95960. * In scene unit
  95961. */
  95962. orthoBottom: Nullable<number>;
  95963. /**
  95964. * Define the current limit on the top side for an orthographic camera
  95965. * In scene unit
  95966. */
  95967. orthoTop: Nullable<number>;
  95968. /**
  95969. * Field Of View is set in Radians. (default is 0.8)
  95970. */
  95971. fov: number;
  95972. /**
  95973. * Define the minimum distance the camera can see from.
  95974. * This is important to note that the depth buffer are not infinite and the closer it starts
  95975. * the more your scene might encounter depth fighting issue.
  95976. */
  95977. minZ: number;
  95978. /**
  95979. * Define the maximum distance the camera can see to.
  95980. * This is important to note that the depth buffer are not infinite and the further it end
  95981. * the more your scene might encounter depth fighting issue.
  95982. */
  95983. maxZ: number;
  95984. /**
  95985. * Define the default inertia of the camera.
  95986. * This helps giving a smooth feeling to the camera movement.
  95987. */
  95988. inertia: number;
  95989. /**
  95990. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95991. */
  95992. mode: number;
  95993. /**
  95994. * Define wether the camera is intermediate.
  95995. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95996. */
  95997. isIntermediate: boolean;
  95998. /**
  95999. * Define the viewport of the camera.
  96000. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  96001. */
  96002. viewport: Viewport;
  96003. /**
  96004. * Restricts the camera to viewing objects with the same layerMask.
  96005. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  96006. */
  96007. layerMask: number;
  96008. /**
  96009. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  96010. */
  96011. fovMode: number;
  96012. /**
  96013. * Rig mode of the camera.
  96014. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  96015. * This is normally controlled byt the camera themselves as internal use.
  96016. */
  96017. cameraRigMode: number;
  96018. /**
  96019. * Defines the distance between both "eyes" in case of a RIG
  96020. */
  96021. interaxialDistance: number;
  96022. /**
  96023. * Defines if stereoscopic rendering is done side by side or over under.
  96024. */
  96025. isStereoscopicSideBySide: boolean;
  96026. /**
  96027. * 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
  96028. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  96029. * else in the scene. (Eg. security camera)
  96030. *
  96031. * 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)
  96032. */
  96033. customRenderTargets: RenderTargetTexture[];
  96034. /**
  96035. * When set, the camera will render to this render target instead of the default canvas
  96036. *
  96037. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  96038. */
  96039. outputRenderTarget: Nullable<RenderTargetTexture>;
  96040. /**
  96041. * Observable triggered when the camera view matrix has changed.
  96042. */
  96043. onViewMatrixChangedObservable: Observable<Camera>;
  96044. /**
  96045. * Observable triggered when the camera Projection matrix has changed.
  96046. */
  96047. onProjectionMatrixChangedObservable: Observable<Camera>;
  96048. /**
  96049. * Observable triggered when the inputs have been processed.
  96050. */
  96051. onAfterCheckInputsObservable: Observable<Camera>;
  96052. /**
  96053. * Observable triggered when reset has been called and applied to the camera.
  96054. */
  96055. onRestoreStateObservable: Observable<Camera>;
  96056. /** @hidden */
  96057. _cameraRigParams: any;
  96058. /** @hidden */
  96059. _rigCameras: Camera[];
  96060. /** @hidden */
  96061. _rigPostProcess: Nullable<PostProcess>;
  96062. protected _webvrViewMatrix: Matrix;
  96063. /** @hidden */
  96064. _skipRendering: boolean;
  96065. /** @hidden */
  96066. _projectionMatrix: Matrix;
  96067. /** @hidden */
  96068. _postProcesses: Nullable<PostProcess>[];
  96069. /** @hidden */
  96070. _activeMeshes: SmartArray<AbstractMesh>;
  96071. protected _globalPosition: Vector3;
  96072. /** @hidden */
  96073. _computedViewMatrix: Matrix;
  96074. private _doNotComputeProjectionMatrix;
  96075. private _transformMatrix;
  96076. private _frustumPlanes;
  96077. private _refreshFrustumPlanes;
  96078. private _storedFov;
  96079. private _stateStored;
  96080. /**
  96081. * Instantiates a new camera object.
  96082. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96083. * @see http://doc.babylonjs.com/features/cameras
  96084. * @param name Defines the name of the camera in the scene
  96085. * @param position Defines the position of the camera
  96086. * @param scene Defines the scene the camera belongs too
  96087. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96088. */
  96089. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96090. /**
  96091. * Store current camera state (fov, position, etc..)
  96092. * @returns the camera
  96093. */
  96094. storeState(): Camera;
  96095. /**
  96096. * Restores the camera state values if it has been stored. You must call storeState() first
  96097. */
  96098. protected _restoreStateValues(): boolean;
  96099. /**
  96100. * Restored camera state. You must call storeState() first.
  96101. * @returns true if restored and false otherwise
  96102. */
  96103. restoreState(): boolean;
  96104. /**
  96105. * Gets the class name of the camera.
  96106. * @returns the class name
  96107. */
  96108. getClassName(): string;
  96109. /** @hidden */
  96110. readonly _isCamera: boolean;
  96111. /**
  96112. * Gets a string representation of the camera useful for debug purpose.
  96113. * @param fullDetails Defines that a more verboe level of logging is required
  96114. * @returns the string representation
  96115. */
  96116. toString(fullDetails?: boolean): string;
  96117. /**
  96118. * Gets the current world space position of the camera.
  96119. */
  96120. get globalPosition(): Vector3;
  96121. /**
  96122. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96123. * @returns the active meshe list
  96124. */
  96125. getActiveMeshes(): SmartArray<AbstractMesh>;
  96126. /**
  96127. * Check wether a mesh is part of the current active mesh list of the camera
  96128. * @param mesh Defines the mesh to check
  96129. * @returns true if active, false otherwise
  96130. */
  96131. isActiveMesh(mesh: Mesh): boolean;
  96132. /**
  96133. * Is this camera ready to be used/rendered
  96134. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96135. * @return true if the camera is ready
  96136. */
  96137. isReady(completeCheck?: boolean): boolean;
  96138. /** @hidden */
  96139. _initCache(): void;
  96140. /** @hidden */
  96141. _updateCache(ignoreParentClass?: boolean): void;
  96142. /** @hidden */
  96143. _isSynchronized(): boolean;
  96144. /** @hidden */
  96145. _isSynchronizedViewMatrix(): boolean;
  96146. /** @hidden */
  96147. _isSynchronizedProjectionMatrix(): boolean;
  96148. /**
  96149. * Attach the input controls to a specific dom element to get the input from.
  96150. * @param element Defines the element the controls should be listened from
  96151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96152. */
  96153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96154. /**
  96155. * Detach the current controls from the specified dom element.
  96156. * @param element Defines the element to stop listening the inputs from
  96157. */
  96158. detachControl(element: HTMLElement): void;
  96159. /**
  96160. * Update the camera state according to the different inputs gathered during the frame.
  96161. */
  96162. update(): void;
  96163. /** @hidden */
  96164. _checkInputs(): void;
  96165. /** @hidden */
  96166. get rigCameras(): Camera[];
  96167. /**
  96168. * Gets the post process used by the rig cameras
  96169. */
  96170. get rigPostProcess(): Nullable<PostProcess>;
  96171. /**
  96172. * Internal, gets the first post proces.
  96173. * @returns the first post process to be run on this camera.
  96174. */
  96175. _getFirstPostProcess(): Nullable<PostProcess>;
  96176. private _cascadePostProcessesToRigCams;
  96177. /**
  96178. * Attach a post process to the camera.
  96179. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96180. * @param postProcess The post process to attach to the camera
  96181. * @param insertAt The position of the post process in case several of them are in use in the scene
  96182. * @returns the position the post process has been inserted at
  96183. */
  96184. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96185. /**
  96186. * Detach a post process to the camera.
  96187. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96188. * @param postProcess The post process to detach from the camera
  96189. */
  96190. detachPostProcess(postProcess: PostProcess): void;
  96191. /**
  96192. * Gets the current world matrix of the camera
  96193. */
  96194. getWorldMatrix(): Matrix;
  96195. /** @hidden */
  96196. _getViewMatrix(): Matrix;
  96197. /**
  96198. * Gets the current view matrix of the camera.
  96199. * @param force forces the camera to recompute the matrix without looking at the cached state
  96200. * @returns the view matrix
  96201. */
  96202. getViewMatrix(force?: boolean): Matrix;
  96203. /**
  96204. * Freeze the projection matrix.
  96205. * It will prevent the cache check of the camera projection compute and can speed up perf
  96206. * if no parameter of the camera are meant to change
  96207. * @param projection Defines manually a projection if necessary
  96208. */
  96209. freezeProjectionMatrix(projection?: Matrix): void;
  96210. /**
  96211. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96212. */
  96213. unfreezeProjectionMatrix(): void;
  96214. /**
  96215. * Gets the current projection matrix of the camera.
  96216. * @param force forces the camera to recompute the matrix without looking at the cached state
  96217. * @returns the projection matrix
  96218. */
  96219. getProjectionMatrix(force?: boolean): Matrix;
  96220. /**
  96221. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96222. * @returns a Matrix
  96223. */
  96224. getTransformationMatrix(): Matrix;
  96225. private _updateFrustumPlanes;
  96226. /**
  96227. * Checks if a cullable object (mesh...) is in the camera frustum
  96228. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96229. * @param target The object to check
  96230. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96231. * @returns true if the object is in frustum otherwise false
  96232. */
  96233. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96234. /**
  96235. * Checks if a cullable object (mesh...) is in the camera frustum
  96236. * Unlike isInFrustum this cheks the full bounding box
  96237. * @param target The object to check
  96238. * @returns true if the object is in frustum otherwise false
  96239. */
  96240. isCompletelyInFrustum(target: ICullable): boolean;
  96241. /**
  96242. * Gets a ray in the forward direction from the camera.
  96243. * @param length Defines the length of the ray to create
  96244. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96245. * @param origin Defines the start point of the ray which defaults to the camera position
  96246. * @returns the forward ray
  96247. */
  96248. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96249. /**
  96250. * Releases resources associated with this node.
  96251. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96252. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96253. */
  96254. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96255. /** @hidden */
  96256. _isLeftCamera: boolean;
  96257. /**
  96258. * Gets the left camera of a rig setup in case of Rigged Camera
  96259. */
  96260. get isLeftCamera(): boolean;
  96261. /** @hidden */
  96262. _isRightCamera: boolean;
  96263. /**
  96264. * Gets the right camera of a rig setup in case of Rigged Camera
  96265. */
  96266. get isRightCamera(): boolean;
  96267. /**
  96268. * Gets the left camera of a rig setup in case of Rigged Camera
  96269. */
  96270. get leftCamera(): Nullable<FreeCamera>;
  96271. /**
  96272. * Gets the right camera of a rig setup in case of Rigged Camera
  96273. */
  96274. get rightCamera(): Nullable<FreeCamera>;
  96275. /**
  96276. * Gets the left camera target of a rig setup in case of Rigged Camera
  96277. * @returns the target position
  96278. */
  96279. getLeftTarget(): Nullable<Vector3>;
  96280. /**
  96281. * Gets the right camera target of a rig setup in case of Rigged Camera
  96282. * @returns the target position
  96283. */
  96284. getRightTarget(): Nullable<Vector3>;
  96285. /**
  96286. * @hidden
  96287. */
  96288. setCameraRigMode(mode: number, rigParams: any): void;
  96289. /** @hidden */
  96290. static _setStereoscopicRigMode(camera: Camera): void;
  96291. /** @hidden */
  96292. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96293. /** @hidden */
  96294. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96295. /** @hidden */
  96296. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96297. /** @hidden */
  96298. _getVRProjectionMatrix(): Matrix;
  96299. protected _updateCameraRotationMatrix(): void;
  96300. protected _updateWebVRCameraRotationMatrix(): void;
  96301. /**
  96302. * This function MUST be overwritten by the different WebVR cameras available.
  96303. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96304. * @hidden
  96305. */
  96306. _getWebVRProjectionMatrix(): Matrix;
  96307. /**
  96308. * This function MUST be overwritten by the different WebVR cameras available.
  96309. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96310. * @hidden
  96311. */
  96312. _getWebVRViewMatrix(): Matrix;
  96313. /** @hidden */
  96314. setCameraRigParameter(name: string, value: any): void;
  96315. /**
  96316. * needs to be overridden by children so sub has required properties to be copied
  96317. * @hidden
  96318. */
  96319. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96320. /**
  96321. * May need to be overridden by children
  96322. * @hidden
  96323. */
  96324. _updateRigCameras(): void;
  96325. /** @hidden */
  96326. _setupInputs(): void;
  96327. /**
  96328. * Serialiaze the camera setup to a json represention
  96329. * @returns the JSON representation
  96330. */
  96331. serialize(): any;
  96332. /**
  96333. * Clones the current camera.
  96334. * @param name The cloned camera name
  96335. * @returns the cloned camera
  96336. */
  96337. clone(name: string): Camera;
  96338. /**
  96339. * Gets the direction of the camera relative to a given local axis.
  96340. * @param localAxis Defines the reference axis to provide a relative direction.
  96341. * @return the direction
  96342. */
  96343. getDirection(localAxis: Vector3): Vector3;
  96344. /**
  96345. * Returns the current camera absolute rotation
  96346. */
  96347. get absoluteRotation(): Quaternion;
  96348. /**
  96349. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96350. * @param localAxis Defines the reference axis to provide a relative direction.
  96351. * @param result Defines the vector to store the result in
  96352. */
  96353. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96354. /**
  96355. * Gets a camera constructor for a given camera type
  96356. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96357. * @param name The name of the camera the result will be able to instantiate
  96358. * @param scene The scene the result will construct the camera in
  96359. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96360. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96361. * @returns a factory method to construc the camera
  96362. */
  96363. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96364. /**
  96365. * Compute the world matrix of the camera.
  96366. * @returns the camera world matrix
  96367. */
  96368. computeWorldMatrix(): Matrix;
  96369. /**
  96370. * Parse a JSON and creates the camera from the parsed information
  96371. * @param parsedCamera The JSON to parse
  96372. * @param scene The scene to instantiate the camera in
  96373. * @returns the newly constructed camera
  96374. */
  96375. static Parse(parsedCamera: any, scene: Scene): Camera;
  96376. }
  96377. }
  96378. declare module BABYLON {
  96379. /**
  96380. * Class containing static functions to help procedurally build meshes
  96381. */
  96382. export class DiscBuilder {
  96383. /**
  96384. * Creates a plane polygonal mesh. By default, this is a disc
  96385. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96386. * * 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
  96387. * * 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
  96388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96391. * @param name defines the name of the mesh
  96392. * @param options defines the options used to create the mesh
  96393. * @param scene defines the hosting scene
  96394. * @returns the plane polygonal mesh
  96395. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96396. */
  96397. static CreateDisc(name: string, options: {
  96398. radius?: number;
  96399. tessellation?: number;
  96400. arc?: number;
  96401. updatable?: boolean;
  96402. sideOrientation?: number;
  96403. frontUVs?: Vector4;
  96404. backUVs?: Vector4;
  96405. }, scene?: Nullable<Scene>): Mesh;
  96406. }
  96407. }
  96408. declare module BABYLON {
  96409. /**
  96410. * This represents all the required information to add a fresnel effect on a material:
  96411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96412. */
  96413. export class FresnelParameters {
  96414. private _isEnabled;
  96415. /**
  96416. * Define if the fresnel effect is enable or not.
  96417. */
  96418. get isEnabled(): boolean;
  96419. set isEnabled(value: boolean);
  96420. /**
  96421. * Define the color used on edges (grazing angle)
  96422. */
  96423. leftColor: Color3;
  96424. /**
  96425. * Define the color used on center
  96426. */
  96427. rightColor: Color3;
  96428. /**
  96429. * Define bias applied to computed fresnel term
  96430. */
  96431. bias: number;
  96432. /**
  96433. * Defined the power exponent applied to fresnel term
  96434. */
  96435. power: number;
  96436. /**
  96437. * Clones the current fresnel and its valuues
  96438. * @returns a clone fresnel configuration
  96439. */
  96440. clone(): FresnelParameters;
  96441. /**
  96442. * Serializes the current fresnel parameters to a JSON representation.
  96443. * @return the JSON serialization
  96444. */
  96445. serialize(): any;
  96446. /**
  96447. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96448. * @param parsedFresnelParameters Define the JSON representation
  96449. * @returns the parsed parameters
  96450. */
  96451. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96452. }
  96453. }
  96454. declare module BABYLON {
  96455. /**
  96456. * Base class of materials working in push mode in babylon JS
  96457. * @hidden
  96458. */
  96459. export class PushMaterial extends Material {
  96460. protected _activeEffect: Effect;
  96461. protected _normalMatrix: Matrix;
  96462. /**
  96463. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96464. * This means that the material can keep using a previous shader while a new one is being compiled.
  96465. * This is mostly used when shader parallel compilation is supported (true by default)
  96466. */
  96467. allowShaderHotSwapping: boolean;
  96468. constructor(name: string, scene: Scene);
  96469. getEffect(): Effect;
  96470. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96471. /**
  96472. * Binds the given world matrix to the active effect
  96473. *
  96474. * @param world the matrix to bind
  96475. */
  96476. bindOnlyWorldMatrix(world: Matrix): void;
  96477. /**
  96478. * Binds the given normal matrix to the active effect
  96479. *
  96480. * @param normalMatrix the matrix to bind
  96481. */
  96482. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96483. bind(world: Matrix, mesh?: Mesh): void;
  96484. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96485. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96486. }
  96487. }
  96488. declare module BABYLON {
  96489. /**
  96490. * This groups all the flags used to control the materials channel.
  96491. */
  96492. export class MaterialFlags {
  96493. private static _DiffuseTextureEnabled;
  96494. /**
  96495. * Are diffuse textures enabled in the application.
  96496. */
  96497. static get DiffuseTextureEnabled(): boolean;
  96498. static set DiffuseTextureEnabled(value: boolean);
  96499. private static _AmbientTextureEnabled;
  96500. /**
  96501. * Are ambient textures enabled in the application.
  96502. */
  96503. static get AmbientTextureEnabled(): boolean;
  96504. static set AmbientTextureEnabled(value: boolean);
  96505. private static _OpacityTextureEnabled;
  96506. /**
  96507. * Are opacity textures enabled in the application.
  96508. */
  96509. static get OpacityTextureEnabled(): boolean;
  96510. static set OpacityTextureEnabled(value: boolean);
  96511. private static _ReflectionTextureEnabled;
  96512. /**
  96513. * Are reflection textures enabled in the application.
  96514. */
  96515. static get ReflectionTextureEnabled(): boolean;
  96516. static set ReflectionTextureEnabled(value: boolean);
  96517. private static _EmissiveTextureEnabled;
  96518. /**
  96519. * Are emissive textures enabled in the application.
  96520. */
  96521. static get EmissiveTextureEnabled(): boolean;
  96522. static set EmissiveTextureEnabled(value: boolean);
  96523. private static _SpecularTextureEnabled;
  96524. /**
  96525. * Are specular textures enabled in the application.
  96526. */
  96527. static get SpecularTextureEnabled(): boolean;
  96528. static set SpecularTextureEnabled(value: boolean);
  96529. private static _BumpTextureEnabled;
  96530. /**
  96531. * Are bump textures enabled in the application.
  96532. */
  96533. static get BumpTextureEnabled(): boolean;
  96534. static set BumpTextureEnabled(value: boolean);
  96535. private static _LightmapTextureEnabled;
  96536. /**
  96537. * Are lightmap textures enabled in the application.
  96538. */
  96539. static get LightmapTextureEnabled(): boolean;
  96540. static set LightmapTextureEnabled(value: boolean);
  96541. private static _RefractionTextureEnabled;
  96542. /**
  96543. * Are refraction textures enabled in the application.
  96544. */
  96545. static get RefractionTextureEnabled(): boolean;
  96546. static set RefractionTextureEnabled(value: boolean);
  96547. private static _ColorGradingTextureEnabled;
  96548. /**
  96549. * Are color grading textures enabled in the application.
  96550. */
  96551. static get ColorGradingTextureEnabled(): boolean;
  96552. static set ColorGradingTextureEnabled(value: boolean);
  96553. private static _FresnelEnabled;
  96554. /**
  96555. * Are fresnels enabled in the application.
  96556. */
  96557. static get FresnelEnabled(): boolean;
  96558. static set FresnelEnabled(value: boolean);
  96559. private static _ClearCoatTextureEnabled;
  96560. /**
  96561. * Are clear coat textures enabled in the application.
  96562. */
  96563. static get ClearCoatTextureEnabled(): boolean;
  96564. static set ClearCoatTextureEnabled(value: boolean);
  96565. private static _ClearCoatBumpTextureEnabled;
  96566. /**
  96567. * Are clear coat bump textures enabled in the application.
  96568. */
  96569. static get ClearCoatBumpTextureEnabled(): boolean;
  96570. static set ClearCoatBumpTextureEnabled(value: boolean);
  96571. private static _ClearCoatTintTextureEnabled;
  96572. /**
  96573. * Are clear coat tint textures enabled in the application.
  96574. */
  96575. static get ClearCoatTintTextureEnabled(): boolean;
  96576. static set ClearCoatTintTextureEnabled(value: boolean);
  96577. private static _SheenTextureEnabled;
  96578. /**
  96579. * Are sheen textures enabled in the application.
  96580. */
  96581. static get SheenTextureEnabled(): boolean;
  96582. static set SheenTextureEnabled(value: boolean);
  96583. private static _AnisotropicTextureEnabled;
  96584. /**
  96585. * Are anisotropic textures enabled in the application.
  96586. */
  96587. static get AnisotropicTextureEnabled(): boolean;
  96588. static set AnisotropicTextureEnabled(value: boolean);
  96589. private static _ThicknessTextureEnabled;
  96590. /**
  96591. * Are thickness textures enabled in the application.
  96592. */
  96593. static get ThicknessTextureEnabled(): boolean;
  96594. static set ThicknessTextureEnabled(value: boolean);
  96595. }
  96596. }
  96597. declare module BABYLON {
  96598. /** @hidden */
  96599. export var defaultFragmentDeclaration: {
  96600. name: string;
  96601. shader: string;
  96602. };
  96603. }
  96604. declare module BABYLON {
  96605. /** @hidden */
  96606. export var defaultUboDeclaration: {
  96607. name: string;
  96608. shader: string;
  96609. };
  96610. }
  96611. declare module BABYLON {
  96612. /** @hidden */
  96613. export var lightFragmentDeclaration: {
  96614. name: string;
  96615. shader: string;
  96616. };
  96617. }
  96618. declare module BABYLON {
  96619. /** @hidden */
  96620. export var lightUboDeclaration: {
  96621. name: string;
  96622. shader: string;
  96623. };
  96624. }
  96625. declare module BABYLON {
  96626. /** @hidden */
  96627. export var lightsFragmentFunctions: {
  96628. name: string;
  96629. shader: string;
  96630. };
  96631. }
  96632. declare module BABYLON {
  96633. /** @hidden */
  96634. export var shadowsFragmentFunctions: {
  96635. name: string;
  96636. shader: string;
  96637. };
  96638. }
  96639. declare module BABYLON {
  96640. /** @hidden */
  96641. export var fresnelFunction: {
  96642. name: string;
  96643. shader: string;
  96644. };
  96645. }
  96646. declare module BABYLON {
  96647. /** @hidden */
  96648. export var reflectionFunction: {
  96649. name: string;
  96650. shader: string;
  96651. };
  96652. }
  96653. declare module BABYLON {
  96654. /** @hidden */
  96655. export var bumpFragmentFunctions: {
  96656. name: string;
  96657. shader: string;
  96658. };
  96659. }
  96660. declare module BABYLON {
  96661. /** @hidden */
  96662. export var logDepthDeclaration: {
  96663. name: string;
  96664. shader: string;
  96665. };
  96666. }
  96667. declare module BABYLON {
  96668. /** @hidden */
  96669. export var bumpFragment: {
  96670. name: string;
  96671. shader: string;
  96672. };
  96673. }
  96674. declare module BABYLON {
  96675. /** @hidden */
  96676. export var depthPrePass: {
  96677. name: string;
  96678. shader: string;
  96679. };
  96680. }
  96681. declare module BABYLON {
  96682. /** @hidden */
  96683. export var lightFragment: {
  96684. name: string;
  96685. shader: string;
  96686. };
  96687. }
  96688. declare module BABYLON {
  96689. /** @hidden */
  96690. export var logDepthFragment: {
  96691. name: string;
  96692. shader: string;
  96693. };
  96694. }
  96695. declare module BABYLON {
  96696. /** @hidden */
  96697. export var defaultPixelShader: {
  96698. name: string;
  96699. shader: string;
  96700. };
  96701. }
  96702. declare module BABYLON {
  96703. /** @hidden */
  96704. export var defaultVertexDeclaration: {
  96705. name: string;
  96706. shader: string;
  96707. };
  96708. }
  96709. declare module BABYLON {
  96710. /** @hidden */
  96711. export var bumpVertexDeclaration: {
  96712. name: string;
  96713. shader: string;
  96714. };
  96715. }
  96716. declare module BABYLON {
  96717. /** @hidden */
  96718. export var bumpVertex: {
  96719. name: string;
  96720. shader: string;
  96721. };
  96722. }
  96723. declare module BABYLON {
  96724. /** @hidden */
  96725. export var fogVertex: {
  96726. name: string;
  96727. shader: string;
  96728. };
  96729. }
  96730. declare module BABYLON {
  96731. /** @hidden */
  96732. export var shadowsVertex: {
  96733. name: string;
  96734. shader: string;
  96735. };
  96736. }
  96737. declare module BABYLON {
  96738. /** @hidden */
  96739. export var pointCloudVertex: {
  96740. name: string;
  96741. shader: string;
  96742. };
  96743. }
  96744. declare module BABYLON {
  96745. /** @hidden */
  96746. export var logDepthVertex: {
  96747. name: string;
  96748. shader: string;
  96749. };
  96750. }
  96751. declare module BABYLON {
  96752. /** @hidden */
  96753. export var defaultVertexShader: {
  96754. name: string;
  96755. shader: string;
  96756. };
  96757. }
  96758. declare module BABYLON {
  96759. /** @hidden */
  96760. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96761. MAINUV1: boolean;
  96762. MAINUV2: boolean;
  96763. DIFFUSE: boolean;
  96764. DIFFUSEDIRECTUV: number;
  96765. AMBIENT: boolean;
  96766. AMBIENTDIRECTUV: number;
  96767. OPACITY: boolean;
  96768. OPACITYDIRECTUV: number;
  96769. OPACITYRGB: boolean;
  96770. REFLECTION: boolean;
  96771. EMISSIVE: boolean;
  96772. EMISSIVEDIRECTUV: number;
  96773. SPECULAR: boolean;
  96774. SPECULARDIRECTUV: number;
  96775. BUMP: boolean;
  96776. BUMPDIRECTUV: number;
  96777. PARALLAX: boolean;
  96778. PARALLAXOCCLUSION: boolean;
  96779. SPECULAROVERALPHA: boolean;
  96780. CLIPPLANE: boolean;
  96781. CLIPPLANE2: boolean;
  96782. CLIPPLANE3: boolean;
  96783. CLIPPLANE4: boolean;
  96784. CLIPPLANE5: boolean;
  96785. CLIPPLANE6: boolean;
  96786. ALPHATEST: boolean;
  96787. DEPTHPREPASS: boolean;
  96788. ALPHAFROMDIFFUSE: boolean;
  96789. POINTSIZE: boolean;
  96790. FOG: boolean;
  96791. SPECULARTERM: boolean;
  96792. DIFFUSEFRESNEL: boolean;
  96793. OPACITYFRESNEL: boolean;
  96794. REFLECTIONFRESNEL: boolean;
  96795. REFRACTIONFRESNEL: boolean;
  96796. EMISSIVEFRESNEL: boolean;
  96797. FRESNEL: boolean;
  96798. NORMAL: boolean;
  96799. UV1: boolean;
  96800. UV2: boolean;
  96801. VERTEXCOLOR: boolean;
  96802. VERTEXALPHA: boolean;
  96803. NUM_BONE_INFLUENCERS: number;
  96804. BonesPerMesh: number;
  96805. BONETEXTURE: boolean;
  96806. INSTANCES: boolean;
  96807. GLOSSINESS: boolean;
  96808. ROUGHNESS: boolean;
  96809. EMISSIVEASILLUMINATION: boolean;
  96810. LINKEMISSIVEWITHDIFFUSE: boolean;
  96811. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96812. LIGHTMAP: boolean;
  96813. LIGHTMAPDIRECTUV: number;
  96814. OBJECTSPACE_NORMALMAP: boolean;
  96815. USELIGHTMAPASSHADOWMAP: boolean;
  96816. REFLECTIONMAP_3D: boolean;
  96817. REFLECTIONMAP_SPHERICAL: boolean;
  96818. REFLECTIONMAP_PLANAR: boolean;
  96819. REFLECTIONMAP_CUBIC: boolean;
  96820. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96821. REFLECTIONMAP_PROJECTION: boolean;
  96822. REFLECTIONMAP_SKYBOX: boolean;
  96823. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96824. REFLECTIONMAP_EXPLICIT: boolean;
  96825. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96826. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96827. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96828. INVERTCUBICMAP: boolean;
  96829. LOGARITHMICDEPTH: boolean;
  96830. REFRACTION: boolean;
  96831. REFRACTIONMAP_3D: boolean;
  96832. REFLECTIONOVERALPHA: boolean;
  96833. TWOSIDEDLIGHTING: boolean;
  96834. SHADOWFLOAT: boolean;
  96835. MORPHTARGETS: boolean;
  96836. MORPHTARGETS_NORMAL: boolean;
  96837. MORPHTARGETS_TANGENT: boolean;
  96838. MORPHTARGETS_UV: boolean;
  96839. NUM_MORPH_INFLUENCERS: number;
  96840. NONUNIFORMSCALING: boolean;
  96841. PREMULTIPLYALPHA: boolean;
  96842. IMAGEPROCESSING: boolean;
  96843. VIGNETTE: boolean;
  96844. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96845. VIGNETTEBLENDMODEOPAQUE: boolean;
  96846. TONEMAPPING: boolean;
  96847. TONEMAPPING_ACES: boolean;
  96848. CONTRAST: boolean;
  96849. COLORCURVES: boolean;
  96850. COLORGRADING: boolean;
  96851. COLORGRADING3D: boolean;
  96852. SAMPLER3DGREENDEPTH: boolean;
  96853. SAMPLER3DBGRMAP: boolean;
  96854. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96855. MULTIVIEW: boolean;
  96856. /**
  96857. * If the reflection texture on this material is in linear color space
  96858. * @hidden
  96859. */
  96860. IS_REFLECTION_LINEAR: boolean;
  96861. /**
  96862. * If the refraction texture on this material is in linear color space
  96863. * @hidden
  96864. */
  96865. IS_REFRACTION_LINEAR: boolean;
  96866. EXPOSURE: boolean;
  96867. constructor();
  96868. setReflectionMode(modeToEnable: string): void;
  96869. }
  96870. /**
  96871. * This is the default material used in Babylon. It is the best trade off between quality
  96872. * and performances.
  96873. * @see http://doc.babylonjs.com/babylon101/materials
  96874. */
  96875. export class StandardMaterial extends PushMaterial {
  96876. private _diffuseTexture;
  96877. /**
  96878. * The basic texture of the material as viewed under a light.
  96879. */
  96880. diffuseTexture: Nullable<BaseTexture>;
  96881. private _ambientTexture;
  96882. /**
  96883. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96884. */
  96885. ambientTexture: Nullable<BaseTexture>;
  96886. private _opacityTexture;
  96887. /**
  96888. * Define the transparency of the material from a texture.
  96889. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96890. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96891. */
  96892. opacityTexture: Nullable<BaseTexture>;
  96893. private _reflectionTexture;
  96894. /**
  96895. * Define the texture used to display the reflection.
  96896. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96897. */
  96898. reflectionTexture: Nullable<BaseTexture>;
  96899. private _emissiveTexture;
  96900. /**
  96901. * Define texture of the material as if self lit.
  96902. * This will be mixed in the final result even in the absence of light.
  96903. */
  96904. emissiveTexture: Nullable<BaseTexture>;
  96905. private _specularTexture;
  96906. /**
  96907. * Define how the color and intensity of the highlight given by the light in the material.
  96908. */
  96909. specularTexture: Nullable<BaseTexture>;
  96910. private _bumpTexture;
  96911. /**
  96912. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96913. * 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.
  96914. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96915. */
  96916. bumpTexture: Nullable<BaseTexture>;
  96917. private _lightmapTexture;
  96918. /**
  96919. * Complex lighting can be computationally expensive to compute at runtime.
  96920. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96921. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96922. */
  96923. lightmapTexture: Nullable<BaseTexture>;
  96924. private _refractionTexture;
  96925. /**
  96926. * Define the texture used to display the refraction.
  96927. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96928. */
  96929. refractionTexture: Nullable<BaseTexture>;
  96930. /**
  96931. * The color of the material lit by the environmental background lighting.
  96932. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96933. */
  96934. ambientColor: Color3;
  96935. /**
  96936. * The basic color of the material as viewed under a light.
  96937. */
  96938. diffuseColor: Color3;
  96939. /**
  96940. * Define how the color and intensity of the highlight given by the light in the material.
  96941. */
  96942. specularColor: Color3;
  96943. /**
  96944. * Define the color of the material as if self lit.
  96945. * This will be mixed in the final result even in the absence of light.
  96946. */
  96947. emissiveColor: Color3;
  96948. /**
  96949. * Defines how sharp are the highlights in the material.
  96950. * The bigger the value the sharper giving a more glossy feeling to the result.
  96951. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96952. */
  96953. specularPower: number;
  96954. private _useAlphaFromDiffuseTexture;
  96955. /**
  96956. * Does the transparency come from the diffuse texture alpha channel.
  96957. */
  96958. useAlphaFromDiffuseTexture: boolean;
  96959. private _useEmissiveAsIllumination;
  96960. /**
  96961. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96962. */
  96963. useEmissiveAsIllumination: boolean;
  96964. private _linkEmissiveWithDiffuse;
  96965. /**
  96966. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96967. * the emissive level when the final color is close to one.
  96968. */
  96969. linkEmissiveWithDiffuse: boolean;
  96970. private _useSpecularOverAlpha;
  96971. /**
  96972. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96973. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96974. */
  96975. useSpecularOverAlpha: boolean;
  96976. private _useReflectionOverAlpha;
  96977. /**
  96978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96980. */
  96981. useReflectionOverAlpha: boolean;
  96982. private _disableLighting;
  96983. /**
  96984. * Does lights from the scene impacts this material.
  96985. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96986. */
  96987. disableLighting: boolean;
  96988. private _useObjectSpaceNormalMap;
  96989. /**
  96990. * Allows using an object space normal map (instead of tangent space).
  96991. */
  96992. useObjectSpaceNormalMap: boolean;
  96993. private _useParallax;
  96994. /**
  96995. * Is parallax enabled or not.
  96996. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96997. */
  96998. useParallax: boolean;
  96999. private _useParallaxOcclusion;
  97000. /**
  97001. * Is parallax occlusion enabled or not.
  97002. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97003. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97004. */
  97005. useParallaxOcclusion: boolean;
  97006. /**
  97007. * 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.
  97008. */
  97009. parallaxScaleBias: number;
  97010. private _roughness;
  97011. /**
  97012. * Helps to define how blurry the reflections should appears in the material.
  97013. */
  97014. roughness: number;
  97015. /**
  97016. * In case of refraction, define the value of the index of refraction.
  97017. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97018. */
  97019. indexOfRefraction: number;
  97020. /**
  97021. * Invert the refraction texture alongside the y axis.
  97022. * It can be useful with procedural textures or probe for instance.
  97023. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97024. */
  97025. invertRefractionY: boolean;
  97026. /**
  97027. * Defines the alpha limits in alpha test mode.
  97028. */
  97029. alphaCutOff: number;
  97030. private _useLightmapAsShadowmap;
  97031. /**
  97032. * In case of light mapping, define whether the map contains light or shadow informations.
  97033. */
  97034. useLightmapAsShadowmap: boolean;
  97035. private _diffuseFresnelParameters;
  97036. /**
  97037. * Define the diffuse fresnel parameters of the material.
  97038. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97039. */
  97040. diffuseFresnelParameters: FresnelParameters;
  97041. private _opacityFresnelParameters;
  97042. /**
  97043. * Define the opacity fresnel parameters of the material.
  97044. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97045. */
  97046. opacityFresnelParameters: FresnelParameters;
  97047. private _reflectionFresnelParameters;
  97048. /**
  97049. * Define the reflection fresnel parameters of the material.
  97050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97051. */
  97052. reflectionFresnelParameters: FresnelParameters;
  97053. private _refractionFresnelParameters;
  97054. /**
  97055. * Define the refraction fresnel parameters of the material.
  97056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97057. */
  97058. refractionFresnelParameters: FresnelParameters;
  97059. private _emissiveFresnelParameters;
  97060. /**
  97061. * Define the emissive fresnel parameters of the material.
  97062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97063. */
  97064. emissiveFresnelParameters: FresnelParameters;
  97065. private _useReflectionFresnelFromSpecular;
  97066. /**
  97067. * If true automatically deducts the fresnels values from the material specularity.
  97068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97069. */
  97070. useReflectionFresnelFromSpecular: boolean;
  97071. private _useGlossinessFromSpecularMapAlpha;
  97072. /**
  97073. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97074. */
  97075. useGlossinessFromSpecularMapAlpha: boolean;
  97076. private _maxSimultaneousLights;
  97077. /**
  97078. * Defines the maximum number of lights that can be used in the material
  97079. */
  97080. maxSimultaneousLights: number;
  97081. private _invertNormalMapX;
  97082. /**
  97083. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97084. */
  97085. invertNormalMapX: boolean;
  97086. private _invertNormalMapY;
  97087. /**
  97088. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97089. */
  97090. invertNormalMapY: boolean;
  97091. private _twoSidedLighting;
  97092. /**
  97093. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97094. */
  97095. twoSidedLighting: boolean;
  97096. /**
  97097. * Default configuration related to image processing available in the standard Material.
  97098. */
  97099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97100. /**
  97101. * Gets the image processing configuration used either in this material.
  97102. */
  97103. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97104. /**
  97105. * Sets the Default image processing configuration used either in the this material.
  97106. *
  97107. * If sets to null, the scene one is in use.
  97108. */
  97109. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97110. /**
  97111. * Keep track of the image processing observer to allow dispose and replace.
  97112. */
  97113. private _imageProcessingObserver;
  97114. /**
  97115. * Attaches a new image processing configuration to the Standard Material.
  97116. * @param configuration
  97117. */
  97118. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97119. /**
  97120. * Gets wether the color curves effect is enabled.
  97121. */
  97122. get cameraColorCurvesEnabled(): boolean;
  97123. /**
  97124. * Sets wether the color curves effect is enabled.
  97125. */
  97126. set cameraColorCurvesEnabled(value: boolean);
  97127. /**
  97128. * Gets wether the color grading effect is enabled.
  97129. */
  97130. get cameraColorGradingEnabled(): boolean;
  97131. /**
  97132. * Gets wether the color grading effect is enabled.
  97133. */
  97134. set cameraColorGradingEnabled(value: boolean);
  97135. /**
  97136. * Gets wether tonemapping is enabled or not.
  97137. */
  97138. get cameraToneMappingEnabled(): boolean;
  97139. /**
  97140. * Sets wether tonemapping is enabled or not
  97141. */
  97142. set cameraToneMappingEnabled(value: boolean);
  97143. /**
  97144. * The camera exposure used on this material.
  97145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97146. * This corresponds to a photographic exposure.
  97147. */
  97148. get cameraExposure(): number;
  97149. /**
  97150. * The camera exposure used on this material.
  97151. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97152. * This corresponds to a photographic exposure.
  97153. */
  97154. set cameraExposure(value: number);
  97155. /**
  97156. * Gets The camera contrast used on this material.
  97157. */
  97158. get cameraContrast(): number;
  97159. /**
  97160. * Sets The camera contrast used on this material.
  97161. */
  97162. set cameraContrast(value: number);
  97163. /**
  97164. * Gets the Color Grading 2D Lookup Texture.
  97165. */
  97166. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97167. /**
  97168. * Sets the Color Grading 2D Lookup Texture.
  97169. */
  97170. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97171. /**
  97172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97174. * 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;
  97175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97176. */
  97177. get cameraColorCurves(): Nullable<ColorCurves>;
  97178. /**
  97179. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97180. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97181. * 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;
  97182. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97183. */
  97184. set cameraColorCurves(value: Nullable<ColorCurves>);
  97185. /**
  97186. * Custom callback helping to override the default shader used in the material.
  97187. */
  97188. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97189. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97190. protected _worldViewProjectionMatrix: Matrix;
  97191. protected _globalAmbientColor: Color3;
  97192. protected _useLogarithmicDepth: boolean;
  97193. protected _rebuildInParallel: boolean;
  97194. /**
  97195. * Instantiates a new standard material.
  97196. * This is the default material used in Babylon. It is the best trade off between quality
  97197. * and performances.
  97198. * @see http://doc.babylonjs.com/babylon101/materials
  97199. * @param name Define the name of the material in the scene
  97200. * @param scene Define the scene the material belong to
  97201. */
  97202. constructor(name: string, scene: Scene);
  97203. /**
  97204. * Gets a boolean indicating that current material needs to register RTT
  97205. */
  97206. get hasRenderTargetTextures(): boolean;
  97207. /**
  97208. * Gets the current class name of the material e.g. "StandardMaterial"
  97209. * Mainly use in serialization.
  97210. * @returns the class name
  97211. */
  97212. getClassName(): string;
  97213. /**
  97214. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97215. * You can try switching to logarithmic depth.
  97216. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97217. */
  97218. get useLogarithmicDepth(): boolean;
  97219. set useLogarithmicDepth(value: boolean);
  97220. /**
  97221. * Specifies if the material will require alpha blending
  97222. * @returns a boolean specifying if alpha blending is needed
  97223. */
  97224. needAlphaBlending(): boolean;
  97225. /**
  97226. * Specifies if this material should be rendered in alpha test mode
  97227. * @returns a boolean specifying if an alpha test is needed.
  97228. */
  97229. needAlphaTesting(): boolean;
  97230. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97231. /**
  97232. * Get the texture used for alpha test purpose.
  97233. * @returns the diffuse texture in case of the standard material.
  97234. */
  97235. getAlphaTestTexture(): Nullable<BaseTexture>;
  97236. /**
  97237. * Get if the submesh is ready to be used and all its information available.
  97238. * Child classes can use it to update shaders
  97239. * @param mesh defines the mesh to check
  97240. * @param subMesh defines which submesh to check
  97241. * @param useInstances specifies that instances should be used
  97242. * @returns a boolean indicating that the submesh is ready or not
  97243. */
  97244. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97245. /**
  97246. * Builds the material UBO layouts.
  97247. * Used internally during the effect preparation.
  97248. */
  97249. buildUniformLayout(): void;
  97250. /**
  97251. * Unbinds the material from the mesh
  97252. */
  97253. unbind(): void;
  97254. /**
  97255. * Binds the submesh to this material by preparing the effect and shader to draw
  97256. * @param world defines the world transformation matrix
  97257. * @param mesh defines the mesh containing the submesh
  97258. * @param subMesh defines the submesh to bind the material to
  97259. */
  97260. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97261. /**
  97262. * Get the list of animatables in the material.
  97263. * @returns the list of animatables object used in the material
  97264. */
  97265. getAnimatables(): IAnimatable[];
  97266. /**
  97267. * Gets the active textures from the material
  97268. * @returns an array of textures
  97269. */
  97270. getActiveTextures(): BaseTexture[];
  97271. /**
  97272. * Specifies if the material uses a texture
  97273. * @param texture defines the texture to check against the material
  97274. * @returns a boolean specifying if the material uses the texture
  97275. */
  97276. hasTexture(texture: BaseTexture): boolean;
  97277. /**
  97278. * Disposes the material
  97279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97281. */
  97282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97283. /**
  97284. * Makes a duplicate of the material, and gives it a new name
  97285. * @param name defines the new name for the duplicated material
  97286. * @returns the cloned material
  97287. */
  97288. clone(name: string): StandardMaterial;
  97289. /**
  97290. * Serializes this material in a JSON representation
  97291. * @returns the serialized material object
  97292. */
  97293. serialize(): any;
  97294. /**
  97295. * Creates a standard material from parsed material data
  97296. * @param source defines the JSON representation of the material
  97297. * @param scene defines the hosting scene
  97298. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97299. * @returns a new standard material
  97300. */
  97301. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97302. /**
  97303. * Are diffuse textures enabled in the application.
  97304. */
  97305. static get DiffuseTextureEnabled(): boolean;
  97306. static set DiffuseTextureEnabled(value: boolean);
  97307. /**
  97308. * Are ambient textures enabled in the application.
  97309. */
  97310. static get AmbientTextureEnabled(): boolean;
  97311. static set AmbientTextureEnabled(value: boolean);
  97312. /**
  97313. * Are opacity textures enabled in the application.
  97314. */
  97315. static get OpacityTextureEnabled(): boolean;
  97316. static set OpacityTextureEnabled(value: boolean);
  97317. /**
  97318. * Are reflection textures enabled in the application.
  97319. */
  97320. static get ReflectionTextureEnabled(): boolean;
  97321. static set ReflectionTextureEnabled(value: boolean);
  97322. /**
  97323. * Are emissive textures enabled in the application.
  97324. */
  97325. static get EmissiveTextureEnabled(): boolean;
  97326. static set EmissiveTextureEnabled(value: boolean);
  97327. /**
  97328. * Are specular textures enabled in the application.
  97329. */
  97330. static get SpecularTextureEnabled(): boolean;
  97331. static set SpecularTextureEnabled(value: boolean);
  97332. /**
  97333. * Are bump textures enabled in the application.
  97334. */
  97335. static get BumpTextureEnabled(): boolean;
  97336. static set BumpTextureEnabled(value: boolean);
  97337. /**
  97338. * Are lightmap textures enabled in the application.
  97339. */
  97340. static get LightmapTextureEnabled(): boolean;
  97341. static set LightmapTextureEnabled(value: boolean);
  97342. /**
  97343. * Are refraction textures enabled in the application.
  97344. */
  97345. static get RefractionTextureEnabled(): boolean;
  97346. static set RefractionTextureEnabled(value: boolean);
  97347. /**
  97348. * Are color grading textures enabled in the application.
  97349. */
  97350. static get ColorGradingTextureEnabled(): boolean;
  97351. static set ColorGradingTextureEnabled(value: boolean);
  97352. /**
  97353. * Are fresnels enabled in the application.
  97354. */
  97355. static get FresnelEnabled(): boolean;
  97356. static set FresnelEnabled(value: boolean);
  97357. }
  97358. }
  97359. declare module BABYLON {
  97360. /**
  97361. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97362. *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.
  97363. * The SPS is also a particle system. It provides some methods to manage the particles.
  97364. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97365. *
  97366. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97367. */
  97368. export class SolidParticleSystem implements IDisposable {
  97369. /**
  97370. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97371. * Example : var p = SPS.particles[i];
  97372. */
  97373. particles: SolidParticle[];
  97374. /**
  97375. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97376. */
  97377. nbParticles: number;
  97378. /**
  97379. * If the particles must ever face the camera (default false). Useful for planar particles.
  97380. */
  97381. billboard: boolean;
  97382. /**
  97383. * Recompute normals when adding a shape
  97384. */
  97385. recomputeNormals: boolean;
  97386. /**
  97387. * This a counter ofr your own usage. It's not set by any SPS functions.
  97388. */
  97389. counter: number;
  97390. /**
  97391. * The SPS name. This name is also given to the underlying mesh.
  97392. */
  97393. name: string;
  97394. /**
  97395. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97396. */
  97397. mesh: Mesh;
  97398. /**
  97399. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97400. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97401. */
  97402. vars: any;
  97403. /**
  97404. * This array is populated when the SPS is set as 'pickable'.
  97405. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97406. * Each element of this array is an object `{idx: int, faceId: int}`.
  97407. * `idx` is the picked particle index in the `SPS.particles` array
  97408. * `faceId` is the picked face index counted within this particle.
  97409. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97410. */
  97411. pickedParticles: {
  97412. idx: number;
  97413. faceId: number;
  97414. }[];
  97415. /**
  97416. * This array is populated when `enableDepthSort` is set to true.
  97417. * Each element of this array is an instance of the class DepthSortedParticle.
  97418. */
  97419. depthSortedParticles: DepthSortedParticle[];
  97420. /**
  97421. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97422. * @hidden
  97423. */
  97424. _bSphereOnly: boolean;
  97425. /**
  97426. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97427. * @hidden
  97428. */
  97429. _bSphereRadiusFactor: number;
  97430. private _scene;
  97431. private _positions;
  97432. private _indices;
  97433. private _normals;
  97434. private _colors;
  97435. private _uvs;
  97436. private _indices32;
  97437. private _positions32;
  97438. private _normals32;
  97439. private _fixedNormal32;
  97440. private _colors32;
  97441. private _uvs32;
  97442. private _index;
  97443. private _updatable;
  97444. private _pickable;
  97445. private _isVisibilityBoxLocked;
  97446. private _alwaysVisible;
  97447. private _depthSort;
  97448. private _expandable;
  97449. private _shapeCounter;
  97450. private _copy;
  97451. private _color;
  97452. private _computeParticleColor;
  97453. private _computeParticleTexture;
  97454. private _computeParticleRotation;
  97455. private _computeParticleVertex;
  97456. private _computeBoundingBox;
  97457. private _depthSortParticles;
  97458. private _camera;
  97459. private _mustUnrotateFixedNormals;
  97460. private _particlesIntersect;
  97461. private _needs32Bits;
  97462. private _isNotBuilt;
  97463. private _lastParticleId;
  97464. private _idxOfId;
  97465. private _multimaterialEnabled;
  97466. private _useModelMaterial;
  97467. private _indicesByMaterial;
  97468. private _materialIndexes;
  97469. private _depthSortFunction;
  97470. private _materialSortFunction;
  97471. private _materials;
  97472. private _multimaterial;
  97473. private _materialIndexesById;
  97474. private _defaultMaterial;
  97475. private _autoUpdateSubMeshes;
  97476. /**
  97477. * Creates a SPS (Solid Particle System) object.
  97478. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97479. * @param scene (Scene) is the scene in which the SPS is added.
  97480. * @param options defines the options of the sps e.g.
  97481. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97482. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97483. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97484. * * 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.
  97485. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97486. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97487. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97488. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97489. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97490. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97491. */
  97492. constructor(name: string, scene: Scene, options?: {
  97493. updatable?: boolean;
  97494. isPickable?: boolean;
  97495. enableDepthSort?: boolean;
  97496. particleIntersection?: boolean;
  97497. boundingSphereOnly?: boolean;
  97498. bSphereRadiusFactor?: number;
  97499. expandable?: boolean;
  97500. useModelMaterial?: boolean;
  97501. enableMultiMaterial?: boolean;
  97502. });
  97503. /**
  97504. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97505. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97506. * @returns the created mesh
  97507. */
  97508. buildMesh(): Mesh;
  97509. /**
  97510. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97511. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97512. * Thus the particles generated from `digest()` have their property `position` set yet.
  97513. * @param mesh ( Mesh ) is the mesh to be digested
  97514. * @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
  97515. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97516. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97517. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97518. * @returns the current SPS
  97519. */
  97520. digest(mesh: Mesh, options?: {
  97521. facetNb?: number;
  97522. number?: number;
  97523. delta?: number;
  97524. storage?: [];
  97525. }): SolidParticleSystem;
  97526. /**
  97527. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97528. * @hidden
  97529. */
  97530. private _unrotateFixedNormals;
  97531. /**
  97532. * Resets the temporary working copy particle
  97533. * @hidden
  97534. */
  97535. private _resetCopy;
  97536. /**
  97537. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97538. * @param p the current index in the positions array to be updated
  97539. * @param ind the current index in the indices array
  97540. * @param shape a Vector3 array, the shape geometry
  97541. * @param positions the positions array to be updated
  97542. * @param meshInd the shape indices array
  97543. * @param indices the indices array to be updated
  97544. * @param meshUV the shape uv array
  97545. * @param uvs the uv array to be updated
  97546. * @param meshCol the shape color array
  97547. * @param colors the color array to be updated
  97548. * @param meshNor the shape normals array
  97549. * @param normals the normals array to be updated
  97550. * @param idx the particle index
  97551. * @param idxInShape the particle index in its shape
  97552. * @param options the addShape() method passed options
  97553. * @model the particle model
  97554. * @hidden
  97555. */
  97556. private _meshBuilder;
  97557. /**
  97558. * Returns a shape Vector3 array from positions float array
  97559. * @param positions float array
  97560. * @returns a vector3 array
  97561. * @hidden
  97562. */
  97563. private _posToShape;
  97564. /**
  97565. * Returns a shapeUV array from a float uvs (array deep copy)
  97566. * @param uvs as a float array
  97567. * @returns a shapeUV array
  97568. * @hidden
  97569. */
  97570. private _uvsToShapeUV;
  97571. /**
  97572. * Adds a new particle object in the particles array
  97573. * @param idx particle index in particles array
  97574. * @param id particle id
  97575. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97576. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97577. * @param model particle ModelShape object
  97578. * @param shapeId model shape identifier
  97579. * @param idxInShape index of the particle in the current model
  97580. * @param bInfo model bounding info object
  97581. * @param storage target storage array, if any
  97582. * @hidden
  97583. */
  97584. private _addParticle;
  97585. /**
  97586. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97587. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97588. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97589. * @param nb (positive integer) the number of particles to be created from this model
  97590. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97591. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97592. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97593. * @returns the number of shapes in the system
  97594. */
  97595. addShape(mesh: Mesh, nb: number, options?: {
  97596. positionFunction?: any;
  97597. vertexFunction?: any;
  97598. storage?: [];
  97599. }): number;
  97600. /**
  97601. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97602. * @hidden
  97603. */
  97604. private _rebuildParticle;
  97605. /**
  97606. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97607. * @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.
  97608. * @returns the SPS.
  97609. */
  97610. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97611. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97612. * Returns an array with the removed particles.
  97613. * 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.
  97614. * The SPS can't be empty so at least one particle needs to remain in place.
  97615. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97616. * @param start index of the first particle to remove
  97617. * @param end index of the last particle to remove (included)
  97618. * @returns an array populated with the removed particles
  97619. */
  97620. removeParticles(start: number, end: number): SolidParticle[];
  97621. /**
  97622. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97623. * @param solidParticleArray an array populated with Solid Particles objects
  97624. * @returns the SPS
  97625. */
  97626. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97627. /**
  97628. * Creates a new particle and modifies the SPS mesh geometry :
  97629. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97630. * - calls _addParticle() to populate the particle array
  97631. * factorized code from addShape() and insertParticlesFromArray()
  97632. * @param idx particle index in the particles array
  97633. * @param i particle index in its shape
  97634. * @param modelShape particle ModelShape object
  97635. * @param shape shape vertex array
  97636. * @param meshInd shape indices array
  97637. * @param meshUV shape uv array
  97638. * @param meshCol shape color array
  97639. * @param meshNor shape normals array
  97640. * @param bbInfo shape bounding info
  97641. * @param storage target particle storage
  97642. * @options addShape() passed options
  97643. * @hidden
  97644. */
  97645. private _insertNewParticle;
  97646. /**
  97647. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97648. * This method calls `updateParticle()` for each particle of the SPS.
  97649. * For an animated SPS, it is usually called within the render loop.
  97650. * 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.
  97651. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97652. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97653. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97654. * @returns the SPS.
  97655. */
  97656. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97657. /**
  97658. * Disposes the SPS.
  97659. */
  97660. dispose(): void;
  97661. /**
  97662. * Returns a SolidParticle object from its identifier : particle.id
  97663. * @param id (integer) the particle Id
  97664. * @returns the searched particle or null if not found in the SPS.
  97665. */
  97666. getParticleById(id: number): Nullable<SolidParticle>;
  97667. /**
  97668. * Returns a new array populated with the particles having the passed shapeId.
  97669. * @param shapeId (integer) the shape identifier
  97670. * @returns a new solid particle array
  97671. */
  97672. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97673. /**
  97674. * Populates the passed array "ref" with the particles having the passed shapeId.
  97675. * @param shapeId the shape identifier
  97676. * @returns the SPS
  97677. * @param ref
  97678. */
  97679. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97680. /**
  97681. * Computes the required SubMeshes according the materials assigned to the particles.
  97682. * @returns the solid particle system.
  97683. * Does nothing if called before the SPS mesh is built.
  97684. */
  97685. computeSubMeshes(): SolidParticleSystem;
  97686. /**
  97687. * Sorts the solid particles by material when MultiMaterial is enabled.
  97688. * Updates the indices32 array.
  97689. * Updates the indicesByMaterial array.
  97690. * Updates the mesh indices array.
  97691. * @returns the SPS
  97692. * @hidden
  97693. */
  97694. private _sortParticlesByMaterial;
  97695. /**
  97696. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97697. * @hidden
  97698. */
  97699. private _setMaterialIndexesById;
  97700. /**
  97701. * Returns an array with unique values of Materials from the passed array
  97702. * @param array the material array to be checked and filtered
  97703. * @hidden
  97704. */
  97705. private _filterUniqueMaterialId;
  97706. /**
  97707. * Sets a new Standard Material as _defaultMaterial if not already set.
  97708. * @hidden
  97709. */
  97710. private _setDefaultMaterial;
  97711. /**
  97712. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97713. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97714. * @returns the SPS.
  97715. */
  97716. refreshVisibleSize(): SolidParticleSystem;
  97717. /**
  97718. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97719. * @param size the size (float) of the visibility box
  97720. * note : this doesn't lock the SPS mesh bounding box.
  97721. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97722. */
  97723. setVisibilityBox(size: number): void;
  97724. /**
  97725. * Gets whether the SPS as always visible or not
  97726. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97727. */
  97728. get isAlwaysVisible(): boolean;
  97729. /**
  97730. * Sets the SPS as always visible or not
  97731. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97732. */
  97733. set isAlwaysVisible(val: boolean);
  97734. /**
  97735. * Sets 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. set isVisibilityBoxLocked(val: boolean);
  97739. /**
  97740. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97741. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97742. */
  97743. get isVisibilityBoxLocked(): boolean;
  97744. /**
  97745. * Tells to `setParticles()` to compute the particle rotations or not.
  97746. * Default value : true. The SPS is faster when it's set to false.
  97747. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97748. */
  97749. set computeParticleRotation(val: boolean);
  97750. /**
  97751. * Tells to `setParticles()` to compute the particle colors or not.
  97752. * Default value : true. The SPS is faster when it's set to false.
  97753. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97754. */
  97755. set computeParticleColor(val: boolean);
  97756. set computeParticleTexture(val: boolean);
  97757. /**
  97758. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97759. * Default value : false. The SPS is faster when it's set to false.
  97760. * Note : the particle custom vertex positions aren't stored values.
  97761. */
  97762. set computeParticleVertex(val: boolean);
  97763. /**
  97764. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97765. */
  97766. set computeBoundingBox(val: boolean);
  97767. /**
  97768. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97769. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97770. * Default : `true`
  97771. */
  97772. set depthSortParticles(val: boolean);
  97773. /**
  97774. * Gets if `setParticles()` computes the particle rotations or not.
  97775. * Default value : true. The SPS is faster when it's set to false.
  97776. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97777. */
  97778. get computeParticleRotation(): boolean;
  97779. /**
  97780. * Gets if `setParticles()` computes the particle colors or not.
  97781. * Default value : true. The SPS is faster when it's set to false.
  97782. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97783. */
  97784. get computeParticleColor(): boolean;
  97785. /**
  97786. * Gets if `setParticles()` computes the particle textures or not.
  97787. * Default value : true. The SPS is faster when it's set to false.
  97788. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97789. */
  97790. get computeParticleTexture(): boolean;
  97791. /**
  97792. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97793. * Default value : false. The SPS is faster when it's set to false.
  97794. * Note : the particle custom vertex positions aren't stored values.
  97795. */
  97796. get computeParticleVertex(): boolean;
  97797. /**
  97798. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97799. */
  97800. get computeBoundingBox(): boolean;
  97801. /**
  97802. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97803. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97804. * Default : `true`
  97805. */
  97806. get depthSortParticles(): boolean;
  97807. /**
  97808. * Gets if the SPS is created as expandable at construction time.
  97809. * Default : `false`
  97810. */
  97811. get expandable(): boolean;
  97812. /**
  97813. * Gets if the SPS supports the Multi Materials
  97814. */
  97815. get multimaterialEnabled(): boolean;
  97816. /**
  97817. * Gets if the SPS uses the model materials for its own multimaterial.
  97818. */
  97819. get useModelMaterial(): boolean;
  97820. /**
  97821. * The SPS used material array.
  97822. */
  97823. get materials(): Material[];
  97824. /**
  97825. * Sets the SPS MultiMaterial from the passed materials.
  97826. * Note : the passed array is internally copied and not used then by reference.
  97827. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97828. */
  97829. setMultiMaterial(materials: Material[]): void;
  97830. /**
  97831. * The SPS computed multimaterial object
  97832. */
  97833. get multimaterial(): MultiMaterial;
  97834. set multimaterial(mm: MultiMaterial);
  97835. /**
  97836. * If the subMeshes must be updated on the next call to setParticles()
  97837. */
  97838. get autoUpdateSubMeshes(): boolean;
  97839. set autoUpdateSubMeshes(val: boolean);
  97840. /**
  97841. * This function does nothing. It may be overwritten to set all the particle first values.
  97842. * The SPS doesn't call this function, you may have to call it by your own.
  97843. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97844. */
  97845. initParticles(): void;
  97846. /**
  97847. * This function does nothing. It may be overwritten to recycle a particle.
  97848. * The SPS doesn't call this function, you may have to call it by your own.
  97849. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97850. * @param particle The particle to recycle
  97851. * @returns the recycled particle
  97852. */
  97853. recycleParticle(particle: SolidParticle): SolidParticle;
  97854. /**
  97855. * Updates a particle : this function should be overwritten by the user.
  97856. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97857. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97858. * @example : just set a particle position or velocity and recycle conditions
  97859. * @param particle The particle to update
  97860. * @returns the updated particle
  97861. */
  97862. updateParticle(particle: SolidParticle): SolidParticle;
  97863. /**
  97864. * Updates a vertex of a particle : it can be overwritten by the user.
  97865. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97866. * @param particle the current particle
  97867. * @param vertex the current index of the current particle
  97868. * @param pt the index of the current vertex in the particle shape
  97869. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97870. * @example : just set a vertex particle position
  97871. * @returns the updated vertex
  97872. */
  97873. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97874. /**
  97875. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97876. * This does nothing and may be overwritten by the user.
  97877. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97878. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97879. * @param update the boolean update value actually passed to setParticles()
  97880. */
  97881. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97882. /**
  97883. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97884. * This will be passed three parameters.
  97885. * This does nothing and may be overwritten by the user.
  97886. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97887. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97888. * @param update the boolean update value actually passed to setParticles()
  97889. */
  97890. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97891. }
  97892. }
  97893. declare module BABYLON {
  97894. /**
  97895. * Represents one particle of a solid particle system.
  97896. */
  97897. export class SolidParticle {
  97898. /**
  97899. * particle global index
  97900. */
  97901. idx: number;
  97902. /**
  97903. * particle identifier
  97904. */
  97905. id: number;
  97906. /**
  97907. * The color of the particle
  97908. */
  97909. color: Nullable<Color4>;
  97910. /**
  97911. * The world space position of the particle.
  97912. */
  97913. position: Vector3;
  97914. /**
  97915. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97916. */
  97917. rotation: Vector3;
  97918. /**
  97919. * The world space rotation quaternion of the particle.
  97920. */
  97921. rotationQuaternion: Nullable<Quaternion>;
  97922. /**
  97923. * The scaling of the particle.
  97924. */
  97925. scaling: Vector3;
  97926. /**
  97927. * The uvs of the particle.
  97928. */
  97929. uvs: Vector4;
  97930. /**
  97931. * The current speed of the particle.
  97932. */
  97933. velocity: Vector3;
  97934. /**
  97935. * The pivot point in the particle local space.
  97936. */
  97937. pivot: Vector3;
  97938. /**
  97939. * Must the particle be translated from its pivot point in its local space ?
  97940. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97941. * Default : false
  97942. */
  97943. translateFromPivot: boolean;
  97944. /**
  97945. * Is the particle active or not ?
  97946. */
  97947. alive: boolean;
  97948. /**
  97949. * Is the particle visible or not ?
  97950. */
  97951. isVisible: boolean;
  97952. /**
  97953. * Index of this particle in the global "positions" array (Internal use)
  97954. * @hidden
  97955. */
  97956. _pos: number;
  97957. /**
  97958. * @hidden Index of this particle in the global "indices" array (Internal use)
  97959. */
  97960. _ind: number;
  97961. /**
  97962. * @hidden ModelShape of this particle (Internal use)
  97963. */
  97964. _model: ModelShape;
  97965. /**
  97966. * ModelShape id of this particle
  97967. */
  97968. shapeId: number;
  97969. /**
  97970. * Index of the particle in its shape id
  97971. */
  97972. idxInShape: number;
  97973. /**
  97974. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97975. */
  97976. _modelBoundingInfo: BoundingInfo;
  97977. /**
  97978. * @hidden Particle BoundingInfo object (Internal use)
  97979. */
  97980. _boundingInfo: BoundingInfo;
  97981. /**
  97982. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97983. */
  97984. _sps: SolidParticleSystem;
  97985. /**
  97986. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97987. */
  97988. _stillInvisible: boolean;
  97989. /**
  97990. * @hidden Last computed particle rotation matrix
  97991. */
  97992. _rotationMatrix: number[];
  97993. /**
  97994. * Parent particle Id, if any.
  97995. * Default null.
  97996. */
  97997. parentId: Nullable<number>;
  97998. /**
  97999. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  98000. */
  98001. materialIndex: Nullable<number>;
  98002. /**
  98003. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  98004. * The possible values are :
  98005. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98006. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98007. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98008. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98009. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98010. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  98011. * */
  98012. cullingStrategy: number;
  98013. /**
  98014. * @hidden Internal global position in the SPS.
  98015. */
  98016. _globalPosition: Vector3;
  98017. /**
  98018. * Creates a Solid Particle object.
  98019. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  98020. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  98021. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  98022. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  98023. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  98024. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  98025. * @param shapeId (integer) is the model shape identifier in the SPS.
  98026. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  98027. * @param sps defines the sps it is associated to
  98028. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  98029. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  98030. */
  98031. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  98032. /**
  98033. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  98034. * @param target the particle target
  98035. * @returns the current particle
  98036. */
  98037. copyToRef(target: SolidParticle): SolidParticle;
  98038. /**
  98039. * Legacy support, changed scale to scaling
  98040. */
  98041. get scale(): Vector3;
  98042. /**
  98043. * Legacy support, changed scale to scaling
  98044. */
  98045. set scale(scale: Vector3);
  98046. /**
  98047. * Legacy support, changed quaternion to rotationQuaternion
  98048. */
  98049. get quaternion(): Nullable<Quaternion>;
  98050. /**
  98051. * Legacy support, changed quaternion to rotationQuaternion
  98052. */
  98053. set quaternion(q: Nullable<Quaternion>);
  98054. /**
  98055. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98056. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98057. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98058. * @returns true if it intersects
  98059. */
  98060. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98061. /**
  98062. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98063. * A particle is in the frustum if its bounding box intersects the frustum
  98064. * @param frustumPlanes defines the frustum to test
  98065. * @returns true if the particle is in the frustum planes
  98066. */
  98067. isInFrustum(frustumPlanes: Plane[]): boolean;
  98068. /**
  98069. * get the rotation matrix of the particle
  98070. * @hidden
  98071. */
  98072. getRotationMatrix(m: Matrix): void;
  98073. }
  98074. /**
  98075. * Represents the shape of the model used by one particle of a solid particle system.
  98076. * SPS internal tool, don't use it manually.
  98077. */
  98078. export class ModelShape {
  98079. /**
  98080. * The shape id
  98081. * @hidden
  98082. */
  98083. shapeID: number;
  98084. /**
  98085. * flat array of model positions (internal use)
  98086. * @hidden
  98087. */
  98088. _shape: Vector3[];
  98089. /**
  98090. * flat array of model UVs (internal use)
  98091. * @hidden
  98092. */
  98093. _shapeUV: number[];
  98094. /**
  98095. * color array of the model
  98096. * @hidden
  98097. */
  98098. _shapeColors: number[];
  98099. /**
  98100. * indices array of the model
  98101. * @hidden
  98102. */
  98103. _indices: number[];
  98104. /**
  98105. * normals array of the model
  98106. * @hidden
  98107. */
  98108. _normals: number[];
  98109. /**
  98110. * length of the shape in the model indices array (internal use)
  98111. * @hidden
  98112. */
  98113. _indicesLength: number;
  98114. /**
  98115. * Custom position function (internal use)
  98116. * @hidden
  98117. */
  98118. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98119. /**
  98120. * Custom vertex function (internal use)
  98121. * @hidden
  98122. */
  98123. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98124. /**
  98125. * Model material (internal use)
  98126. * @hidden
  98127. */
  98128. _material: Nullable<Material>;
  98129. /**
  98130. * 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.
  98131. * SPS internal tool, don't use it manually.
  98132. * @hidden
  98133. */
  98134. 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>);
  98135. }
  98136. /**
  98137. * Represents a Depth Sorted Particle in the solid particle system.
  98138. * @hidden
  98139. */
  98140. export class DepthSortedParticle {
  98141. /**
  98142. * Index of the particle in the "indices" array
  98143. */
  98144. ind: number;
  98145. /**
  98146. * Length of the particle shape in the "indices" array
  98147. */
  98148. indicesLength: number;
  98149. /**
  98150. * Squared distance from the particle to the camera
  98151. */
  98152. sqDistance: number;
  98153. /**
  98154. * Material index when used with MultiMaterials
  98155. */
  98156. materialIndex: number;
  98157. /**
  98158. * Creates a new sorted particle
  98159. * @param materialIndex
  98160. */
  98161. constructor(ind: number, indLength: number, materialIndex: number);
  98162. }
  98163. }
  98164. declare module BABYLON {
  98165. /**
  98166. * @hidden
  98167. */
  98168. export class _MeshCollisionData {
  98169. _checkCollisions: boolean;
  98170. _collisionMask: number;
  98171. _collisionGroup: number;
  98172. _collider: Nullable<Collider>;
  98173. _oldPositionForCollisions: Vector3;
  98174. _diffPositionForCollisions: Vector3;
  98175. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98176. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98177. }
  98178. }
  98179. declare module BABYLON {
  98180. /** @hidden */
  98181. class _FacetDataStorage {
  98182. facetPositions: Vector3[];
  98183. facetNormals: Vector3[];
  98184. facetPartitioning: number[][];
  98185. facetNb: number;
  98186. partitioningSubdivisions: number;
  98187. partitioningBBoxRatio: number;
  98188. facetDataEnabled: boolean;
  98189. facetParameters: any;
  98190. bbSize: Vector3;
  98191. subDiv: {
  98192. max: number;
  98193. X: number;
  98194. Y: number;
  98195. Z: number;
  98196. };
  98197. facetDepthSort: boolean;
  98198. facetDepthSortEnabled: boolean;
  98199. depthSortedIndices: IndicesArray;
  98200. depthSortedFacets: {
  98201. ind: number;
  98202. sqDistance: number;
  98203. }[];
  98204. facetDepthSortFunction: (f1: {
  98205. ind: number;
  98206. sqDistance: number;
  98207. }, f2: {
  98208. ind: number;
  98209. sqDistance: number;
  98210. }) => number;
  98211. facetDepthSortFrom: Vector3;
  98212. facetDepthSortOrigin: Vector3;
  98213. invertedMatrix: Matrix;
  98214. }
  98215. /**
  98216. * @hidden
  98217. **/
  98218. class _InternalAbstractMeshDataInfo {
  98219. _hasVertexAlpha: boolean;
  98220. _useVertexColors: boolean;
  98221. _numBoneInfluencers: number;
  98222. _applyFog: boolean;
  98223. _receiveShadows: boolean;
  98224. _facetData: _FacetDataStorage;
  98225. _visibility: number;
  98226. _skeleton: Nullable<Skeleton>;
  98227. _layerMask: number;
  98228. _computeBonesUsingShaders: boolean;
  98229. _isActive: boolean;
  98230. _onlyForInstances: boolean;
  98231. _isActiveIntermediate: boolean;
  98232. _onlyForInstancesIntermediate: boolean;
  98233. _actAsRegularMesh: boolean;
  98234. }
  98235. /**
  98236. * Class used to store all common mesh properties
  98237. */
  98238. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98239. /** No occlusion */
  98240. static OCCLUSION_TYPE_NONE: number;
  98241. /** Occlusion set to optimisitic */
  98242. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98243. /** Occlusion set to strict */
  98244. static OCCLUSION_TYPE_STRICT: number;
  98245. /** Use an accurante occlusion algorithm */
  98246. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98247. /** Use a conservative occlusion algorithm */
  98248. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98249. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98250. * Test order :
  98251. * Is the bounding sphere outside the frustum ?
  98252. * If not, are the bounding box vertices outside the frustum ?
  98253. * It not, then the cullable object is in the frustum.
  98254. */
  98255. static readonly CULLINGSTRATEGY_STANDARD: number;
  98256. /** Culling strategy : Bounding Sphere Only.
  98257. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98258. * It's also less accurate than the standard because some not visible objects can still be selected.
  98259. * Test : is the bounding sphere outside the frustum ?
  98260. * If not, then the cullable object is in the frustum.
  98261. */
  98262. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98263. /** Culling strategy : Optimistic Inclusion.
  98264. * This in an inclusion test first, then the standard exclusion test.
  98265. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98266. * 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.
  98267. * Anyway, it's as accurate as the standard strategy.
  98268. * Test :
  98269. * Is the cullable object bounding sphere center in the frustum ?
  98270. * If not, apply the default culling strategy.
  98271. */
  98272. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98273. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98274. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98275. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98276. * 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.
  98277. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98278. * Test :
  98279. * Is the cullable object bounding sphere center in the frustum ?
  98280. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98281. */
  98282. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98283. /**
  98284. * No billboard
  98285. */
  98286. static get BILLBOARDMODE_NONE(): number;
  98287. /** Billboard on X axis */
  98288. static get BILLBOARDMODE_X(): number;
  98289. /** Billboard on Y axis */
  98290. static get BILLBOARDMODE_Y(): number;
  98291. /** Billboard on Z axis */
  98292. static get BILLBOARDMODE_Z(): number;
  98293. /** Billboard on all axes */
  98294. static get BILLBOARDMODE_ALL(): number;
  98295. /** Billboard on using position instead of orientation */
  98296. static get BILLBOARDMODE_USE_POSITION(): number;
  98297. /** @hidden */
  98298. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98299. /**
  98300. * The culling strategy to use to check whether the mesh must be rendered or not.
  98301. * This value can be changed at any time and will be used on the next render mesh selection.
  98302. * The possible values are :
  98303. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98304. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98306. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98307. * Please read each static variable documentation to get details about the culling process.
  98308. * */
  98309. cullingStrategy: number;
  98310. /**
  98311. * Gets the number of facets in the mesh
  98312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98313. */
  98314. get facetNb(): number;
  98315. /**
  98316. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98318. */
  98319. get partitioningSubdivisions(): number;
  98320. set partitioningSubdivisions(nb: number);
  98321. /**
  98322. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98323. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98325. */
  98326. get partitioningBBoxRatio(): number;
  98327. set partitioningBBoxRatio(ratio: number);
  98328. /**
  98329. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98330. * Works only for updatable meshes.
  98331. * Doesn't work with multi-materials
  98332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98333. */
  98334. get mustDepthSortFacets(): boolean;
  98335. set mustDepthSortFacets(sort: boolean);
  98336. /**
  98337. * The location (Vector3) where the facet depth sort must be computed from.
  98338. * By default, the active camera position.
  98339. * Used only when facet depth sort is enabled
  98340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98341. */
  98342. get facetDepthSortFrom(): Vector3;
  98343. set facetDepthSortFrom(location: Vector3);
  98344. /**
  98345. * gets a boolean indicating if facetData is enabled
  98346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98347. */
  98348. get isFacetDataEnabled(): boolean;
  98349. /** @hidden */
  98350. _updateNonUniformScalingState(value: boolean): boolean;
  98351. /**
  98352. * An event triggered when this mesh collides with another one
  98353. */
  98354. onCollideObservable: Observable<AbstractMesh>;
  98355. /** Set a function to call when this mesh collides with another one */
  98356. set onCollide(callback: () => void);
  98357. /**
  98358. * An event triggered when the collision's position changes
  98359. */
  98360. onCollisionPositionChangeObservable: Observable<Vector3>;
  98361. /** Set a function to call when the collision's position changes */
  98362. set onCollisionPositionChange(callback: () => void);
  98363. /**
  98364. * An event triggered when material is changed
  98365. */
  98366. onMaterialChangedObservable: Observable<AbstractMesh>;
  98367. /**
  98368. * Gets or sets the orientation for POV movement & rotation
  98369. */
  98370. definedFacingForward: boolean;
  98371. /** @hidden */
  98372. _occlusionQuery: Nullable<WebGLQuery>;
  98373. /** @hidden */
  98374. _renderingGroup: Nullable<RenderingGroup>;
  98375. /**
  98376. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98377. */
  98378. get visibility(): number;
  98379. /**
  98380. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98381. */
  98382. set visibility(value: number);
  98383. /** Gets or sets the alpha index used to sort transparent meshes
  98384. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98385. */
  98386. alphaIndex: number;
  98387. /**
  98388. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98389. */
  98390. isVisible: boolean;
  98391. /**
  98392. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98393. */
  98394. isPickable: boolean;
  98395. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98396. showSubMeshesBoundingBox: boolean;
  98397. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98398. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98399. */
  98400. isBlocker: boolean;
  98401. /**
  98402. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98403. */
  98404. enablePointerMoveEvents: boolean;
  98405. /**
  98406. * Specifies the rendering group id for this mesh (0 by default)
  98407. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98408. */
  98409. renderingGroupId: number;
  98410. private _material;
  98411. /** Gets or sets current material */
  98412. get material(): Nullable<Material>;
  98413. set material(value: Nullable<Material>);
  98414. /**
  98415. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98416. * @see http://doc.babylonjs.com/babylon101/shadows
  98417. */
  98418. get receiveShadows(): boolean;
  98419. set receiveShadows(value: boolean);
  98420. /** Defines color to use when rendering outline */
  98421. outlineColor: Color3;
  98422. /** Define width to use when rendering outline */
  98423. outlineWidth: number;
  98424. /** Defines color to use when rendering overlay */
  98425. overlayColor: Color3;
  98426. /** Defines alpha to use when rendering overlay */
  98427. overlayAlpha: number;
  98428. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98429. get hasVertexAlpha(): boolean;
  98430. set hasVertexAlpha(value: boolean);
  98431. /** 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) */
  98432. get useVertexColors(): boolean;
  98433. set useVertexColors(value: boolean);
  98434. /**
  98435. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98436. */
  98437. get computeBonesUsingShaders(): boolean;
  98438. set computeBonesUsingShaders(value: boolean);
  98439. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98440. get numBoneInfluencers(): number;
  98441. set numBoneInfluencers(value: number);
  98442. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98443. get applyFog(): boolean;
  98444. set applyFog(value: boolean);
  98445. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98446. useOctreeForRenderingSelection: boolean;
  98447. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98448. useOctreeForPicking: boolean;
  98449. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98450. useOctreeForCollisions: boolean;
  98451. /**
  98452. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98453. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98454. */
  98455. get layerMask(): number;
  98456. set layerMask(value: number);
  98457. /**
  98458. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98459. */
  98460. alwaysSelectAsActiveMesh: boolean;
  98461. /**
  98462. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98463. */
  98464. doNotSyncBoundingInfo: boolean;
  98465. /**
  98466. * Gets or sets the current action manager
  98467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98468. */
  98469. actionManager: Nullable<AbstractActionManager>;
  98470. private _meshCollisionData;
  98471. /**
  98472. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98473. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98474. */
  98475. ellipsoid: Vector3;
  98476. /**
  98477. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98479. */
  98480. ellipsoidOffset: Vector3;
  98481. /**
  98482. * Gets or sets a collision mask used to mask collisions (default is -1).
  98483. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98484. */
  98485. get collisionMask(): number;
  98486. set collisionMask(mask: number);
  98487. /**
  98488. * Gets or sets the current collision group mask (-1 by default).
  98489. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98490. */
  98491. get collisionGroup(): number;
  98492. set collisionGroup(mask: number);
  98493. /**
  98494. * Defines edge width used when edgesRenderer is enabled
  98495. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98496. */
  98497. edgesWidth: number;
  98498. /**
  98499. * Defines edge color used when edgesRenderer is enabled
  98500. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98501. */
  98502. edgesColor: Color4;
  98503. /** @hidden */
  98504. _edgesRenderer: Nullable<IEdgesRenderer>;
  98505. /** @hidden */
  98506. _masterMesh: Nullable<AbstractMesh>;
  98507. /** @hidden */
  98508. _boundingInfo: Nullable<BoundingInfo>;
  98509. /** @hidden */
  98510. _renderId: number;
  98511. /**
  98512. * Gets or sets the list of subMeshes
  98513. * @see http://doc.babylonjs.com/how_to/multi_materials
  98514. */
  98515. subMeshes: SubMesh[];
  98516. /** @hidden */
  98517. _intersectionsInProgress: AbstractMesh[];
  98518. /** @hidden */
  98519. _unIndexed: boolean;
  98520. /** @hidden */
  98521. _lightSources: Light[];
  98522. /** Gets the list of lights affecting that mesh */
  98523. get lightSources(): Light[];
  98524. /** @hidden */
  98525. get _positions(): Nullable<Vector3[]>;
  98526. /** @hidden */
  98527. _waitingData: {
  98528. lods: Nullable<any>;
  98529. actions: Nullable<any>;
  98530. freezeWorldMatrix: Nullable<boolean>;
  98531. };
  98532. /** @hidden */
  98533. _bonesTransformMatrices: Nullable<Float32Array>;
  98534. /** @hidden */
  98535. _transformMatrixTexture: Nullable<RawTexture>;
  98536. /**
  98537. * Gets or sets a skeleton to apply skining transformations
  98538. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98539. */
  98540. set skeleton(value: Nullable<Skeleton>);
  98541. get skeleton(): Nullable<Skeleton>;
  98542. /**
  98543. * An event triggered when the mesh is rebuilt.
  98544. */
  98545. onRebuildObservable: Observable<AbstractMesh>;
  98546. /**
  98547. * Creates a new AbstractMesh
  98548. * @param name defines the name of the mesh
  98549. * @param scene defines the hosting scene
  98550. */
  98551. constructor(name: string, scene?: Nullable<Scene>);
  98552. /**
  98553. * Returns the string "AbstractMesh"
  98554. * @returns "AbstractMesh"
  98555. */
  98556. getClassName(): string;
  98557. /**
  98558. * Gets a string representation of the current mesh
  98559. * @param fullDetails defines a boolean indicating if full details must be included
  98560. * @returns a string representation of the current mesh
  98561. */
  98562. toString(fullDetails?: boolean): string;
  98563. /**
  98564. * @hidden
  98565. */
  98566. protected _getEffectiveParent(): Nullable<Node>;
  98567. /** @hidden */
  98568. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98569. /** @hidden */
  98570. _rebuild(): void;
  98571. /** @hidden */
  98572. _resyncLightSources(): void;
  98573. /** @hidden */
  98574. _resyncLightSource(light: Light): void;
  98575. /** @hidden */
  98576. _unBindEffect(): void;
  98577. /** @hidden */
  98578. _removeLightSource(light: Light, dispose: boolean): void;
  98579. private _markSubMeshesAsDirty;
  98580. /** @hidden */
  98581. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98582. /** @hidden */
  98583. _markSubMeshesAsAttributesDirty(): void;
  98584. /** @hidden */
  98585. _markSubMeshesAsMiscDirty(): void;
  98586. /**
  98587. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98588. */
  98589. get scaling(): Vector3;
  98590. set scaling(newScaling: Vector3);
  98591. /**
  98592. * Returns true if the mesh is blocked. Implemented by child classes
  98593. */
  98594. get isBlocked(): boolean;
  98595. /**
  98596. * Returns the mesh itself by default. Implemented by child classes
  98597. * @param camera defines the camera to use to pick the right LOD level
  98598. * @returns the currentAbstractMesh
  98599. */
  98600. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98601. /**
  98602. * Returns 0 by default. Implemented by child classes
  98603. * @returns an integer
  98604. */
  98605. getTotalVertices(): number;
  98606. /**
  98607. * Returns a positive integer : the total number of indices in this mesh geometry.
  98608. * @returns the numner of indices or zero if the mesh has no geometry.
  98609. */
  98610. getTotalIndices(): number;
  98611. /**
  98612. * Returns null by default. Implemented by child classes
  98613. * @returns null
  98614. */
  98615. getIndices(): Nullable<IndicesArray>;
  98616. /**
  98617. * Returns the array of the requested vertex data kind. Implemented by child classes
  98618. * @param kind defines the vertex data kind to use
  98619. * @returns null
  98620. */
  98621. getVerticesData(kind: string): Nullable<FloatArray>;
  98622. /**
  98623. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98624. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98625. * Note that a new underlying VertexBuffer object is created each call.
  98626. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98627. * @param kind defines vertex data kind:
  98628. * * VertexBuffer.PositionKind
  98629. * * VertexBuffer.UVKind
  98630. * * VertexBuffer.UV2Kind
  98631. * * VertexBuffer.UV3Kind
  98632. * * VertexBuffer.UV4Kind
  98633. * * VertexBuffer.UV5Kind
  98634. * * VertexBuffer.UV6Kind
  98635. * * VertexBuffer.ColorKind
  98636. * * VertexBuffer.MatricesIndicesKind
  98637. * * VertexBuffer.MatricesIndicesExtraKind
  98638. * * VertexBuffer.MatricesWeightsKind
  98639. * * VertexBuffer.MatricesWeightsExtraKind
  98640. * @param data defines the data source
  98641. * @param updatable defines if the data must be flagged as updatable (or static)
  98642. * @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
  98643. * @returns the current mesh
  98644. */
  98645. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98646. /**
  98647. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98648. * If the mesh has no geometry, it is simply returned as it is.
  98649. * @param kind defines vertex data kind:
  98650. * * VertexBuffer.PositionKind
  98651. * * VertexBuffer.UVKind
  98652. * * VertexBuffer.UV2Kind
  98653. * * VertexBuffer.UV3Kind
  98654. * * VertexBuffer.UV4Kind
  98655. * * VertexBuffer.UV5Kind
  98656. * * VertexBuffer.UV6Kind
  98657. * * VertexBuffer.ColorKind
  98658. * * VertexBuffer.MatricesIndicesKind
  98659. * * VertexBuffer.MatricesIndicesExtraKind
  98660. * * VertexBuffer.MatricesWeightsKind
  98661. * * VertexBuffer.MatricesWeightsExtraKind
  98662. * @param data defines the data source
  98663. * @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
  98664. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98665. * @returns the current mesh
  98666. */
  98667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98668. /**
  98669. * Sets the mesh indices,
  98670. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98671. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98672. * @param totalVertices Defines the total number of vertices
  98673. * @returns the current mesh
  98674. */
  98675. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98676. /**
  98677. * Gets a boolean indicating if specific vertex data is present
  98678. * @param kind defines the vertex data kind to use
  98679. * @returns true is data kind is present
  98680. */
  98681. isVerticesDataPresent(kind: string): boolean;
  98682. /**
  98683. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98684. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98685. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98686. * @returns a BoundingInfo
  98687. */
  98688. getBoundingInfo(): BoundingInfo;
  98689. /**
  98690. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98691. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98692. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98693. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98694. * @returns the current mesh
  98695. */
  98696. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98697. /**
  98698. * Overwrite the current bounding info
  98699. * @param boundingInfo defines the new bounding info
  98700. * @returns the current mesh
  98701. */
  98702. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98703. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98704. get useBones(): boolean;
  98705. /** @hidden */
  98706. _preActivate(): void;
  98707. /** @hidden */
  98708. _preActivateForIntermediateRendering(renderId: number): void;
  98709. /** @hidden */
  98710. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98711. /** @hidden */
  98712. _postActivate(): void;
  98713. /** @hidden */
  98714. _freeze(): void;
  98715. /** @hidden */
  98716. _unFreeze(): void;
  98717. /**
  98718. * Gets the current world matrix
  98719. * @returns a Matrix
  98720. */
  98721. getWorldMatrix(): Matrix;
  98722. /** @hidden */
  98723. _getWorldMatrixDeterminant(): number;
  98724. /**
  98725. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98726. */
  98727. get isAnInstance(): boolean;
  98728. /**
  98729. * Gets a boolean indicating if this mesh has instances
  98730. */
  98731. get hasInstances(): boolean;
  98732. /**
  98733. * Perform relative position change from the point of view of behind the front of the mesh.
  98734. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98735. * Supports definition of mesh facing forward or backward
  98736. * @param amountRight defines the distance on the right axis
  98737. * @param amountUp defines the distance on the up axis
  98738. * @param amountForward defines the distance on the forward axis
  98739. * @returns the current mesh
  98740. */
  98741. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98742. /**
  98743. * Calculate relative position change from the point of view of behind the front of the mesh.
  98744. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98745. * Supports definition of mesh facing forward or backward
  98746. * @param amountRight defines the distance on the right axis
  98747. * @param amountUp defines the distance on the up axis
  98748. * @param amountForward defines the distance on the forward axis
  98749. * @returns the new displacement vector
  98750. */
  98751. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98752. /**
  98753. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98754. * Supports definition of mesh facing forward or backward
  98755. * @param flipBack defines the flip
  98756. * @param twirlClockwise defines the twirl
  98757. * @param tiltRight defines the tilt
  98758. * @returns the current mesh
  98759. */
  98760. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98761. /**
  98762. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98763. * Supports definition of mesh facing forward or backward.
  98764. * @param flipBack defines the flip
  98765. * @param twirlClockwise defines the twirl
  98766. * @param tiltRight defines the tilt
  98767. * @returns the new rotation vector
  98768. */
  98769. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98770. /**
  98771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98772. * This means the mesh underlying bounding box and sphere are recomputed.
  98773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98774. * @returns the current mesh
  98775. */
  98776. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98777. /** @hidden */
  98778. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98779. /** @hidden */
  98780. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98781. /** @hidden */
  98782. _updateBoundingInfo(): AbstractMesh;
  98783. /** @hidden */
  98784. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98785. /** @hidden */
  98786. protected _afterComputeWorldMatrix(): void;
  98787. /** @hidden */
  98788. get _effectiveMesh(): AbstractMesh;
  98789. /**
  98790. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98791. * A mesh is in the frustum if its bounding box intersects the frustum
  98792. * @param frustumPlanes defines the frustum to test
  98793. * @returns true if the mesh is in the frustum planes
  98794. */
  98795. isInFrustum(frustumPlanes: Plane[]): boolean;
  98796. /**
  98797. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98798. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98799. * @param frustumPlanes defines the frustum to test
  98800. * @returns true if the mesh is completely in the frustum planes
  98801. */
  98802. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98803. /**
  98804. * True if the mesh intersects another mesh or a SolidParticle object
  98805. * @param mesh defines a target mesh or SolidParticle to test
  98806. * @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)
  98807. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98808. * @returns true if there is an intersection
  98809. */
  98810. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98811. /**
  98812. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98813. * @param point defines the point to test
  98814. * @returns true if there is an intersection
  98815. */
  98816. intersectsPoint(point: Vector3): boolean;
  98817. /**
  98818. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98819. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98820. */
  98821. get checkCollisions(): boolean;
  98822. set checkCollisions(collisionEnabled: boolean);
  98823. /**
  98824. * Gets Collider object used to compute collisions (not physics)
  98825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98826. */
  98827. get collider(): Nullable<Collider>;
  98828. /**
  98829. * Move the mesh using collision engine
  98830. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98831. * @param displacement defines the requested displacement vector
  98832. * @returns the current mesh
  98833. */
  98834. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98835. private _onCollisionPositionChange;
  98836. /** @hidden */
  98837. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98838. /** @hidden */
  98839. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98840. /** @hidden */
  98841. _checkCollision(collider: Collider): AbstractMesh;
  98842. /** @hidden */
  98843. _generatePointsArray(): boolean;
  98844. /**
  98845. * Checks if the passed Ray intersects with the mesh
  98846. * @param ray defines the ray to use
  98847. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98848. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98849. * @returns the picking info
  98850. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98851. */
  98852. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98853. /**
  98854. * Clones the current mesh
  98855. * @param name defines the mesh name
  98856. * @param newParent defines the new mesh parent
  98857. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98858. * @returns the new mesh
  98859. */
  98860. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98861. /**
  98862. * Disposes all the submeshes of the current meshnp
  98863. * @returns the current mesh
  98864. */
  98865. releaseSubMeshes(): AbstractMesh;
  98866. /**
  98867. * Releases resources associated with this abstract mesh.
  98868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98870. */
  98871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98872. /**
  98873. * Adds the passed mesh as a child to the current mesh
  98874. * @param mesh defines the child mesh
  98875. * @returns the current mesh
  98876. */
  98877. addChild(mesh: AbstractMesh): AbstractMesh;
  98878. /**
  98879. * Removes the passed mesh from the current mesh children list
  98880. * @param mesh defines the child mesh
  98881. * @returns the current mesh
  98882. */
  98883. removeChild(mesh: AbstractMesh): AbstractMesh;
  98884. /** @hidden */
  98885. private _initFacetData;
  98886. /**
  98887. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98888. * This method can be called within the render loop.
  98889. * 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
  98890. * @returns the current mesh
  98891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98892. */
  98893. updateFacetData(): AbstractMesh;
  98894. /**
  98895. * Returns the facetLocalNormals array.
  98896. * The normals are expressed in the mesh local spac
  98897. * @returns an array of Vector3
  98898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98899. */
  98900. getFacetLocalNormals(): Vector3[];
  98901. /**
  98902. * Returns the facetLocalPositions array.
  98903. * The facet positions are expressed in the mesh local space
  98904. * @returns an array of Vector3
  98905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98906. */
  98907. getFacetLocalPositions(): Vector3[];
  98908. /**
  98909. * Returns the facetLocalPartioning array
  98910. * @returns an array of array of numbers
  98911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98912. */
  98913. getFacetLocalPartitioning(): number[][];
  98914. /**
  98915. * Returns the i-th facet position in the world system.
  98916. * This method allocates a new Vector3 per call
  98917. * @param i defines the facet index
  98918. * @returns a new Vector3
  98919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98920. */
  98921. getFacetPosition(i: number): Vector3;
  98922. /**
  98923. * Sets the reference Vector3 with the i-th facet position in the world system
  98924. * @param i defines the facet index
  98925. * @param ref defines the target vector
  98926. * @returns the current mesh
  98927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98928. */
  98929. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98930. /**
  98931. * Returns the i-th facet normal in the world system.
  98932. * This method allocates a new Vector3 per call
  98933. * @param i defines the facet index
  98934. * @returns a new Vector3
  98935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98936. */
  98937. getFacetNormal(i: number): Vector3;
  98938. /**
  98939. * Sets the reference Vector3 with the i-th facet normal in the world system
  98940. * @param i defines the facet index
  98941. * @param ref defines the target vector
  98942. * @returns the current mesh
  98943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98944. */
  98945. getFacetNormalToRef(i: number, ref: Vector3): this;
  98946. /**
  98947. * 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)
  98948. * @param x defines x coordinate
  98949. * @param y defines y coordinate
  98950. * @param z defines z coordinate
  98951. * @returns the array of facet indexes
  98952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98953. */
  98954. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98955. /**
  98956. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98957. * @param projected sets as the (x,y,z) world projection on the facet
  98958. * @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
  98959. * @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
  98960. * @param x defines x coordinate
  98961. * @param y defines y coordinate
  98962. * @param z defines z coordinate
  98963. * @returns the face index if found (or null instead)
  98964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98965. */
  98966. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98967. /**
  98968. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98969. * @param projected sets as the (x,y,z) local projection on the facet
  98970. * @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
  98971. * @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
  98972. * @param x defines x coordinate
  98973. * @param y defines y coordinate
  98974. * @param z defines z coordinate
  98975. * @returns the face index if found (or null instead)
  98976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98977. */
  98978. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98979. /**
  98980. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98981. * @returns the parameters
  98982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98983. */
  98984. getFacetDataParameters(): any;
  98985. /**
  98986. * Disables the feature FacetData and frees the related memory
  98987. * @returns the current mesh
  98988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98989. */
  98990. disableFacetData(): AbstractMesh;
  98991. /**
  98992. * Updates the AbstractMesh indices array
  98993. * @param indices defines the data source
  98994. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98995. * @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)
  98996. * @returns the current mesh
  98997. */
  98998. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98999. /**
  99000. * Creates new normals data for the mesh
  99001. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  99002. * @returns the current mesh
  99003. */
  99004. createNormals(updatable: boolean): AbstractMesh;
  99005. /**
  99006. * Align the mesh with a normal
  99007. * @param normal defines the normal to use
  99008. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  99009. * @returns the current mesh
  99010. */
  99011. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  99012. /** @hidden */
  99013. _checkOcclusionQuery(): boolean;
  99014. /**
  99015. * Disables the mesh edge rendering mode
  99016. * @returns the currentAbstractMesh
  99017. */
  99018. disableEdgesRendering(): AbstractMesh;
  99019. /**
  99020. * Enables the edge rendering mode on the mesh.
  99021. * This mode makes the mesh edges visible
  99022. * @param epsilon defines the maximal distance between two angles to detect a face
  99023. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  99024. * @returns the currentAbstractMesh
  99025. * @see https://www.babylonjs-playground.com/#19O9TU#0
  99026. */
  99027. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  99028. }
  99029. }
  99030. declare module BABYLON {
  99031. /**
  99032. * Interface used to define ActionEvent
  99033. */
  99034. export interface IActionEvent {
  99035. /** The mesh or sprite that triggered the action */
  99036. source: any;
  99037. /** The X mouse cursor position at the time of the event */
  99038. pointerX: number;
  99039. /** The Y mouse cursor position at the time of the event */
  99040. pointerY: number;
  99041. /** The mesh that is currently pointed at (can be null) */
  99042. meshUnderPointer: Nullable<AbstractMesh>;
  99043. /** the original (browser) event that triggered the ActionEvent */
  99044. sourceEvent?: any;
  99045. /** additional data for the event */
  99046. additionalData?: any;
  99047. }
  99048. /**
  99049. * ActionEvent is the event being sent when an action is triggered.
  99050. */
  99051. export class ActionEvent implements IActionEvent {
  99052. /** The mesh or sprite that triggered the action */
  99053. source: any;
  99054. /** The X mouse cursor position at the time of the event */
  99055. pointerX: number;
  99056. /** The Y mouse cursor position at the time of the event */
  99057. pointerY: number;
  99058. /** The mesh that is currently pointed at (can be null) */
  99059. meshUnderPointer: Nullable<AbstractMesh>;
  99060. /** the original (browser) event that triggered the ActionEvent */
  99061. sourceEvent?: any;
  99062. /** additional data for the event */
  99063. additionalData?: any;
  99064. /**
  99065. * Creates a new ActionEvent
  99066. * @param source The mesh or sprite that triggered the action
  99067. * @param pointerX The X mouse cursor position at the time of the event
  99068. * @param pointerY The Y mouse cursor position at the time of the event
  99069. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99070. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99071. * @param additionalData additional data for the event
  99072. */
  99073. constructor(
  99074. /** The mesh or sprite that triggered the action */
  99075. source: any,
  99076. /** The X mouse cursor position at the time of the event */
  99077. pointerX: number,
  99078. /** The Y mouse cursor position at the time of the event */
  99079. pointerY: number,
  99080. /** The mesh that is currently pointed at (can be null) */
  99081. meshUnderPointer: Nullable<AbstractMesh>,
  99082. /** the original (browser) event that triggered the ActionEvent */
  99083. sourceEvent?: any,
  99084. /** additional data for the event */
  99085. additionalData?: any);
  99086. /**
  99087. * Helper function to auto-create an ActionEvent from a source mesh.
  99088. * @param source The source mesh that triggered the event
  99089. * @param evt The original (browser) event
  99090. * @param additionalData additional data for the event
  99091. * @returns the new ActionEvent
  99092. */
  99093. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99094. /**
  99095. * Helper function to auto-create an ActionEvent from a source sprite
  99096. * @param source The source sprite that triggered the event
  99097. * @param scene Scene associated with the sprite
  99098. * @param evt The original (browser) event
  99099. * @param additionalData additional data for the event
  99100. * @returns the new ActionEvent
  99101. */
  99102. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99103. /**
  99104. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99105. * @param scene the scene where the event occurred
  99106. * @param evt The original (browser) event
  99107. * @returns the new ActionEvent
  99108. */
  99109. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99110. /**
  99111. * Helper function to auto-create an ActionEvent from a primitive
  99112. * @param prim defines the target primitive
  99113. * @param pointerPos defines the pointer position
  99114. * @param evt The original (browser) event
  99115. * @param additionalData additional data for the event
  99116. * @returns the new ActionEvent
  99117. */
  99118. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99119. }
  99120. }
  99121. declare module BABYLON {
  99122. /**
  99123. * Abstract class used to decouple action Manager from scene and meshes.
  99124. * Do not instantiate.
  99125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99126. */
  99127. export abstract class AbstractActionManager implements IDisposable {
  99128. /** Gets the list of active triggers */
  99129. static Triggers: {
  99130. [key: string]: number;
  99131. };
  99132. /** Gets the cursor to use when hovering items */
  99133. hoverCursor: string;
  99134. /** Gets the list of actions */
  99135. actions: IAction[];
  99136. /**
  99137. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99138. */
  99139. isRecursive: boolean;
  99140. /**
  99141. * Releases all associated resources
  99142. */
  99143. abstract dispose(): void;
  99144. /**
  99145. * Does this action manager has pointer triggers
  99146. */
  99147. abstract get hasPointerTriggers(): boolean;
  99148. /**
  99149. * Does this action manager has pick triggers
  99150. */
  99151. abstract get hasPickTriggers(): boolean;
  99152. /**
  99153. * Process a specific trigger
  99154. * @param trigger defines the trigger to process
  99155. * @param evt defines the event details to be processed
  99156. */
  99157. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99158. /**
  99159. * Does this action manager handles actions of any of the given triggers
  99160. * @param triggers defines the triggers to be tested
  99161. * @return a boolean indicating whether one (or more) of the triggers is handled
  99162. */
  99163. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99164. /**
  99165. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99166. * speed.
  99167. * @param triggerA defines the trigger to be tested
  99168. * @param triggerB defines the trigger to be tested
  99169. * @return a boolean indicating whether one (or more) of the triggers is handled
  99170. */
  99171. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99172. /**
  99173. * Does this action manager handles actions of a given trigger
  99174. * @param trigger defines the trigger to be tested
  99175. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99176. * @return whether the trigger is handled
  99177. */
  99178. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99179. /**
  99180. * Serialize this manager to a JSON object
  99181. * @param name defines the property name to store this manager
  99182. * @returns a JSON representation of this manager
  99183. */
  99184. abstract serialize(name: string): any;
  99185. /**
  99186. * Registers an action to this action manager
  99187. * @param action defines the action to be registered
  99188. * @return the action amended (prepared) after registration
  99189. */
  99190. abstract registerAction(action: IAction): Nullable<IAction>;
  99191. /**
  99192. * Unregisters an action to this action manager
  99193. * @param action defines the action to be unregistered
  99194. * @return a boolean indicating whether the action has been unregistered
  99195. */
  99196. abstract unregisterAction(action: IAction): Boolean;
  99197. /**
  99198. * Does exist one action manager with at least one trigger
  99199. **/
  99200. static get HasTriggers(): boolean;
  99201. /**
  99202. * Does exist one action manager with at least one pick trigger
  99203. **/
  99204. static get HasPickTriggers(): boolean;
  99205. /**
  99206. * Does exist one action manager that handles actions of a given trigger
  99207. * @param trigger defines the trigger to be tested
  99208. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99209. **/
  99210. static HasSpecificTrigger(trigger: number): boolean;
  99211. }
  99212. }
  99213. declare module BABYLON {
  99214. /**
  99215. * Defines how a node can be built from a string name.
  99216. */
  99217. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99218. /**
  99219. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99220. */
  99221. export class Node implements IBehaviorAware<Node> {
  99222. /** @hidden */
  99223. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99224. private static _NodeConstructors;
  99225. /**
  99226. * Add a new node constructor
  99227. * @param type defines the type name of the node to construct
  99228. * @param constructorFunc defines the constructor function
  99229. */
  99230. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99231. /**
  99232. * Returns a node constructor based on type name
  99233. * @param type defines the type name
  99234. * @param name defines the new node name
  99235. * @param scene defines the hosting scene
  99236. * @param options defines optional options to transmit to constructors
  99237. * @returns the new constructor or null
  99238. */
  99239. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99240. /**
  99241. * Gets or sets the name of the node
  99242. */
  99243. name: string;
  99244. /**
  99245. * Gets or sets the id of the node
  99246. */
  99247. id: string;
  99248. /**
  99249. * Gets or sets the unique id of the node
  99250. */
  99251. uniqueId: number;
  99252. /**
  99253. * Gets or sets a string used to store user defined state for the node
  99254. */
  99255. state: string;
  99256. /**
  99257. * Gets or sets an object used to store user defined information for the node
  99258. */
  99259. metadata: any;
  99260. /**
  99261. * For internal use only. Please do not use.
  99262. */
  99263. reservedDataStore: any;
  99264. /**
  99265. * List of inspectable custom properties (used by the Inspector)
  99266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99267. */
  99268. inspectableCustomProperties: IInspectable[];
  99269. private _doNotSerialize;
  99270. /**
  99271. * Gets or sets a boolean used to define if the node must be serialized
  99272. */
  99273. get doNotSerialize(): boolean;
  99274. set doNotSerialize(value: boolean);
  99275. /** @hidden */
  99276. _isDisposed: boolean;
  99277. /**
  99278. * Gets a list of Animations associated with the node
  99279. */
  99280. animations: Animation[];
  99281. protected _ranges: {
  99282. [name: string]: Nullable<AnimationRange>;
  99283. };
  99284. /**
  99285. * Callback raised when the node is ready to be used
  99286. */
  99287. onReady: Nullable<(node: Node) => void>;
  99288. private _isEnabled;
  99289. private _isParentEnabled;
  99290. private _isReady;
  99291. /** @hidden */
  99292. _currentRenderId: number;
  99293. private _parentUpdateId;
  99294. /** @hidden */
  99295. _childUpdateId: number;
  99296. /** @hidden */
  99297. _waitingParentId: Nullable<string>;
  99298. /** @hidden */
  99299. _scene: Scene;
  99300. /** @hidden */
  99301. _cache: any;
  99302. private _parentNode;
  99303. private _children;
  99304. /** @hidden */
  99305. _worldMatrix: Matrix;
  99306. /** @hidden */
  99307. _worldMatrixDeterminant: number;
  99308. /** @hidden */
  99309. _worldMatrixDeterminantIsDirty: boolean;
  99310. /** @hidden */
  99311. private _sceneRootNodesIndex;
  99312. /**
  99313. * Gets a boolean indicating if the node has been disposed
  99314. * @returns true if the node was disposed
  99315. */
  99316. isDisposed(): boolean;
  99317. /**
  99318. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99319. * @see https://doc.babylonjs.com/how_to/parenting
  99320. */
  99321. set parent(parent: Nullable<Node>);
  99322. get parent(): Nullable<Node>;
  99323. /** @hidden */
  99324. _addToSceneRootNodes(): void;
  99325. /** @hidden */
  99326. _removeFromSceneRootNodes(): void;
  99327. private _animationPropertiesOverride;
  99328. /**
  99329. * Gets or sets the animation properties override
  99330. */
  99331. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99332. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99333. /**
  99334. * Gets a string idenfifying the name of the class
  99335. * @returns "Node" string
  99336. */
  99337. getClassName(): string;
  99338. /** @hidden */
  99339. readonly _isNode: boolean;
  99340. /**
  99341. * An event triggered when the mesh is disposed
  99342. */
  99343. onDisposeObservable: Observable<Node>;
  99344. private _onDisposeObserver;
  99345. /**
  99346. * Sets a callback that will be raised when the node will be disposed
  99347. */
  99348. set onDispose(callback: () => void);
  99349. /**
  99350. * Creates a new Node
  99351. * @param name the name and id to be given to this node
  99352. * @param scene the scene this node will be added to
  99353. */
  99354. constructor(name: string, scene?: Nullable<Scene>);
  99355. /**
  99356. * Gets the scene of the node
  99357. * @returns a scene
  99358. */
  99359. getScene(): Scene;
  99360. /**
  99361. * Gets the engine of the node
  99362. * @returns a Engine
  99363. */
  99364. getEngine(): Engine;
  99365. private _behaviors;
  99366. /**
  99367. * Attach a behavior to the node
  99368. * @see http://doc.babylonjs.com/features/behaviour
  99369. * @param behavior defines the behavior to attach
  99370. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99371. * @returns the current Node
  99372. */
  99373. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99374. /**
  99375. * Remove an attached behavior
  99376. * @see http://doc.babylonjs.com/features/behaviour
  99377. * @param behavior defines the behavior to attach
  99378. * @returns the current Node
  99379. */
  99380. removeBehavior(behavior: Behavior<Node>): Node;
  99381. /**
  99382. * Gets the list of attached behaviors
  99383. * @see http://doc.babylonjs.com/features/behaviour
  99384. */
  99385. get behaviors(): Behavior<Node>[];
  99386. /**
  99387. * Gets an attached behavior by name
  99388. * @param name defines the name of the behavior to look for
  99389. * @see http://doc.babylonjs.com/features/behaviour
  99390. * @returns null if behavior was not found else the requested behavior
  99391. */
  99392. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99393. /**
  99394. * Returns the latest update of the World matrix
  99395. * @returns a Matrix
  99396. */
  99397. getWorldMatrix(): Matrix;
  99398. /** @hidden */
  99399. _getWorldMatrixDeterminant(): number;
  99400. /**
  99401. * Returns directly the latest state of the mesh World matrix.
  99402. * A Matrix is returned.
  99403. */
  99404. get worldMatrixFromCache(): Matrix;
  99405. /** @hidden */
  99406. _initCache(): void;
  99407. /** @hidden */
  99408. updateCache(force?: boolean): void;
  99409. /** @hidden */
  99410. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99411. /** @hidden */
  99412. _updateCache(ignoreParentClass?: boolean): void;
  99413. /** @hidden */
  99414. _isSynchronized(): boolean;
  99415. /** @hidden */
  99416. _markSyncedWithParent(): void;
  99417. /** @hidden */
  99418. isSynchronizedWithParent(): boolean;
  99419. /** @hidden */
  99420. isSynchronized(): boolean;
  99421. /**
  99422. * Is this node ready to be used/rendered
  99423. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99424. * @return true if the node is ready
  99425. */
  99426. isReady(completeCheck?: boolean): boolean;
  99427. /**
  99428. * Is this node enabled?
  99429. * 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
  99430. * @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
  99431. * @return whether this node (and its parent) is enabled
  99432. */
  99433. isEnabled(checkAncestors?: boolean): boolean;
  99434. /** @hidden */
  99435. protected _syncParentEnabledState(): void;
  99436. /**
  99437. * Set the enabled state of this node
  99438. * @param value defines the new enabled state
  99439. */
  99440. setEnabled(value: boolean): void;
  99441. /**
  99442. * Is this node a descendant of the given node?
  99443. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99444. * @param ancestor defines the parent node to inspect
  99445. * @returns a boolean indicating if this node is a descendant of the given node
  99446. */
  99447. isDescendantOf(ancestor: Node): boolean;
  99448. /** @hidden */
  99449. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99450. /**
  99451. * Will return all nodes that have this node as ascendant
  99452. * @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
  99453. * @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
  99454. * @return all children nodes of all types
  99455. */
  99456. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99457. /**
  99458. * Get all child-meshes of this node
  99459. * @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)
  99460. * @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
  99461. * @returns an array of AbstractMesh
  99462. */
  99463. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99464. /**
  99465. * Get all direct children of this node
  99466. * @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
  99467. * @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)
  99468. * @returns an array of Node
  99469. */
  99470. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99471. /** @hidden */
  99472. _setReady(state: boolean): void;
  99473. /**
  99474. * Get an animation by name
  99475. * @param name defines the name of the animation to look for
  99476. * @returns null if not found else the requested animation
  99477. */
  99478. getAnimationByName(name: string): Nullable<Animation>;
  99479. /**
  99480. * Creates an animation range for this node
  99481. * @param name defines the name of the range
  99482. * @param from defines the starting key
  99483. * @param to defines the end key
  99484. */
  99485. createAnimationRange(name: string, from: number, to: number): void;
  99486. /**
  99487. * Delete a specific animation range
  99488. * @param name defines the name of the range to delete
  99489. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99490. */
  99491. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99492. /**
  99493. * Get an animation range by name
  99494. * @param name defines the name of the animation range to look for
  99495. * @returns null if not found else the requested animation range
  99496. */
  99497. getAnimationRange(name: string): Nullable<AnimationRange>;
  99498. /**
  99499. * Gets the list of all animation ranges defined on this node
  99500. * @returns an array
  99501. */
  99502. getAnimationRanges(): Nullable<AnimationRange>[];
  99503. /**
  99504. * Will start the animation sequence
  99505. * @param name defines the range frames for animation sequence
  99506. * @param loop defines if the animation should loop (false by default)
  99507. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99508. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99509. * @returns the object created for this animation. If range does not exist, it will return null
  99510. */
  99511. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99512. /**
  99513. * Serialize animation ranges into a JSON compatible object
  99514. * @returns serialization object
  99515. */
  99516. serializeAnimationRanges(): any;
  99517. /**
  99518. * Computes the world matrix of the node
  99519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99520. * @returns the world matrix
  99521. */
  99522. computeWorldMatrix(force?: boolean): Matrix;
  99523. /**
  99524. * Releases resources associated with this node.
  99525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99527. */
  99528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99529. /**
  99530. * Parse animation range data from a serialization object and store them into a given node
  99531. * @param node defines where to store the animation ranges
  99532. * @param parsedNode defines the serialization object to read data from
  99533. * @param scene defines the hosting scene
  99534. */
  99535. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99536. /**
  99537. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99538. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99539. * @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
  99540. * @returns the new bounding vectors
  99541. */
  99542. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99543. min: Vector3;
  99544. max: Vector3;
  99545. };
  99546. }
  99547. }
  99548. declare module BABYLON {
  99549. /**
  99550. * @hidden
  99551. */
  99552. export class _IAnimationState {
  99553. key: number;
  99554. repeatCount: number;
  99555. workValue?: any;
  99556. loopMode?: number;
  99557. offsetValue?: any;
  99558. highLimitValue?: any;
  99559. }
  99560. /**
  99561. * Class used to store any kind of animation
  99562. */
  99563. export class Animation {
  99564. /**Name of the animation */
  99565. name: string;
  99566. /**Property to animate */
  99567. targetProperty: string;
  99568. /**The frames per second of the animation */
  99569. framePerSecond: number;
  99570. /**The data type of the animation */
  99571. dataType: number;
  99572. /**The loop mode of the animation */
  99573. loopMode?: number | undefined;
  99574. /**Specifies if blending should be enabled */
  99575. enableBlending?: boolean | undefined;
  99576. /**
  99577. * Use matrix interpolation instead of using direct key value when animating matrices
  99578. */
  99579. static AllowMatricesInterpolation: boolean;
  99580. /**
  99581. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99582. */
  99583. static AllowMatrixDecomposeForInterpolation: boolean;
  99584. /**
  99585. * Stores the key frames of the animation
  99586. */
  99587. private _keys;
  99588. /**
  99589. * Stores the easing function of the animation
  99590. */
  99591. private _easingFunction;
  99592. /**
  99593. * @hidden Internal use only
  99594. */
  99595. _runtimeAnimations: RuntimeAnimation[];
  99596. /**
  99597. * The set of event that will be linked to this animation
  99598. */
  99599. private _events;
  99600. /**
  99601. * Stores an array of target property paths
  99602. */
  99603. targetPropertyPath: string[];
  99604. /**
  99605. * Stores the blending speed of the animation
  99606. */
  99607. blendingSpeed: number;
  99608. /**
  99609. * Stores the animation ranges for the animation
  99610. */
  99611. private _ranges;
  99612. /**
  99613. * @hidden Internal use
  99614. */
  99615. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99616. /**
  99617. * Sets up an animation
  99618. * @param property The property to animate
  99619. * @param animationType The animation type to apply
  99620. * @param framePerSecond The frames per second of the animation
  99621. * @param easingFunction The easing function used in the animation
  99622. * @returns The created animation
  99623. */
  99624. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99625. /**
  99626. * Create and start an animation on a node
  99627. * @param name defines the name of the global animation that will be run on all nodes
  99628. * @param node defines the root node where the animation will take place
  99629. * @param targetProperty defines property to animate
  99630. * @param framePerSecond defines the number of frame per second yo use
  99631. * @param totalFrame defines the number of frames in total
  99632. * @param from defines the initial value
  99633. * @param to defines the final value
  99634. * @param loopMode defines which loop mode you want to use (off by default)
  99635. * @param easingFunction defines the easing function to use (linear by default)
  99636. * @param onAnimationEnd defines the callback to call when animation end
  99637. * @returns the animatable created for this animation
  99638. */
  99639. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99640. /**
  99641. * Create and start an animation on a node and its descendants
  99642. * @param name defines the name of the global animation that will be run on all nodes
  99643. * @param node defines the root node where the animation will take place
  99644. * @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
  99645. * @param targetProperty defines property to animate
  99646. * @param framePerSecond defines the number of frame per second to use
  99647. * @param totalFrame defines the number of frames in total
  99648. * @param from defines the initial value
  99649. * @param to defines the final value
  99650. * @param loopMode defines which loop mode you want to use (off by default)
  99651. * @param easingFunction defines the easing function to use (linear by default)
  99652. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99653. * @returns the list of animatables created for all nodes
  99654. * @example https://www.babylonjs-playground.com/#MH0VLI
  99655. */
  99656. 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[]>;
  99657. /**
  99658. * Creates a new animation, merges it with the existing animations and starts it
  99659. * @param name Name of the animation
  99660. * @param node Node which contains the scene that begins the animations
  99661. * @param targetProperty Specifies which property to animate
  99662. * @param framePerSecond The frames per second of the animation
  99663. * @param totalFrame The total number of frames
  99664. * @param from The frame at the beginning of the animation
  99665. * @param to The frame at the end of the animation
  99666. * @param loopMode Specifies the loop mode of the animation
  99667. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99668. * @param onAnimationEnd Callback to run once the animation is complete
  99669. * @returns Nullable animation
  99670. */
  99671. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99672. /**
  99673. * Transition property of an host to the target Value
  99674. * @param property The property to transition
  99675. * @param targetValue The target Value of the property
  99676. * @param host The object where the property to animate belongs
  99677. * @param scene Scene used to run the animation
  99678. * @param frameRate Framerate (in frame/s) to use
  99679. * @param transition The transition type we want to use
  99680. * @param duration The duration of the animation, in milliseconds
  99681. * @param onAnimationEnd Callback trigger at the end of the animation
  99682. * @returns Nullable animation
  99683. */
  99684. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99685. /**
  99686. * Return the array of runtime animations currently using this animation
  99687. */
  99688. get runtimeAnimations(): RuntimeAnimation[];
  99689. /**
  99690. * Specifies if any of the runtime animations are currently running
  99691. */
  99692. get hasRunningRuntimeAnimations(): boolean;
  99693. /**
  99694. * Initializes the animation
  99695. * @param name Name of the animation
  99696. * @param targetProperty Property to animate
  99697. * @param framePerSecond The frames per second of the animation
  99698. * @param dataType The data type of the animation
  99699. * @param loopMode The loop mode of the animation
  99700. * @param enableBlending Specifies if blending should be enabled
  99701. */
  99702. constructor(
  99703. /**Name of the animation */
  99704. name: string,
  99705. /**Property to animate */
  99706. targetProperty: string,
  99707. /**The frames per second of the animation */
  99708. framePerSecond: number,
  99709. /**The data type of the animation */
  99710. dataType: number,
  99711. /**The loop mode of the animation */
  99712. loopMode?: number | undefined,
  99713. /**Specifies if blending should be enabled */
  99714. enableBlending?: boolean | undefined);
  99715. /**
  99716. * Converts the animation to a string
  99717. * @param fullDetails support for multiple levels of logging within scene loading
  99718. * @returns String form of the animation
  99719. */
  99720. toString(fullDetails?: boolean): string;
  99721. /**
  99722. * Add an event to this animation
  99723. * @param event Event to add
  99724. */
  99725. addEvent(event: AnimationEvent): void;
  99726. /**
  99727. * Remove all events found at the given frame
  99728. * @param frame The frame to remove events from
  99729. */
  99730. removeEvents(frame: number): void;
  99731. /**
  99732. * Retrieves all the events from the animation
  99733. * @returns Events from the animation
  99734. */
  99735. getEvents(): AnimationEvent[];
  99736. /**
  99737. * Creates an animation range
  99738. * @param name Name of the animation range
  99739. * @param from Starting frame of the animation range
  99740. * @param to Ending frame of the animation
  99741. */
  99742. createRange(name: string, from: number, to: number): void;
  99743. /**
  99744. * Deletes an animation range by name
  99745. * @param name Name of the animation range to delete
  99746. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99747. */
  99748. deleteRange(name: string, deleteFrames?: boolean): void;
  99749. /**
  99750. * Gets the animation range by name, or null if not defined
  99751. * @param name Name of the animation range
  99752. * @returns Nullable animation range
  99753. */
  99754. getRange(name: string): Nullable<AnimationRange>;
  99755. /**
  99756. * Gets the key frames from the animation
  99757. * @returns The key frames of the animation
  99758. */
  99759. getKeys(): Array<IAnimationKey>;
  99760. /**
  99761. * Gets the highest frame rate of the animation
  99762. * @returns Highest frame rate of the animation
  99763. */
  99764. getHighestFrame(): number;
  99765. /**
  99766. * Gets the easing function of the animation
  99767. * @returns Easing function of the animation
  99768. */
  99769. getEasingFunction(): IEasingFunction;
  99770. /**
  99771. * Sets the easing function of the animation
  99772. * @param easingFunction A custom mathematical formula for animation
  99773. */
  99774. setEasingFunction(easingFunction: EasingFunction): void;
  99775. /**
  99776. * Interpolates a scalar linearly
  99777. * @param startValue Start value of the animation curve
  99778. * @param endValue End value of the animation curve
  99779. * @param gradient Scalar amount to interpolate
  99780. * @returns Interpolated scalar value
  99781. */
  99782. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99783. /**
  99784. * Interpolates a scalar cubically
  99785. * @param startValue Start value of the animation curve
  99786. * @param outTangent End tangent of the animation
  99787. * @param endValue End value of the animation curve
  99788. * @param inTangent Start tangent of the animation curve
  99789. * @param gradient Scalar amount to interpolate
  99790. * @returns Interpolated scalar value
  99791. */
  99792. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99793. /**
  99794. * Interpolates a quaternion using a spherical linear interpolation
  99795. * @param startValue Start value of the animation curve
  99796. * @param endValue End value of the animation curve
  99797. * @param gradient Scalar amount to interpolate
  99798. * @returns Interpolated quaternion value
  99799. */
  99800. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99801. /**
  99802. * Interpolates a quaternion cubically
  99803. * @param startValue Start value of the animation curve
  99804. * @param outTangent End tangent of the animation curve
  99805. * @param endValue End value of the animation curve
  99806. * @param inTangent Start tangent of the animation curve
  99807. * @param gradient Scalar amount to interpolate
  99808. * @returns Interpolated quaternion value
  99809. */
  99810. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99811. /**
  99812. * Interpolates a Vector3 linearl
  99813. * @param startValue Start value of the animation curve
  99814. * @param endValue End value of the animation curve
  99815. * @param gradient Scalar amount to interpolate
  99816. * @returns Interpolated scalar value
  99817. */
  99818. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99819. /**
  99820. * Interpolates a Vector3 cubically
  99821. * @param startValue Start value of the animation curve
  99822. * @param outTangent End tangent of the animation
  99823. * @param endValue End value of the animation curve
  99824. * @param inTangent Start tangent of the animation curve
  99825. * @param gradient Scalar amount to interpolate
  99826. * @returns InterpolatedVector3 value
  99827. */
  99828. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99829. /**
  99830. * Interpolates a Vector2 linearly
  99831. * @param startValue Start value of the animation curve
  99832. * @param endValue End value of the animation curve
  99833. * @param gradient Scalar amount to interpolate
  99834. * @returns Interpolated Vector2 value
  99835. */
  99836. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99837. /**
  99838. * Interpolates a Vector2 cubically
  99839. * @param startValue Start value of the animation curve
  99840. * @param outTangent End tangent of the animation
  99841. * @param endValue End value of the animation curve
  99842. * @param inTangent Start tangent of the animation curve
  99843. * @param gradient Scalar amount to interpolate
  99844. * @returns Interpolated Vector2 value
  99845. */
  99846. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99847. /**
  99848. * Interpolates a size linearly
  99849. * @param startValue Start value of the animation curve
  99850. * @param endValue End value of the animation curve
  99851. * @param gradient Scalar amount to interpolate
  99852. * @returns Interpolated Size value
  99853. */
  99854. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99855. /**
  99856. * Interpolates a Color3 linearly
  99857. * @param startValue Start value of the animation curve
  99858. * @param endValue End value of the animation curve
  99859. * @param gradient Scalar amount to interpolate
  99860. * @returns Interpolated Color3 value
  99861. */
  99862. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99863. /**
  99864. * Interpolates a Color4 linearly
  99865. * @param startValue Start value of the animation curve
  99866. * @param endValue End value of the animation curve
  99867. * @param gradient Scalar amount to interpolate
  99868. * @returns Interpolated Color3 value
  99869. */
  99870. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99871. /**
  99872. * @hidden Internal use only
  99873. */
  99874. _getKeyValue(value: any): any;
  99875. /**
  99876. * @hidden Internal use only
  99877. */
  99878. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99879. /**
  99880. * Defines the function to use to interpolate matrices
  99881. * @param startValue defines the start matrix
  99882. * @param endValue defines the end matrix
  99883. * @param gradient defines the gradient between both matrices
  99884. * @param result defines an optional target matrix where to store the interpolation
  99885. * @returns the interpolated matrix
  99886. */
  99887. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99888. /**
  99889. * Makes a copy of the animation
  99890. * @returns Cloned animation
  99891. */
  99892. clone(): Animation;
  99893. /**
  99894. * Sets the key frames of the animation
  99895. * @param values The animation key frames to set
  99896. */
  99897. setKeys(values: Array<IAnimationKey>): void;
  99898. /**
  99899. * Serializes the animation to an object
  99900. * @returns Serialized object
  99901. */
  99902. serialize(): any;
  99903. /**
  99904. * Float animation type
  99905. */
  99906. static readonly ANIMATIONTYPE_FLOAT: number;
  99907. /**
  99908. * Vector3 animation type
  99909. */
  99910. static readonly ANIMATIONTYPE_VECTOR3: number;
  99911. /**
  99912. * Quaternion animation type
  99913. */
  99914. static readonly ANIMATIONTYPE_QUATERNION: number;
  99915. /**
  99916. * Matrix animation type
  99917. */
  99918. static readonly ANIMATIONTYPE_MATRIX: number;
  99919. /**
  99920. * Color3 animation type
  99921. */
  99922. static readonly ANIMATIONTYPE_COLOR3: number;
  99923. /**
  99924. * Color3 animation type
  99925. */
  99926. static readonly ANIMATIONTYPE_COLOR4: number;
  99927. /**
  99928. * Vector2 animation type
  99929. */
  99930. static readonly ANIMATIONTYPE_VECTOR2: number;
  99931. /**
  99932. * Size animation type
  99933. */
  99934. static readonly ANIMATIONTYPE_SIZE: number;
  99935. /**
  99936. * Relative Loop Mode
  99937. */
  99938. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99939. /**
  99940. * Cycle Loop Mode
  99941. */
  99942. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99943. /**
  99944. * Constant Loop Mode
  99945. */
  99946. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99947. /** @hidden */
  99948. static _UniversalLerp(left: any, right: any, amount: number): any;
  99949. /**
  99950. * Parses an animation object and creates an animation
  99951. * @param parsedAnimation Parsed animation object
  99952. * @returns Animation object
  99953. */
  99954. static Parse(parsedAnimation: any): Animation;
  99955. /**
  99956. * Appends the serialized animations from the source animations
  99957. * @param source Source containing the animations
  99958. * @param destination Target to store the animations
  99959. */
  99960. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99961. }
  99962. }
  99963. declare module BABYLON {
  99964. /**
  99965. * Interface containing an array of animations
  99966. */
  99967. export interface IAnimatable {
  99968. /**
  99969. * Array of animations
  99970. */
  99971. animations: Nullable<Array<Animation>>;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99976. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99977. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99978. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99979. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99980. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99981. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99982. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99983. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99984. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99985. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99986. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99987. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99988. /**
  99989. * Decorator used to define property that can be serialized as reference to a camera
  99990. * @param sourceName defines the name of the property to decorate
  99991. */
  99992. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99993. /**
  99994. * Class used to help serialization objects
  99995. */
  99996. export class SerializationHelper {
  99997. /** @hidden */
  99998. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99999. /** @hidden */
  100000. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  100001. /** @hidden */
  100002. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  100003. /** @hidden */
  100004. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  100005. /**
  100006. * Appends the serialized animations from the source animations
  100007. * @param source Source containing the animations
  100008. * @param destination Target to store the animations
  100009. */
  100010. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100011. /**
  100012. * Static function used to serialized a specific entity
  100013. * @param entity defines the entity to serialize
  100014. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  100015. * @returns a JSON compatible object representing the serialization of the entity
  100016. */
  100017. static Serialize<T>(entity: T, serializationObject?: any): any;
  100018. /**
  100019. * Creates a new entity from a serialization data object
  100020. * @param creationFunction defines a function used to instanciated the new entity
  100021. * @param source defines the source serialization data
  100022. * @param scene defines the hosting scene
  100023. * @param rootUrl defines the root url for resources
  100024. * @returns a new entity
  100025. */
  100026. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  100027. /**
  100028. * Clones an object
  100029. * @param creationFunction defines the function used to instanciate the new object
  100030. * @param source defines the source object
  100031. * @returns the cloned object
  100032. */
  100033. static Clone<T>(creationFunction: () => T, source: T): T;
  100034. /**
  100035. * Instanciates a new object based on a source one (some data will be shared between both object)
  100036. * @param creationFunction defines the function used to instanciate the new object
  100037. * @param source defines the source object
  100038. * @returns the new object
  100039. */
  100040. static Instanciate<T>(creationFunction: () => T, source: T): T;
  100041. }
  100042. }
  100043. declare module BABYLON {
  100044. /**
  100045. * Class used to manipulate GUIDs
  100046. */
  100047. export class GUID {
  100048. /**
  100049. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100050. * Be aware Math.random() could cause collisions, but:
  100051. * "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"
  100052. * @returns a pseudo random id
  100053. */
  100054. static RandomId(): string;
  100055. }
  100056. }
  100057. declare module BABYLON {
  100058. /**
  100059. * Base class of all the textures in babylon.
  100060. * It groups all the common properties the materials, post process, lights... might need
  100061. * in order to make a correct use of the texture.
  100062. */
  100063. export class BaseTexture implements IAnimatable {
  100064. /**
  100065. * Default anisotropic filtering level for the application.
  100066. * It is set to 4 as a good tradeoff between perf and quality.
  100067. */
  100068. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100069. /**
  100070. * Gets or sets the unique id of the texture
  100071. */
  100072. uniqueId: number;
  100073. /**
  100074. * Define the name of the texture.
  100075. */
  100076. name: string;
  100077. /**
  100078. * Gets or sets an object used to store user defined information.
  100079. */
  100080. metadata: any;
  100081. /**
  100082. * For internal use only. Please do not use.
  100083. */
  100084. reservedDataStore: any;
  100085. private _hasAlpha;
  100086. /**
  100087. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100088. */
  100089. set hasAlpha(value: boolean);
  100090. get hasAlpha(): boolean;
  100091. /**
  100092. * Defines if the alpha value should be determined via the rgb values.
  100093. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100094. */
  100095. getAlphaFromRGB: boolean;
  100096. /**
  100097. * Intensity or strength of the texture.
  100098. * It is commonly used by materials to fine tune the intensity of the texture
  100099. */
  100100. level: number;
  100101. /**
  100102. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100103. * This is part of the texture as textures usually maps to one uv set.
  100104. */
  100105. coordinatesIndex: number;
  100106. private _coordinatesMode;
  100107. /**
  100108. * How a texture is mapped.
  100109. *
  100110. * | Value | Type | Description |
  100111. * | ----- | ----------------------------------- | ----------- |
  100112. * | 0 | EXPLICIT_MODE | |
  100113. * | 1 | SPHERICAL_MODE | |
  100114. * | 2 | PLANAR_MODE | |
  100115. * | 3 | CUBIC_MODE | |
  100116. * | 4 | PROJECTION_MODE | |
  100117. * | 5 | SKYBOX_MODE | |
  100118. * | 6 | INVCUBIC_MODE | |
  100119. * | 7 | EQUIRECTANGULAR_MODE | |
  100120. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100121. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100122. */
  100123. set coordinatesMode(value: number);
  100124. get coordinatesMode(): number;
  100125. /**
  100126. * | Value | Type | Description |
  100127. * | ----- | ------------------ | ----------- |
  100128. * | 0 | CLAMP_ADDRESSMODE | |
  100129. * | 1 | WRAP_ADDRESSMODE | |
  100130. * | 2 | MIRROR_ADDRESSMODE | |
  100131. */
  100132. wrapU: number;
  100133. /**
  100134. * | Value | Type | Description |
  100135. * | ----- | ------------------ | ----------- |
  100136. * | 0 | CLAMP_ADDRESSMODE | |
  100137. * | 1 | WRAP_ADDRESSMODE | |
  100138. * | 2 | MIRROR_ADDRESSMODE | |
  100139. */
  100140. wrapV: number;
  100141. /**
  100142. * | Value | Type | Description |
  100143. * | ----- | ------------------ | ----------- |
  100144. * | 0 | CLAMP_ADDRESSMODE | |
  100145. * | 1 | WRAP_ADDRESSMODE | |
  100146. * | 2 | MIRROR_ADDRESSMODE | |
  100147. */
  100148. wrapR: number;
  100149. /**
  100150. * With compliant hardware and browser (supporting anisotropic filtering)
  100151. * this defines the level of anisotropic filtering in the texture.
  100152. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100153. */
  100154. anisotropicFilteringLevel: number;
  100155. /**
  100156. * Define if the texture is a cube texture or if false a 2d texture.
  100157. */
  100158. get isCube(): boolean;
  100159. set isCube(value: boolean);
  100160. /**
  100161. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100162. */
  100163. get is3D(): boolean;
  100164. set is3D(value: boolean);
  100165. /**
  100166. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100167. */
  100168. get is2DArray(): boolean;
  100169. set is2DArray(value: boolean);
  100170. /**
  100171. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100172. * HDR texture are usually stored in linear space.
  100173. * This only impacts the PBR and Background materials
  100174. */
  100175. gammaSpace: boolean;
  100176. /**
  100177. * Gets or sets whether or not the texture contains RGBD data.
  100178. */
  100179. get isRGBD(): boolean;
  100180. set isRGBD(value: boolean);
  100181. /**
  100182. * Is Z inverted in the texture (useful in a cube texture).
  100183. */
  100184. invertZ: boolean;
  100185. /**
  100186. * Are mip maps generated for this texture or not.
  100187. */
  100188. get noMipmap(): boolean;
  100189. /**
  100190. * @hidden
  100191. */
  100192. lodLevelInAlpha: boolean;
  100193. /**
  100194. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100195. */
  100196. get lodGenerationOffset(): number;
  100197. set lodGenerationOffset(value: number);
  100198. /**
  100199. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100200. */
  100201. get lodGenerationScale(): number;
  100202. set lodGenerationScale(value: number);
  100203. /**
  100204. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100205. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100206. * average roughness values.
  100207. */
  100208. get linearSpecularLOD(): boolean;
  100209. set linearSpecularLOD(value: boolean);
  100210. /**
  100211. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100212. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100213. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100214. */
  100215. get irradianceTexture(): Nullable<BaseTexture>;
  100216. set irradianceTexture(value: Nullable<BaseTexture>);
  100217. /**
  100218. * Define if the texture is a render target.
  100219. */
  100220. isRenderTarget: boolean;
  100221. /**
  100222. * Define the unique id of the texture in the scene.
  100223. */
  100224. get uid(): string;
  100225. /**
  100226. * Return a string representation of the texture.
  100227. * @returns the texture as a string
  100228. */
  100229. toString(): string;
  100230. /**
  100231. * Get the class name of the texture.
  100232. * @returns "BaseTexture"
  100233. */
  100234. getClassName(): string;
  100235. /**
  100236. * Define the list of animation attached to the texture.
  100237. */
  100238. animations: Animation[];
  100239. /**
  100240. * An event triggered when the texture is disposed.
  100241. */
  100242. onDisposeObservable: Observable<BaseTexture>;
  100243. private _onDisposeObserver;
  100244. /**
  100245. * Callback triggered when the texture has been disposed.
  100246. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100247. */
  100248. set onDispose(callback: () => void);
  100249. /**
  100250. * Define the current state of the loading sequence when in delayed load mode.
  100251. */
  100252. delayLoadState: number;
  100253. private _scene;
  100254. /** @hidden */
  100255. _texture: Nullable<InternalTexture>;
  100256. private _uid;
  100257. /**
  100258. * Define if the texture is preventinga material to render or not.
  100259. * If not and the texture is not ready, the engine will use a default black texture instead.
  100260. */
  100261. get isBlocking(): boolean;
  100262. /**
  100263. * Instantiates a new BaseTexture.
  100264. * Base class of all the textures in babylon.
  100265. * It groups all the common properties the materials, post process, lights... might need
  100266. * in order to make a correct use of the texture.
  100267. * @param scene Define the scene the texture blongs to
  100268. */
  100269. constructor(scene: Nullable<Scene>);
  100270. /**
  100271. * Get the scene the texture belongs to.
  100272. * @returns the scene or null if undefined
  100273. */
  100274. getScene(): Nullable<Scene>;
  100275. /**
  100276. * Get the texture transform matrix used to offset tile the texture for istance.
  100277. * @returns the transformation matrix
  100278. */
  100279. getTextureMatrix(): Matrix;
  100280. /**
  100281. * Get the texture reflection matrix used to rotate/transform the reflection.
  100282. * @returns the reflection matrix
  100283. */
  100284. getReflectionTextureMatrix(): Matrix;
  100285. /**
  100286. * Get the underlying lower level texture from Babylon.
  100287. * @returns the insternal texture
  100288. */
  100289. getInternalTexture(): Nullable<InternalTexture>;
  100290. /**
  100291. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100292. * @returns true if ready or not blocking
  100293. */
  100294. isReadyOrNotBlocking(): boolean;
  100295. /**
  100296. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100297. * @returns true if fully ready
  100298. */
  100299. isReady(): boolean;
  100300. private _cachedSize;
  100301. /**
  100302. * Get the size of the texture.
  100303. * @returns the texture size.
  100304. */
  100305. getSize(): ISize;
  100306. /**
  100307. * Get the base size of the texture.
  100308. * It can be different from the size if the texture has been resized for POT for instance
  100309. * @returns the base size
  100310. */
  100311. getBaseSize(): ISize;
  100312. /**
  100313. * Update the sampling mode of the texture.
  100314. * Default is Trilinear mode.
  100315. *
  100316. * | Value | Type | Description |
  100317. * | ----- | ------------------ | ----------- |
  100318. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100319. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100320. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100321. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100322. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100323. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100324. * | 7 | NEAREST_LINEAR | |
  100325. * | 8 | NEAREST_NEAREST | |
  100326. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100327. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100328. * | 11 | LINEAR_LINEAR | |
  100329. * | 12 | LINEAR_NEAREST | |
  100330. *
  100331. * > _mag_: magnification filter (close to the viewer)
  100332. * > _min_: minification filter (far from the viewer)
  100333. * > _mip_: filter used between mip map levels
  100334. *@param samplingMode Define the new sampling mode of the texture
  100335. */
  100336. updateSamplingMode(samplingMode: number): void;
  100337. /**
  100338. * Scales the texture if is `canRescale()`
  100339. * @param ratio the resize factor we want to use to rescale
  100340. */
  100341. scale(ratio: number): void;
  100342. /**
  100343. * Get if the texture can rescale.
  100344. */
  100345. get canRescale(): boolean;
  100346. /** @hidden */
  100347. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100348. /** @hidden */
  100349. _rebuild(): void;
  100350. /**
  100351. * Triggers the load sequence in delayed load mode.
  100352. */
  100353. delayLoad(): void;
  100354. /**
  100355. * Clones the texture.
  100356. * @returns the cloned texture
  100357. */
  100358. clone(): Nullable<BaseTexture>;
  100359. /**
  100360. * Get the texture underlying type (INT, FLOAT...)
  100361. */
  100362. get textureType(): number;
  100363. /**
  100364. * Get the texture underlying format (RGB, RGBA...)
  100365. */
  100366. get textureFormat(): number;
  100367. /**
  100368. * Indicates that textures need to be re-calculated for all materials
  100369. */
  100370. protected _markAllSubMeshesAsTexturesDirty(): void;
  100371. /**
  100372. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100373. * This will returns an RGBA array buffer containing either in values (0-255) or
  100374. * float values (0-1) depending of the underlying buffer type.
  100375. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100376. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100377. * @param buffer defines a user defined buffer to fill with data (can be null)
  100378. * @returns The Array buffer containing the pixels data.
  100379. */
  100380. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100381. /**
  100382. * Release and destroy the underlying lower level texture aka internalTexture.
  100383. */
  100384. releaseInternalTexture(): void;
  100385. /** @hidden */
  100386. get _lodTextureHigh(): Nullable<BaseTexture>;
  100387. /** @hidden */
  100388. get _lodTextureMid(): Nullable<BaseTexture>;
  100389. /** @hidden */
  100390. get _lodTextureLow(): Nullable<BaseTexture>;
  100391. /**
  100392. * Dispose the texture and release its associated resources.
  100393. */
  100394. dispose(): void;
  100395. /**
  100396. * Serialize the texture into a JSON representation that can be parsed later on.
  100397. * @returns the JSON representation of the texture
  100398. */
  100399. serialize(): any;
  100400. /**
  100401. * Helper function to be called back once a list of texture contains only ready textures.
  100402. * @param textures Define the list of textures to wait for
  100403. * @param callback Define the callback triggered once the entire list will be ready
  100404. */
  100405. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100406. }
  100407. }
  100408. declare module BABYLON {
  100409. /**
  100410. * Options to be used when creating an effect.
  100411. */
  100412. export interface IEffectCreationOptions {
  100413. /**
  100414. * Atrributes that will be used in the shader.
  100415. */
  100416. attributes: string[];
  100417. /**
  100418. * Uniform varible names that will be set in the shader.
  100419. */
  100420. uniformsNames: string[];
  100421. /**
  100422. * Uniform buffer variable names that will be set in the shader.
  100423. */
  100424. uniformBuffersNames: string[];
  100425. /**
  100426. * Sampler texture variable names that will be set in the shader.
  100427. */
  100428. samplers: string[];
  100429. /**
  100430. * Define statements that will be set in the shader.
  100431. */
  100432. defines: any;
  100433. /**
  100434. * Possible fallbacks for this effect to improve performance when needed.
  100435. */
  100436. fallbacks: Nullable<IEffectFallbacks>;
  100437. /**
  100438. * Callback that will be called when the shader is compiled.
  100439. */
  100440. onCompiled: Nullable<(effect: Effect) => void>;
  100441. /**
  100442. * Callback that will be called if an error occurs during shader compilation.
  100443. */
  100444. onError: Nullable<(effect: Effect, errors: string) => void>;
  100445. /**
  100446. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100447. */
  100448. indexParameters?: any;
  100449. /**
  100450. * Max number of lights that can be used in the shader.
  100451. */
  100452. maxSimultaneousLights?: number;
  100453. /**
  100454. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100455. */
  100456. transformFeedbackVaryings?: Nullable<string[]>;
  100457. }
  100458. /**
  100459. * Effect containing vertex and fragment shader that can be executed on an object.
  100460. */
  100461. export class Effect implements IDisposable {
  100462. /**
  100463. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100464. */
  100465. static ShadersRepository: string;
  100466. /**
  100467. * Name of the effect.
  100468. */
  100469. name: any;
  100470. /**
  100471. * String container all the define statements that should be set on the shader.
  100472. */
  100473. defines: string;
  100474. /**
  100475. * Callback that will be called when the shader is compiled.
  100476. */
  100477. onCompiled: Nullable<(effect: Effect) => void>;
  100478. /**
  100479. * Callback that will be called if an error occurs during shader compilation.
  100480. */
  100481. onError: Nullable<(effect: Effect, errors: string) => void>;
  100482. /**
  100483. * Callback that will be called when effect is bound.
  100484. */
  100485. onBind: Nullable<(effect: Effect) => void>;
  100486. /**
  100487. * Unique ID of the effect.
  100488. */
  100489. uniqueId: number;
  100490. /**
  100491. * Observable that will be called when the shader is compiled.
  100492. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100493. */
  100494. onCompileObservable: Observable<Effect>;
  100495. /**
  100496. * Observable that will be called if an error occurs during shader compilation.
  100497. */
  100498. onErrorObservable: Observable<Effect>;
  100499. /** @hidden */
  100500. _onBindObservable: Nullable<Observable<Effect>>;
  100501. /**
  100502. * @hidden
  100503. * Specifies if the effect was previously ready
  100504. */
  100505. _wasPreviouslyReady: boolean;
  100506. /**
  100507. * Observable that will be called when effect is bound.
  100508. */
  100509. get onBindObservable(): Observable<Effect>;
  100510. /** @hidden */
  100511. _bonesComputationForcedToCPU: boolean;
  100512. private static _uniqueIdSeed;
  100513. private _engine;
  100514. private _uniformBuffersNames;
  100515. private _uniformsNames;
  100516. private _samplerList;
  100517. private _samplers;
  100518. private _isReady;
  100519. private _compilationError;
  100520. private _allFallbacksProcessed;
  100521. private _attributesNames;
  100522. private _attributes;
  100523. private _attributeLocationByName;
  100524. private _uniforms;
  100525. /**
  100526. * Key for the effect.
  100527. * @hidden
  100528. */
  100529. _key: string;
  100530. private _indexParameters;
  100531. private _fallbacks;
  100532. private _vertexSourceCode;
  100533. private _fragmentSourceCode;
  100534. private _vertexSourceCodeOverride;
  100535. private _fragmentSourceCodeOverride;
  100536. private _transformFeedbackVaryings;
  100537. /**
  100538. * Compiled shader to webGL program.
  100539. * @hidden
  100540. */
  100541. _pipelineContext: Nullable<IPipelineContext>;
  100542. private _valueCache;
  100543. private static _baseCache;
  100544. /**
  100545. * Instantiates an effect.
  100546. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100547. * @param baseName Name of the effect.
  100548. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100549. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100550. * @param samplers List of sampler variables that will be passed to the shader.
  100551. * @param engine Engine to be used to render the effect
  100552. * @param defines Define statements to be added to the shader.
  100553. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100554. * @param onCompiled Callback that will be called when the shader is compiled.
  100555. * @param onError Callback that will be called if an error occurs during shader compilation.
  100556. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100557. */
  100558. 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);
  100559. private _useFinalCode;
  100560. /**
  100561. * Unique key for this effect
  100562. */
  100563. get key(): string;
  100564. /**
  100565. * If the effect has been compiled and prepared.
  100566. * @returns if the effect is compiled and prepared.
  100567. */
  100568. isReady(): boolean;
  100569. private _isReadyInternal;
  100570. /**
  100571. * The engine the effect was initialized with.
  100572. * @returns the engine.
  100573. */
  100574. getEngine(): Engine;
  100575. /**
  100576. * The pipeline context for this effect
  100577. * @returns the associated pipeline context
  100578. */
  100579. getPipelineContext(): Nullable<IPipelineContext>;
  100580. /**
  100581. * The set of names of attribute variables for the shader.
  100582. * @returns An array of attribute names.
  100583. */
  100584. getAttributesNames(): string[];
  100585. /**
  100586. * Returns the attribute at the given index.
  100587. * @param index The index of the attribute.
  100588. * @returns The location of the attribute.
  100589. */
  100590. getAttributeLocation(index: number): number;
  100591. /**
  100592. * Returns the attribute based on the name of the variable.
  100593. * @param name of the attribute to look up.
  100594. * @returns the attribute location.
  100595. */
  100596. getAttributeLocationByName(name: string): number;
  100597. /**
  100598. * The number of attributes.
  100599. * @returns the numnber of attributes.
  100600. */
  100601. getAttributesCount(): number;
  100602. /**
  100603. * Gets the index of a uniform variable.
  100604. * @param uniformName of the uniform to look up.
  100605. * @returns the index.
  100606. */
  100607. getUniformIndex(uniformName: string): number;
  100608. /**
  100609. * Returns the attribute based on the name of the variable.
  100610. * @param uniformName of the uniform to look up.
  100611. * @returns the location of the uniform.
  100612. */
  100613. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100614. /**
  100615. * Returns an array of sampler variable names
  100616. * @returns The array of sampler variable neames.
  100617. */
  100618. getSamplers(): string[];
  100619. /**
  100620. * The error from the last compilation.
  100621. * @returns the error string.
  100622. */
  100623. getCompilationError(): string;
  100624. /**
  100625. * Gets a boolean indicating that all fallbacks were used during compilation
  100626. * @returns true if all fallbacks were used
  100627. */
  100628. allFallbacksProcessed(): boolean;
  100629. /**
  100630. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100631. * @param func The callback to be used.
  100632. */
  100633. executeWhenCompiled(func: (effect: Effect) => void): void;
  100634. private _checkIsReady;
  100635. private _loadShader;
  100636. /**
  100637. * Recompiles the webGL program
  100638. * @param vertexSourceCode The source code for the vertex shader.
  100639. * @param fragmentSourceCode The source code for the fragment shader.
  100640. * @param onCompiled Callback called when completed.
  100641. * @param onError Callback called on error.
  100642. * @hidden
  100643. */
  100644. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100645. /**
  100646. * Prepares the effect
  100647. * @hidden
  100648. */
  100649. _prepareEffect(): void;
  100650. private _processCompilationErrors;
  100651. /**
  100652. * Checks if the effect is supported. (Must be called after compilation)
  100653. */
  100654. get isSupported(): boolean;
  100655. /**
  100656. * Binds a texture to the engine to be used as output of the shader.
  100657. * @param channel Name of the output variable.
  100658. * @param texture Texture to bind.
  100659. * @hidden
  100660. */
  100661. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100662. /**
  100663. * Sets a texture on the engine to be used in the shader.
  100664. * @param channel Name of the sampler variable.
  100665. * @param texture Texture to set.
  100666. */
  100667. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100668. /**
  100669. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100670. * @param channel Name of the sampler variable.
  100671. * @param texture Texture to set.
  100672. */
  100673. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100674. /**
  100675. * Sets an array of textures on the engine to be used in the shader.
  100676. * @param channel Name of the variable.
  100677. * @param textures Textures to set.
  100678. */
  100679. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100680. /**
  100681. * 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)
  100682. * @param channel Name of the sampler variable.
  100683. * @param postProcess Post process to get the input texture from.
  100684. */
  100685. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100686. /**
  100687. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100688. * 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)
  100689. * @param channel Name of the sampler variable.
  100690. * @param postProcess Post process to get the output texture from.
  100691. */
  100692. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100693. /** @hidden */
  100694. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100695. /** @hidden */
  100696. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100697. /** @hidden */
  100698. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100699. /** @hidden */
  100700. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100701. /**
  100702. * Binds a buffer to a uniform.
  100703. * @param buffer Buffer to bind.
  100704. * @param name Name of the uniform variable to bind to.
  100705. */
  100706. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100707. /**
  100708. * Binds block to a uniform.
  100709. * @param blockName Name of the block to bind.
  100710. * @param index Index to bind.
  100711. */
  100712. bindUniformBlock(blockName: string, index: number): void;
  100713. /**
  100714. * Sets an interger value on a uniform variable.
  100715. * @param uniformName Name of the variable.
  100716. * @param value Value to be set.
  100717. * @returns this effect.
  100718. */
  100719. setInt(uniformName: string, value: number): Effect;
  100720. /**
  100721. * Sets an int array on a uniform variable.
  100722. * @param uniformName Name of the variable.
  100723. * @param array array to be set.
  100724. * @returns this effect.
  100725. */
  100726. setIntArray(uniformName: string, array: Int32Array): Effect;
  100727. /**
  100728. * 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)
  100729. * @param uniformName Name of the variable.
  100730. * @param array array to be set.
  100731. * @returns this effect.
  100732. */
  100733. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100734. /**
  100735. * 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)
  100736. * @param uniformName Name of the variable.
  100737. * @param array array to be set.
  100738. * @returns this effect.
  100739. */
  100740. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100741. /**
  100742. * 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)
  100743. * @param uniformName Name of the variable.
  100744. * @param array array to be set.
  100745. * @returns this effect.
  100746. */
  100747. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100748. /**
  100749. * Sets an float array on a uniform variable.
  100750. * @param uniformName Name of the variable.
  100751. * @param array array to be set.
  100752. * @returns this effect.
  100753. */
  100754. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100755. /**
  100756. * 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)
  100757. * @param uniformName Name of the variable.
  100758. * @param array array to be set.
  100759. * @returns this effect.
  100760. */
  100761. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100762. /**
  100763. * 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)
  100764. * @param uniformName Name of the variable.
  100765. * @param array array to be set.
  100766. * @returns this effect.
  100767. */
  100768. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100769. /**
  100770. * 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)
  100771. * @param uniformName Name of the variable.
  100772. * @param array array to be set.
  100773. * @returns this effect.
  100774. */
  100775. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100776. /**
  100777. * Sets an array on a uniform variable.
  100778. * @param uniformName Name of the variable.
  100779. * @param array array to be set.
  100780. * @returns this effect.
  100781. */
  100782. setArray(uniformName: string, array: number[]): Effect;
  100783. /**
  100784. * 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)
  100785. * @param uniformName Name of the variable.
  100786. * @param array array to be set.
  100787. * @returns this effect.
  100788. */
  100789. setArray2(uniformName: string, array: number[]): Effect;
  100790. /**
  100791. * 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)
  100792. * @param uniformName Name of the variable.
  100793. * @param array array to be set.
  100794. * @returns this effect.
  100795. */
  100796. setArray3(uniformName: string, array: number[]): Effect;
  100797. /**
  100798. * 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)
  100799. * @param uniformName Name of the variable.
  100800. * @param array array to be set.
  100801. * @returns this effect.
  100802. */
  100803. setArray4(uniformName: string, array: number[]): Effect;
  100804. /**
  100805. * Sets matrices on a uniform variable.
  100806. * @param uniformName Name of the variable.
  100807. * @param matrices matrices to be set.
  100808. * @returns this effect.
  100809. */
  100810. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100811. /**
  100812. * Sets matrix on a uniform variable.
  100813. * @param uniformName Name of the variable.
  100814. * @param matrix matrix to be set.
  100815. * @returns this effect.
  100816. */
  100817. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100818. /**
  100819. * 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)
  100820. * @param uniformName Name of the variable.
  100821. * @param matrix matrix to be set.
  100822. * @returns this effect.
  100823. */
  100824. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100825. /**
  100826. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100827. * @param uniformName Name of the variable.
  100828. * @param matrix matrix to be set.
  100829. * @returns this effect.
  100830. */
  100831. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100832. /**
  100833. * Sets a float on a uniform variable.
  100834. * @param uniformName Name of the variable.
  100835. * @param value value to be set.
  100836. * @returns this effect.
  100837. */
  100838. setFloat(uniformName: string, value: number): Effect;
  100839. /**
  100840. * Sets a boolean on a uniform variable.
  100841. * @param uniformName Name of the variable.
  100842. * @param bool value to be set.
  100843. * @returns this effect.
  100844. */
  100845. setBool(uniformName: string, bool: boolean): Effect;
  100846. /**
  100847. * Sets a Vector2 on a uniform variable.
  100848. * @param uniformName Name of the variable.
  100849. * @param vector2 vector2 to be set.
  100850. * @returns this effect.
  100851. */
  100852. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100853. /**
  100854. * Sets a float2 on a uniform variable.
  100855. * @param uniformName Name of the variable.
  100856. * @param x First float in float2.
  100857. * @param y Second float in float2.
  100858. * @returns this effect.
  100859. */
  100860. setFloat2(uniformName: string, x: number, y: number): Effect;
  100861. /**
  100862. * Sets a Vector3 on a uniform variable.
  100863. * @param uniformName Name of the variable.
  100864. * @param vector3 Value to be set.
  100865. * @returns this effect.
  100866. */
  100867. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100868. /**
  100869. * Sets a float3 on a uniform variable.
  100870. * @param uniformName Name of the variable.
  100871. * @param x First float in float3.
  100872. * @param y Second float in float3.
  100873. * @param z Third float in float3.
  100874. * @returns this effect.
  100875. */
  100876. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100877. /**
  100878. * Sets a Vector4 on a uniform variable.
  100879. * @param uniformName Name of the variable.
  100880. * @param vector4 Value to be set.
  100881. * @returns this effect.
  100882. */
  100883. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100884. /**
  100885. * Sets a float4 on a uniform variable.
  100886. * @param uniformName Name of the variable.
  100887. * @param x First float in float4.
  100888. * @param y Second float in float4.
  100889. * @param z Third float in float4.
  100890. * @param w Fourth float in float4.
  100891. * @returns this effect.
  100892. */
  100893. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100894. /**
  100895. * Sets a Color3 on a uniform variable.
  100896. * @param uniformName Name of the variable.
  100897. * @param color3 Value to be set.
  100898. * @returns this effect.
  100899. */
  100900. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100901. /**
  100902. * Sets a Color4 on a uniform variable.
  100903. * @param uniformName Name of the variable.
  100904. * @param color3 Value to be set.
  100905. * @param alpha Alpha value to be set.
  100906. * @returns this effect.
  100907. */
  100908. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100909. /**
  100910. * Sets a Color4 on a uniform variable
  100911. * @param uniformName defines the name of the variable
  100912. * @param color4 defines the value to be set
  100913. * @returns this effect.
  100914. */
  100915. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100916. /** Release all associated resources */
  100917. dispose(): void;
  100918. /**
  100919. * This function will add a new shader to the shader store
  100920. * @param name the name of the shader
  100921. * @param pixelShader optional pixel shader content
  100922. * @param vertexShader optional vertex shader content
  100923. */
  100924. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100925. /**
  100926. * Store of each shader (The can be looked up using effect.key)
  100927. */
  100928. static ShadersStore: {
  100929. [key: string]: string;
  100930. };
  100931. /**
  100932. * Store of each included file for a shader (The can be looked up using effect.key)
  100933. */
  100934. static IncludesShadersStore: {
  100935. [key: string]: string;
  100936. };
  100937. /**
  100938. * Resets the cache of effects.
  100939. */
  100940. static ResetCache(): void;
  100941. }
  100942. }
  100943. declare module BABYLON {
  100944. /**
  100945. * Interface used to describe the capabilities of the engine relatively to the current browser
  100946. */
  100947. export interface EngineCapabilities {
  100948. /** Maximum textures units per fragment shader */
  100949. maxTexturesImageUnits: number;
  100950. /** Maximum texture units per vertex shader */
  100951. maxVertexTextureImageUnits: number;
  100952. /** Maximum textures units in the entire pipeline */
  100953. maxCombinedTexturesImageUnits: number;
  100954. /** Maximum texture size */
  100955. maxTextureSize: number;
  100956. /** Maximum texture samples */
  100957. maxSamples?: number;
  100958. /** Maximum cube texture size */
  100959. maxCubemapTextureSize: number;
  100960. /** Maximum render texture size */
  100961. maxRenderTextureSize: number;
  100962. /** Maximum number of vertex attributes */
  100963. maxVertexAttribs: number;
  100964. /** Maximum number of varyings */
  100965. maxVaryingVectors: number;
  100966. /** Maximum number of uniforms per vertex shader */
  100967. maxVertexUniformVectors: number;
  100968. /** Maximum number of uniforms per fragment shader */
  100969. maxFragmentUniformVectors: number;
  100970. /** Defines if standard derivates (dx/dy) are supported */
  100971. standardDerivatives: boolean;
  100972. /** Defines if s3tc texture compression is supported */
  100973. s3tc?: WEBGL_compressed_texture_s3tc;
  100974. /** Defines if pvrtc texture compression is supported */
  100975. pvrtc: any;
  100976. /** Defines if etc1 texture compression is supported */
  100977. etc1: any;
  100978. /** Defines if etc2 texture compression is supported */
  100979. etc2: any;
  100980. /** Defines if astc texture compression is supported */
  100981. astc: any;
  100982. /** Defines if float textures are supported */
  100983. textureFloat: boolean;
  100984. /** Defines if vertex array objects are supported */
  100985. vertexArrayObject: boolean;
  100986. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100987. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100988. /** Gets the maximum level of anisotropy supported */
  100989. maxAnisotropy: number;
  100990. /** Defines if instancing is supported */
  100991. instancedArrays: boolean;
  100992. /** Defines if 32 bits indices are supported */
  100993. uintIndices: boolean;
  100994. /** Defines if high precision shaders are supported */
  100995. highPrecisionShaderSupported: boolean;
  100996. /** Defines if depth reading in the fragment shader is supported */
  100997. fragmentDepthSupported: boolean;
  100998. /** Defines if float texture linear filtering is supported*/
  100999. textureFloatLinearFiltering: boolean;
  101000. /** Defines if rendering to float textures is supported */
  101001. textureFloatRender: boolean;
  101002. /** Defines if half float textures are supported*/
  101003. textureHalfFloat: boolean;
  101004. /** Defines if half float texture linear filtering is supported*/
  101005. textureHalfFloatLinearFiltering: boolean;
  101006. /** Defines if rendering to half float textures is supported */
  101007. textureHalfFloatRender: boolean;
  101008. /** Defines if textureLOD shader command is supported */
  101009. textureLOD: boolean;
  101010. /** Defines if draw buffers extension is supported */
  101011. drawBuffersExtension: boolean;
  101012. /** Defines if depth textures are supported */
  101013. depthTextureExtension: boolean;
  101014. /** Defines if float color buffer are supported */
  101015. colorBufferFloat: boolean;
  101016. /** Gets disjoint timer query extension (null if not supported) */
  101017. timerQuery?: EXT_disjoint_timer_query;
  101018. /** Defines if timestamp can be used with timer query */
  101019. canUseTimestampForTimerQuery: boolean;
  101020. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  101021. multiview?: any;
  101022. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  101023. oculusMultiview?: any;
  101024. /** Function used to let the system compiles shaders in background */
  101025. parallelShaderCompile?: {
  101026. COMPLETION_STATUS_KHR: number;
  101027. };
  101028. /** Max number of texture samples for MSAA */
  101029. maxMSAASamples: number;
  101030. /** Defines if the blend min max extension is supported */
  101031. blendMinMax: boolean;
  101032. }
  101033. }
  101034. declare module BABYLON {
  101035. /**
  101036. * @hidden
  101037. **/
  101038. export class DepthCullingState {
  101039. private _isDepthTestDirty;
  101040. private _isDepthMaskDirty;
  101041. private _isDepthFuncDirty;
  101042. private _isCullFaceDirty;
  101043. private _isCullDirty;
  101044. private _isZOffsetDirty;
  101045. private _isFrontFaceDirty;
  101046. private _depthTest;
  101047. private _depthMask;
  101048. private _depthFunc;
  101049. private _cull;
  101050. private _cullFace;
  101051. private _zOffset;
  101052. private _frontFace;
  101053. /**
  101054. * Initializes the state.
  101055. */
  101056. constructor();
  101057. get isDirty(): boolean;
  101058. get zOffset(): number;
  101059. set zOffset(value: number);
  101060. get cullFace(): Nullable<number>;
  101061. set cullFace(value: Nullable<number>);
  101062. get cull(): Nullable<boolean>;
  101063. set cull(value: Nullable<boolean>);
  101064. get depthFunc(): Nullable<number>;
  101065. set depthFunc(value: Nullable<number>);
  101066. get depthMask(): boolean;
  101067. set depthMask(value: boolean);
  101068. get depthTest(): boolean;
  101069. set depthTest(value: boolean);
  101070. get frontFace(): Nullable<number>;
  101071. set frontFace(value: Nullable<number>);
  101072. reset(): void;
  101073. apply(gl: WebGLRenderingContext): void;
  101074. }
  101075. }
  101076. declare module BABYLON {
  101077. /**
  101078. * @hidden
  101079. **/
  101080. export class StencilState {
  101081. /** 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 */
  101082. static readonly ALWAYS: number;
  101083. /** Passed to stencilOperation to specify that stencil value must be kept */
  101084. static readonly KEEP: number;
  101085. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101086. static readonly REPLACE: number;
  101087. private _isStencilTestDirty;
  101088. private _isStencilMaskDirty;
  101089. private _isStencilFuncDirty;
  101090. private _isStencilOpDirty;
  101091. private _stencilTest;
  101092. private _stencilMask;
  101093. private _stencilFunc;
  101094. private _stencilFuncRef;
  101095. private _stencilFuncMask;
  101096. private _stencilOpStencilFail;
  101097. private _stencilOpDepthFail;
  101098. private _stencilOpStencilDepthPass;
  101099. get isDirty(): boolean;
  101100. get stencilFunc(): number;
  101101. set stencilFunc(value: number);
  101102. get stencilFuncRef(): number;
  101103. set stencilFuncRef(value: number);
  101104. get stencilFuncMask(): number;
  101105. set stencilFuncMask(value: number);
  101106. get stencilOpStencilFail(): number;
  101107. set stencilOpStencilFail(value: number);
  101108. get stencilOpDepthFail(): number;
  101109. set stencilOpDepthFail(value: number);
  101110. get stencilOpStencilDepthPass(): number;
  101111. set stencilOpStencilDepthPass(value: number);
  101112. get stencilMask(): number;
  101113. set stencilMask(value: number);
  101114. get stencilTest(): boolean;
  101115. set stencilTest(value: boolean);
  101116. constructor();
  101117. reset(): void;
  101118. apply(gl: WebGLRenderingContext): void;
  101119. }
  101120. }
  101121. declare module BABYLON {
  101122. /**
  101123. * @hidden
  101124. **/
  101125. export class AlphaState {
  101126. private _isAlphaBlendDirty;
  101127. private _isBlendFunctionParametersDirty;
  101128. private _isBlendEquationParametersDirty;
  101129. private _isBlendConstantsDirty;
  101130. private _alphaBlend;
  101131. private _blendFunctionParameters;
  101132. private _blendEquationParameters;
  101133. private _blendConstants;
  101134. /**
  101135. * Initializes the state.
  101136. */
  101137. constructor();
  101138. get isDirty(): boolean;
  101139. get alphaBlend(): boolean;
  101140. set alphaBlend(value: boolean);
  101141. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101142. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101143. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101144. reset(): void;
  101145. apply(gl: WebGLRenderingContext): void;
  101146. }
  101147. }
  101148. declare module BABYLON {
  101149. /** @hidden */
  101150. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101151. attributeProcessor(attribute: string): string;
  101152. varyingProcessor(varying: string, isFragment: boolean): string;
  101153. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101154. }
  101155. }
  101156. declare module BABYLON {
  101157. /**
  101158. * Interface for attribute information associated with buffer instanciation
  101159. */
  101160. export interface InstancingAttributeInfo {
  101161. /**
  101162. * Name of the GLSL attribute
  101163. * if attribute index is not specified, this is used to retrieve the index from the effect
  101164. */
  101165. attributeName: string;
  101166. /**
  101167. * Index/offset of the attribute in the vertex shader
  101168. * if not specified, this will be computes from the name.
  101169. */
  101170. index?: number;
  101171. /**
  101172. * size of the attribute, 1, 2, 3 or 4
  101173. */
  101174. attributeSize: number;
  101175. /**
  101176. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101177. */
  101178. offset: number;
  101179. /**
  101180. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101181. * default to 1
  101182. */
  101183. divisor?: number;
  101184. /**
  101185. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101186. * default is FLOAT
  101187. */
  101188. attributeType?: number;
  101189. /**
  101190. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101191. */
  101192. normalized?: boolean;
  101193. }
  101194. }
  101195. declare module BABYLON {
  101196. interface ThinEngine {
  101197. /**
  101198. * Update a video texture
  101199. * @param texture defines the texture to update
  101200. * @param video defines the video element to use
  101201. * @param invertY defines if data must be stored with Y axis inverted
  101202. */
  101203. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101204. }
  101205. }
  101206. declare module BABYLON {
  101207. /**
  101208. * Settings for finer control over video usage
  101209. */
  101210. export interface VideoTextureSettings {
  101211. /**
  101212. * Applies `autoplay` to video, if specified
  101213. */
  101214. autoPlay?: boolean;
  101215. /**
  101216. * Applies `loop` to video, if specified
  101217. */
  101218. loop?: boolean;
  101219. /**
  101220. * Automatically updates internal texture from video at every frame in the render loop
  101221. */
  101222. autoUpdateTexture: boolean;
  101223. /**
  101224. * Image src displayed during the video loading or until the user interacts with the video.
  101225. */
  101226. poster?: string;
  101227. }
  101228. /**
  101229. * If you want to display a video in your scene, this is the special texture for that.
  101230. * This special texture works similar to other textures, with the exception of a few parameters.
  101231. * @see https://doc.babylonjs.com/how_to/video_texture
  101232. */
  101233. export class VideoTexture extends Texture {
  101234. /**
  101235. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101236. */
  101237. readonly autoUpdateTexture: boolean;
  101238. /**
  101239. * The video instance used by the texture internally
  101240. */
  101241. readonly video: HTMLVideoElement;
  101242. private _onUserActionRequestedObservable;
  101243. /**
  101244. * Event triggerd when a dom action is required by the user to play the video.
  101245. * This happens due to recent changes in browser policies preventing video to auto start.
  101246. */
  101247. get onUserActionRequestedObservable(): Observable<Texture>;
  101248. private _generateMipMaps;
  101249. private _engine;
  101250. private _stillImageCaptured;
  101251. private _displayingPosterTexture;
  101252. private _settings;
  101253. private _createInternalTextureOnEvent;
  101254. private _frameId;
  101255. /**
  101256. * Creates a video texture.
  101257. * If you want to display a video in your scene, this is the special texture for that.
  101258. * This special texture works similar to other textures, with the exception of a few parameters.
  101259. * @see https://doc.babylonjs.com/how_to/video_texture
  101260. * @param name optional name, will detect from video source, if not defined
  101261. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101262. * @param scene is obviously the current scene.
  101263. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101264. * @param invertY is false by default but can be used to invert video on Y axis
  101265. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101266. * @param settings allows finer control over video usage
  101267. */
  101268. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101269. private _getName;
  101270. private _getVideo;
  101271. private _createInternalTexture;
  101272. private reset;
  101273. /**
  101274. * @hidden Internal method to initiate `update`.
  101275. */
  101276. _rebuild(): void;
  101277. /**
  101278. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101279. */
  101280. update(): void;
  101281. /**
  101282. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101283. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101284. */
  101285. updateTexture(isVisible: boolean): void;
  101286. protected _updateInternalTexture: () => void;
  101287. /**
  101288. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101289. * @param url New url.
  101290. */
  101291. updateURL(url: string): void;
  101292. /**
  101293. * Dispose the texture and release its associated resources.
  101294. */
  101295. dispose(): void;
  101296. /**
  101297. * Creates a video texture straight from a stream.
  101298. * @param scene Define the scene the texture should be created in
  101299. * @param stream Define the stream the texture should be created from
  101300. * @returns The created video texture as a promise
  101301. */
  101302. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101303. /**
  101304. * Creates a video texture straight from your WebCam video feed.
  101305. * @param scene Define the scene the texture should be created in
  101306. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101307. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101308. * @returns The created video texture as a promise
  101309. */
  101310. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101311. minWidth: number;
  101312. maxWidth: number;
  101313. minHeight: number;
  101314. maxHeight: number;
  101315. deviceId: string;
  101316. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101317. /**
  101318. * Creates a video texture straight from your WebCam video feed.
  101319. * @param scene Define the scene the texture should be created in
  101320. * @param onReady Define a callback to triggered once the texture will be ready
  101321. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101322. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101323. */
  101324. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101325. minWidth: number;
  101326. maxWidth: number;
  101327. minHeight: number;
  101328. maxHeight: number;
  101329. deviceId: string;
  101330. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101331. }
  101332. }
  101333. declare module BABYLON {
  101334. /**
  101335. * Defines the interface used by objects working like Scene
  101336. * @hidden
  101337. */
  101338. interface ISceneLike {
  101339. _addPendingData(data: any): void;
  101340. _removePendingData(data: any): void;
  101341. offlineProvider: IOfflineProvider;
  101342. }
  101343. /** Interface defining initialization parameters for Engine class */
  101344. export interface EngineOptions extends WebGLContextAttributes {
  101345. /**
  101346. * Defines if the engine should no exceed a specified device ratio
  101347. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101348. */
  101349. limitDeviceRatio?: number;
  101350. /**
  101351. * Defines if webvr should be enabled automatically
  101352. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101353. */
  101354. autoEnableWebVR?: boolean;
  101355. /**
  101356. * Defines if webgl2 should be turned off even if supported
  101357. * @see http://doc.babylonjs.com/features/webgl2
  101358. */
  101359. disableWebGL2Support?: boolean;
  101360. /**
  101361. * Defines if webaudio should be initialized as well
  101362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101363. */
  101364. audioEngine?: boolean;
  101365. /**
  101366. * Defines if animations should run using a deterministic lock step
  101367. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101368. */
  101369. deterministicLockstep?: boolean;
  101370. /** Defines the maximum steps to use with deterministic lock step mode */
  101371. lockstepMaxSteps?: number;
  101372. /** Defines the seconds between each deterministic lock step */
  101373. timeStep?: number;
  101374. /**
  101375. * Defines that engine should ignore context lost events
  101376. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101377. */
  101378. doNotHandleContextLost?: boolean;
  101379. /**
  101380. * Defines that engine should ignore modifying touch action attribute and style
  101381. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101382. */
  101383. doNotHandleTouchAction?: boolean;
  101384. /**
  101385. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101386. */
  101387. useHighPrecisionFloats?: boolean;
  101388. }
  101389. /**
  101390. * The base engine class (root of all engines)
  101391. */
  101392. export class ThinEngine {
  101393. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101394. static ExceptionList: ({
  101395. key: string;
  101396. capture: string;
  101397. captureConstraint: number;
  101398. targets: string[];
  101399. } | {
  101400. key: string;
  101401. capture: null;
  101402. captureConstraint: null;
  101403. targets: string[];
  101404. })[];
  101405. /** @hidden */
  101406. static _TextureLoaders: IInternalTextureLoader[];
  101407. /**
  101408. * Returns the current npm package of the sdk
  101409. */
  101410. static get NpmPackage(): string;
  101411. /**
  101412. * Returns the current version of the framework
  101413. */
  101414. static get Version(): string;
  101415. /**
  101416. * Returns a string describing the current engine
  101417. */
  101418. get description(): string;
  101419. /**
  101420. * Gets or sets the epsilon value used by collision engine
  101421. */
  101422. static CollisionsEpsilon: number;
  101423. /**
  101424. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101425. */
  101426. static get ShadersRepository(): string;
  101427. static set ShadersRepository(value: string);
  101428. /**
  101429. * Gets or sets the textures that the engine should not attempt to load as compressed
  101430. */
  101431. protected _excludedCompressedTextures: string[];
  101432. /**
  101433. * Filters the compressed texture formats to only include
  101434. * files that are not included in the skippable list
  101435. *
  101436. * @param url the current extension
  101437. * @param textureFormatInUse the current compressed texture format
  101438. * @returns "format" string
  101439. */
  101440. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101441. /** @hidden */
  101442. _shaderProcessor: IShaderProcessor;
  101443. /**
  101444. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101445. */
  101446. forcePOTTextures: boolean;
  101447. /**
  101448. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101449. */
  101450. isFullscreen: boolean;
  101451. /**
  101452. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101453. */
  101454. cullBackFaces: boolean;
  101455. /**
  101456. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101457. */
  101458. renderEvenInBackground: boolean;
  101459. /**
  101460. * Gets or sets a boolean indicating that cache can be kept between frames
  101461. */
  101462. preventCacheWipeBetweenFrames: boolean;
  101463. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101464. validateShaderPrograms: boolean;
  101465. /**
  101466. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101467. * This can provide greater z depth for distant objects.
  101468. */
  101469. useReverseDepthBuffer: boolean;
  101470. /**
  101471. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101472. */
  101473. disableUniformBuffers: boolean;
  101474. /** @hidden */
  101475. _uniformBuffers: UniformBuffer[];
  101476. /**
  101477. * Gets a boolean indicating that the engine supports uniform buffers
  101478. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101479. */
  101480. get supportsUniformBuffers(): boolean;
  101481. /** @hidden */
  101482. _gl: WebGLRenderingContext;
  101483. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101484. protected _windowIsBackground: boolean;
  101485. protected _webGLVersion: number;
  101486. protected _creationOptions: EngineOptions;
  101487. protected _highPrecisionShadersAllowed: boolean;
  101488. /** @hidden */
  101489. get _shouldUseHighPrecisionShader(): boolean;
  101490. /**
  101491. * Gets a boolean indicating that only power of 2 textures are supported
  101492. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101493. */
  101494. get needPOTTextures(): boolean;
  101495. /** @hidden */
  101496. _badOS: boolean;
  101497. /** @hidden */
  101498. _badDesktopOS: boolean;
  101499. private _hardwareScalingLevel;
  101500. /** @hidden */
  101501. _caps: EngineCapabilities;
  101502. private _isStencilEnable;
  101503. private _glVersion;
  101504. private _glRenderer;
  101505. private _glVendor;
  101506. /** @hidden */
  101507. _videoTextureSupported: boolean;
  101508. protected _renderingQueueLaunched: boolean;
  101509. protected _activeRenderLoops: (() => void)[];
  101510. /**
  101511. * Observable signaled when a context lost event is raised
  101512. */
  101513. onContextLostObservable: Observable<ThinEngine>;
  101514. /**
  101515. * Observable signaled when a context restored event is raised
  101516. */
  101517. onContextRestoredObservable: Observable<ThinEngine>;
  101518. private _onContextLost;
  101519. private _onContextRestored;
  101520. protected _contextWasLost: boolean;
  101521. /** @hidden */
  101522. _doNotHandleContextLost: boolean;
  101523. /**
  101524. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101526. */
  101527. get doNotHandleContextLost(): boolean;
  101528. set doNotHandleContextLost(value: boolean);
  101529. /**
  101530. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101531. */
  101532. disableVertexArrayObjects: boolean;
  101533. /** @hidden */
  101534. protected _colorWrite: boolean;
  101535. /** @hidden */
  101536. protected _colorWriteChanged: boolean;
  101537. /** @hidden */
  101538. protected _depthCullingState: DepthCullingState;
  101539. /** @hidden */
  101540. protected _stencilState: StencilState;
  101541. /** @hidden */
  101542. _alphaState: AlphaState;
  101543. /** @hidden */
  101544. _alphaMode: number;
  101545. /** @hidden */
  101546. _alphaEquation: number;
  101547. /** @hidden */
  101548. _internalTexturesCache: InternalTexture[];
  101549. /** @hidden */
  101550. protected _activeChannel: number;
  101551. private _currentTextureChannel;
  101552. /** @hidden */
  101553. protected _boundTexturesCache: {
  101554. [key: string]: Nullable<InternalTexture>;
  101555. };
  101556. /** @hidden */
  101557. protected _currentEffect: Nullable<Effect>;
  101558. /** @hidden */
  101559. protected _currentProgram: Nullable<WebGLProgram>;
  101560. private _compiledEffects;
  101561. private _vertexAttribArraysEnabled;
  101562. /** @hidden */
  101563. protected _cachedViewport: Nullable<IViewportLike>;
  101564. private _cachedVertexArrayObject;
  101565. /** @hidden */
  101566. protected _cachedVertexBuffers: any;
  101567. /** @hidden */
  101568. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101569. /** @hidden */
  101570. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101571. /** @hidden */
  101572. _currentRenderTarget: Nullable<InternalTexture>;
  101573. private _uintIndicesCurrentlySet;
  101574. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101575. /** @hidden */
  101576. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101577. private _currentBufferPointers;
  101578. private _currentInstanceLocations;
  101579. private _currentInstanceBuffers;
  101580. private _textureUnits;
  101581. /** @hidden */
  101582. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101583. /** @hidden */
  101584. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101585. /** @hidden */
  101586. _boundRenderFunction: any;
  101587. private _vaoRecordInProgress;
  101588. private _mustWipeVertexAttributes;
  101589. private _emptyTexture;
  101590. private _emptyCubeTexture;
  101591. private _emptyTexture3D;
  101592. private _emptyTexture2DArray;
  101593. /** @hidden */
  101594. _frameHandler: number;
  101595. private _nextFreeTextureSlots;
  101596. private _maxSimultaneousTextures;
  101597. private _activeRequests;
  101598. protected _texturesSupported: string[];
  101599. /** @hidden */
  101600. _textureFormatInUse: Nullable<string>;
  101601. protected get _supportsHardwareTextureRescaling(): boolean;
  101602. /**
  101603. * Gets the list of texture formats supported
  101604. */
  101605. get texturesSupported(): Array<string>;
  101606. /**
  101607. * Gets the list of texture formats in use
  101608. */
  101609. get textureFormatInUse(): Nullable<string>;
  101610. /**
  101611. * Gets the current viewport
  101612. */
  101613. get currentViewport(): Nullable<IViewportLike>;
  101614. /**
  101615. * Gets the default empty texture
  101616. */
  101617. get emptyTexture(): InternalTexture;
  101618. /**
  101619. * Gets the default empty 3D texture
  101620. */
  101621. get emptyTexture3D(): InternalTexture;
  101622. /**
  101623. * Gets the default empty 2D array texture
  101624. */
  101625. get emptyTexture2DArray(): InternalTexture;
  101626. /**
  101627. * Gets the default empty cube texture
  101628. */
  101629. get emptyCubeTexture(): InternalTexture;
  101630. /**
  101631. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101632. */
  101633. readonly premultipliedAlpha: boolean;
  101634. /**
  101635. * Observable event triggered before each texture is initialized
  101636. */
  101637. onBeforeTextureInitObservable: Observable<Texture>;
  101638. /**
  101639. * Creates a new engine
  101640. * @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
  101641. * @param antialias defines enable antialiasing (default: false)
  101642. * @param options defines further options to be sent to the getContext() function
  101643. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101644. */
  101645. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101646. private _rebuildInternalTextures;
  101647. private _rebuildEffects;
  101648. /**
  101649. * Gets a boolean indicating if all created effects are ready
  101650. * @returns true if all effects are ready
  101651. */
  101652. areAllEffectsReady(): boolean;
  101653. protected _rebuildBuffers(): void;
  101654. private _initGLContext;
  101655. /**
  101656. * Gets version of the current webGL context
  101657. */
  101658. get webGLVersion(): number;
  101659. /**
  101660. * Gets a string idenfifying the name of the class
  101661. * @returns "Engine" string
  101662. */
  101663. getClassName(): string;
  101664. /**
  101665. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101666. */
  101667. get isStencilEnable(): boolean;
  101668. /** @hidden */
  101669. _prepareWorkingCanvas(): void;
  101670. /**
  101671. * Reset the texture cache to empty state
  101672. */
  101673. resetTextureCache(): void;
  101674. /**
  101675. * Gets an object containing information about the current webGL context
  101676. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101677. */
  101678. getGlInfo(): {
  101679. vendor: string;
  101680. renderer: string;
  101681. version: string;
  101682. };
  101683. /**
  101684. * Defines the hardware scaling level.
  101685. * By default the hardware scaling level is computed from the window device ratio.
  101686. * 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.
  101687. * @param level defines the level to use
  101688. */
  101689. setHardwareScalingLevel(level: number): void;
  101690. /**
  101691. * Gets the current hardware scaling level.
  101692. * By default the hardware scaling level is computed from the window device ratio.
  101693. * 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.
  101694. * @returns a number indicating the current hardware scaling level
  101695. */
  101696. getHardwareScalingLevel(): number;
  101697. /**
  101698. * Gets the list of loaded textures
  101699. * @returns an array containing all loaded textures
  101700. */
  101701. getLoadedTexturesCache(): InternalTexture[];
  101702. /**
  101703. * Gets the object containing all engine capabilities
  101704. * @returns the EngineCapabilities object
  101705. */
  101706. getCaps(): EngineCapabilities;
  101707. /**
  101708. * stop executing a render loop function and remove it from the execution array
  101709. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101710. */
  101711. stopRenderLoop(renderFunction?: () => void): void;
  101712. /** @hidden */
  101713. _renderLoop(): void;
  101714. /**
  101715. * Gets the HTML canvas attached with the current webGL context
  101716. * @returns a HTML canvas
  101717. */
  101718. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101719. /**
  101720. * Gets host window
  101721. * @returns the host window object
  101722. */
  101723. getHostWindow(): Nullable<Window>;
  101724. /**
  101725. * Gets the current render width
  101726. * @param useScreen defines if screen size must be used (or the current render target if any)
  101727. * @returns a number defining the current render width
  101728. */
  101729. getRenderWidth(useScreen?: boolean): number;
  101730. /**
  101731. * Gets the current render height
  101732. * @param useScreen defines if screen size must be used (or the current render target if any)
  101733. * @returns a number defining the current render height
  101734. */
  101735. getRenderHeight(useScreen?: boolean): number;
  101736. /**
  101737. * Can be used to override the current requestAnimationFrame requester.
  101738. * @hidden
  101739. */
  101740. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101741. /**
  101742. * Register and execute a render loop. The engine can have more than one render function
  101743. * @param renderFunction defines the function to continuously execute
  101744. */
  101745. runRenderLoop(renderFunction: () => void): void;
  101746. /**
  101747. * Clear the current render buffer or the current render target (if any is set up)
  101748. * @param color defines the color to use
  101749. * @param backBuffer defines if the back buffer must be cleared
  101750. * @param depth defines if the depth buffer must be cleared
  101751. * @param stencil defines if the stencil buffer must be cleared
  101752. */
  101753. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101754. private _viewportCached;
  101755. /** @hidden */
  101756. _viewport(x: number, y: number, width: number, height: number): void;
  101757. /**
  101758. * Set the WebGL's viewport
  101759. * @param viewport defines the viewport element to be used
  101760. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101761. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101762. */
  101763. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101764. /**
  101765. * Begin a new frame
  101766. */
  101767. beginFrame(): void;
  101768. /**
  101769. * Enf the current frame
  101770. */
  101771. endFrame(): void;
  101772. /**
  101773. * Resize the view according to the canvas' size
  101774. */
  101775. resize(): void;
  101776. /**
  101777. * Force a specific size of the canvas
  101778. * @param width defines the new canvas' width
  101779. * @param height defines the new canvas' height
  101780. */
  101781. setSize(width: number, height: number): void;
  101782. /**
  101783. * Binds the frame buffer to the specified texture.
  101784. * @param texture The texture to render to or null for the default canvas
  101785. * @param faceIndex The face of the texture to render to in case of cube texture
  101786. * @param requiredWidth The width of the target to render to
  101787. * @param requiredHeight The height of the target to render to
  101788. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101789. * @param depthStencilTexture The depth stencil texture to use to render
  101790. * @param lodLevel defines le lod level to bind to the frame buffer
  101791. */
  101792. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101793. /** @hidden */
  101794. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101795. /**
  101796. * Unbind the current render target texture from the webGL context
  101797. * @param texture defines the render target texture to unbind
  101798. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101799. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101800. */
  101801. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101802. /**
  101803. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101804. */
  101805. flushFramebuffer(): void;
  101806. /**
  101807. * Unbind the current render target and bind the default framebuffer
  101808. */
  101809. restoreDefaultFramebuffer(): void;
  101810. /** @hidden */
  101811. protected _resetVertexBufferBinding(): void;
  101812. /**
  101813. * Creates a vertex buffer
  101814. * @param data the data for the vertex buffer
  101815. * @returns the new WebGL static buffer
  101816. */
  101817. createVertexBuffer(data: DataArray): DataBuffer;
  101818. private _createVertexBuffer;
  101819. /**
  101820. * Creates a dynamic vertex buffer
  101821. * @param data the data for the dynamic vertex buffer
  101822. * @returns the new WebGL dynamic buffer
  101823. */
  101824. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101825. protected _resetIndexBufferBinding(): void;
  101826. /**
  101827. * Creates a new index buffer
  101828. * @param indices defines the content of the index buffer
  101829. * @param updatable defines if the index buffer must be updatable
  101830. * @returns a new webGL buffer
  101831. */
  101832. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101833. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101834. /**
  101835. * Bind a webGL buffer to the webGL context
  101836. * @param buffer defines the buffer to bind
  101837. */
  101838. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101839. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101840. private bindBuffer;
  101841. /**
  101842. * update the bound buffer with the given data
  101843. * @param data defines the data to update
  101844. */
  101845. updateArrayBuffer(data: Float32Array): void;
  101846. private _vertexAttribPointer;
  101847. private _bindIndexBufferWithCache;
  101848. private _bindVertexBuffersAttributes;
  101849. /**
  101850. * Records a vertex array object
  101851. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101852. * @param vertexBuffers defines the list of vertex buffers to store
  101853. * @param indexBuffer defines the index buffer to store
  101854. * @param effect defines the effect to store
  101855. * @returns the new vertex array object
  101856. */
  101857. recordVertexArrayObject(vertexBuffers: {
  101858. [key: string]: VertexBuffer;
  101859. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101860. /**
  101861. * Bind a specific vertex array object
  101862. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101863. * @param vertexArrayObject defines the vertex array object to bind
  101864. * @param indexBuffer defines the index buffer to bind
  101865. */
  101866. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101867. /**
  101868. * Bind webGl buffers directly to the webGL context
  101869. * @param vertexBuffer defines the vertex buffer to bind
  101870. * @param indexBuffer defines the index buffer to bind
  101871. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101872. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101873. * @param effect defines the effect associated with the vertex buffer
  101874. */
  101875. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101876. private _unbindVertexArrayObject;
  101877. /**
  101878. * Bind a list of vertex buffers to the webGL context
  101879. * @param vertexBuffers defines the list of vertex buffers to bind
  101880. * @param indexBuffer defines the index buffer to bind
  101881. * @param effect defines the effect associated with the vertex buffers
  101882. */
  101883. bindBuffers(vertexBuffers: {
  101884. [key: string]: Nullable<VertexBuffer>;
  101885. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101886. /**
  101887. * Unbind all instance attributes
  101888. */
  101889. unbindInstanceAttributes(): void;
  101890. /**
  101891. * Release and free the memory of a vertex array object
  101892. * @param vao defines the vertex array object to delete
  101893. */
  101894. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101895. /** @hidden */
  101896. _releaseBuffer(buffer: DataBuffer): boolean;
  101897. protected _deleteBuffer(buffer: DataBuffer): void;
  101898. /**
  101899. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101900. * @param instancesBuffer defines the webGL buffer to update and bind
  101901. * @param data defines the data to store in the buffer
  101902. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101903. */
  101904. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101905. /**
  101906. * Bind the content of a webGL buffer used with instanciation
  101907. * @param instancesBuffer defines the webGL buffer to bind
  101908. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101909. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101910. */
  101911. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101912. /**
  101913. * Disable the instance attribute corresponding to the name in parameter
  101914. * @param name defines the name of the attribute to disable
  101915. */
  101916. disableInstanceAttributeByName(name: string): void;
  101917. /**
  101918. * Disable the instance attribute corresponding to the location in parameter
  101919. * @param attributeLocation defines the attribute location of the attribute to disable
  101920. */
  101921. disableInstanceAttribute(attributeLocation: number): void;
  101922. /**
  101923. * Disable the attribute corresponding to the location in parameter
  101924. * @param attributeLocation defines the attribute location of the attribute to disable
  101925. */
  101926. disableAttributeByIndex(attributeLocation: number): void;
  101927. /**
  101928. * Send a draw order
  101929. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101930. * @param indexStart defines the starting index
  101931. * @param indexCount defines the number of index to draw
  101932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101933. */
  101934. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101935. /**
  101936. * Draw a list of points
  101937. * @param verticesStart defines the index of first vertex to draw
  101938. * @param verticesCount defines the count of vertices to draw
  101939. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101940. */
  101941. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101942. /**
  101943. * Draw a list of unindexed primitives
  101944. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101945. * @param verticesStart defines the index of first vertex to draw
  101946. * @param verticesCount defines the count of vertices to draw
  101947. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101948. */
  101949. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101950. /**
  101951. * Draw a list of indexed primitives
  101952. * @param fillMode defines the primitive to use
  101953. * @param indexStart defines the starting index
  101954. * @param indexCount defines the number of index to draw
  101955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101956. */
  101957. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101958. /**
  101959. * Draw a list of unindexed primitives
  101960. * @param fillMode defines the primitive to use
  101961. * @param verticesStart defines the index of first vertex to draw
  101962. * @param verticesCount defines the count of vertices to draw
  101963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101964. */
  101965. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101966. private _drawMode;
  101967. /** @hidden */
  101968. protected _reportDrawCall(): void;
  101969. /** @hidden */
  101970. _releaseEffect(effect: Effect): void;
  101971. /** @hidden */
  101972. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101973. /**
  101974. * Create a new effect (used to store vertex/fragment shaders)
  101975. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101976. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101977. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101978. * @param samplers defines an array of string used to represent textures
  101979. * @param defines defines the string containing the defines to use to compile the shaders
  101980. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101981. * @param onCompiled defines a function to call when the effect creation is successful
  101982. * @param onError defines a function to call when the effect creation has failed
  101983. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101984. * @returns the new Effect
  101985. */
  101986. 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;
  101987. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101988. private _compileShader;
  101989. private _compileRawShader;
  101990. /**
  101991. * Directly creates a webGL program
  101992. * @param pipelineContext defines the pipeline context to attach to
  101993. * @param vertexCode defines the vertex shader code to use
  101994. * @param fragmentCode defines the fragment shader code to use
  101995. * @param context defines the webGL context to use (if not set, the current one will be used)
  101996. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101997. * @returns the new webGL program
  101998. */
  101999. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102000. /**
  102001. * Creates a webGL program
  102002. * @param pipelineContext defines the pipeline context to attach to
  102003. * @param vertexCode defines the vertex shader code to use
  102004. * @param fragmentCode defines the fragment shader code to use
  102005. * @param defines defines the string containing the defines to use to compile the shaders
  102006. * @param context defines the webGL context to use (if not set, the current one will be used)
  102007. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102008. * @returns the new webGL program
  102009. */
  102010. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102011. /**
  102012. * Creates a new pipeline context
  102013. * @returns the new pipeline
  102014. */
  102015. createPipelineContext(): IPipelineContext;
  102016. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102017. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  102018. /** @hidden */
  102019. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  102020. /** @hidden */
  102021. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  102022. /** @hidden */
  102023. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  102024. /**
  102025. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  102026. * @param pipelineContext defines the pipeline context to use
  102027. * @param uniformsNames defines the list of uniform names
  102028. * @returns an array of webGL uniform locations
  102029. */
  102030. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  102031. /**
  102032. * Gets the lsit of active attributes for a given webGL program
  102033. * @param pipelineContext defines the pipeline context to use
  102034. * @param attributesNames defines the list of attribute names to get
  102035. * @returns an array of indices indicating the offset of each attribute
  102036. */
  102037. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  102038. /**
  102039. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  102040. * @param effect defines the effect to activate
  102041. */
  102042. enableEffect(effect: Nullable<Effect>): void;
  102043. /**
  102044. * Set the value of an uniform to a number (int)
  102045. * @param uniform defines the webGL uniform location where to store the value
  102046. * @param value defines the int number to store
  102047. */
  102048. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102049. /**
  102050. * Set the value of an uniform to an array of int32
  102051. * @param uniform defines the webGL uniform location where to store the value
  102052. * @param array defines the array of int32 to store
  102053. */
  102054. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102055. /**
  102056. * Set the value of an uniform to an array of int32 (stored as vec2)
  102057. * @param uniform defines the webGL uniform location where to store the value
  102058. * @param array defines the array of int32 to store
  102059. */
  102060. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102061. /**
  102062. * Set the value of an uniform to an array of int32 (stored as vec3)
  102063. * @param uniform defines the webGL uniform location where to store the value
  102064. * @param array defines the array of int32 to store
  102065. */
  102066. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102067. /**
  102068. * Set the value of an uniform to an array of int32 (stored as vec4)
  102069. * @param uniform defines the webGL uniform location where to store the value
  102070. * @param array defines the array of int32 to store
  102071. */
  102072. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102073. /**
  102074. * Set the value of an uniform to an array of number
  102075. * @param uniform defines the webGL uniform location where to store the value
  102076. * @param array defines the array of number to store
  102077. */
  102078. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102079. /**
  102080. * Set the value of an uniform to an array of number (stored as vec2)
  102081. * @param uniform defines the webGL uniform location where to store the value
  102082. * @param array defines the array of number to store
  102083. */
  102084. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102085. /**
  102086. * Set the value of an uniform to an array of number (stored as vec3)
  102087. * @param uniform defines the webGL uniform location where to store the value
  102088. * @param array defines the array of number to store
  102089. */
  102090. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102091. /**
  102092. * Set the value of an uniform to an array of number (stored as vec4)
  102093. * @param uniform defines the webGL uniform location where to store the value
  102094. * @param array defines the array of number to store
  102095. */
  102096. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102097. /**
  102098. * Set the value of an uniform to an array of float32 (stored as matrices)
  102099. * @param uniform defines the webGL uniform location where to store the value
  102100. * @param matrices defines the array of float32 to store
  102101. */
  102102. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102103. /**
  102104. * Set the value of an uniform to a matrix (3x3)
  102105. * @param uniform defines the webGL uniform location where to store the value
  102106. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102107. */
  102108. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102109. /**
  102110. * Set the value of an uniform to a matrix (2x2)
  102111. * @param uniform defines the webGL uniform location where to store the value
  102112. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102113. */
  102114. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102115. /**
  102116. * Set the value of an uniform to a number (float)
  102117. * @param uniform defines the webGL uniform location where to store the value
  102118. * @param value defines the float number to store
  102119. */
  102120. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102121. /**
  102122. * Set the value of an uniform to a vec2
  102123. * @param uniform defines the webGL uniform location where to store the value
  102124. * @param x defines the 1st component of the value
  102125. * @param y defines the 2nd component of the value
  102126. */
  102127. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102128. /**
  102129. * Set the value of an uniform to a vec3
  102130. * @param uniform defines the webGL uniform location where to store the value
  102131. * @param x defines the 1st component of the value
  102132. * @param y defines the 2nd component of the value
  102133. * @param z defines the 3rd component of the value
  102134. */
  102135. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102136. /**
  102137. * Set the value of an uniform to a vec4
  102138. * @param uniform defines the webGL uniform location where to store the value
  102139. * @param x defines the 1st component of the value
  102140. * @param y defines the 2nd component of the value
  102141. * @param z defines the 3rd component of the value
  102142. * @param w defines the 4th component of the value
  102143. */
  102144. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102145. /**
  102146. * Apply all cached states (depth, culling, stencil and alpha)
  102147. */
  102148. applyStates(): void;
  102149. /**
  102150. * Enable or disable color writing
  102151. * @param enable defines the state to set
  102152. */
  102153. setColorWrite(enable: boolean): void;
  102154. /**
  102155. * Gets a boolean indicating if color writing is enabled
  102156. * @returns the current color writing state
  102157. */
  102158. getColorWrite(): boolean;
  102159. /**
  102160. * Gets the depth culling state manager
  102161. */
  102162. get depthCullingState(): DepthCullingState;
  102163. /**
  102164. * Gets the alpha state manager
  102165. */
  102166. get alphaState(): AlphaState;
  102167. /**
  102168. * Gets the stencil state manager
  102169. */
  102170. get stencilState(): StencilState;
  102171. /**
  102172. * Clears the list of texture accessible through engine.
  102173. * This can help preventing texture load conflict due to name collision.
  102174. */
  102175. clearInternalTexturesCache(): void;
  102176. /**
  102177. * Force the entire cache to be cleared
  102178. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102179. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102180. */
  102181. wipeCaches(bruteForce?: boolean): void;
  102182. /** @hidden */
  102183. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102184. min: number;
  102185. mag: number;
  102186. };
  102187. /** @hidden */
  102188. _createTexture(): WebGLTexture;
  102189. /**
  102190. * Usually called from Texture.ts.
  102191. * Passed information to create a WebGLTexture
  102192. * @param urlArg defines a value which contains one of the following:
  102193. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102194. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102195. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102196. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102197. * @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)
  102198. * @param scene needed for loading to the correct scene
  102199. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102200. * @param onLoad optional callback to be called upon successful completion
  102201. * @param onError optional callback to be called upon failure
  102202. * @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
  102203. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102204. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102205. * @param forcedExtension defines the extension to use to pick the right loader
  102206. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102207. * @param mimeType defines an optional mime type
  102208. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102209. */
  102210. 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;
  102211. /**
  102212. * Loads an image as an HTMLImageElement.
  102213. * @param input url string, ArrayBuffer, or Blob to load
  102214. * @param onLoad callback called when the image successfully loads
  102215. * @param onError callback called when the image fails to load
  102216. * @param offlineProvider offline provider for caching
  102217. * @param mimeType optional mime type
  102218. * @returns the HTMLImageElement of the loaded image
  102219. * @hidden
  102220. */
  102221. 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>;
  102222. /**
  102223. * @hidden
  102224. */
  102225. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102226. /**
  102227. * Creates a raw texture
  102228. * @param data defines the data to store in the texture
  102229. * @param width defines the width of the texture
  102230. * @param height defines the height of the texture
  102231. * @param format defines the format of the data
  102232. * @param generateMipMaps defines if the engine should generate the mip levels
  102233. * @param invertY defines if data must be stored with Y axis inverted
  102234. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102235. * @param compression defines the compression used (null by default)
  102236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102237. * @returns the raw texture inside an InternalTexture
  102238. */
  102239. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102240. /**
  102241. * Creates a new raw cube texture
  102242. * @param data defines the array of data to use to create each face
  102243. * @param size defines the size of the textures
  102244. * @param format defines the format of the data
  102245. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102246. * @param generateMipMaps defines if the engine should generate the mip levels
  102247. * @param invertY defines if data must be stored with Y axis inverted
  102248. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102249. * @param compression defines the compression used (null by default)
  102250. * @returns the cube texture as an InternalTexture
  102251. */
  102252. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102253. /**
  102254. * Creates a new raw 3D texture
  102255. * @param data defines the data used to create the texture
  102256. * @param width defines the width of the texture
  102257. * @param height defines the height of the texture
  102258. * @param depth defines the depth of the texture
  102259. * @param format defines the format of the texture
  102260. * @param generateMipMaps defines if the engine must generate mip levels
  102261. * @param invertY defines if data must be stored with Y axis inverted
  102262. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102263. * @param compression defines the compressed used (can be null)
  102264. * @param textureType defines the compressed used (can be null)
  102265. * @returns a new raw 3D texture (stored in an InternalTexture)
  102266. */
  102267. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102268. /**
  102269. * Creates a new raw 2D array texture
  102270. * @param data defines the data used to create the texture
  102271. * @param width defines the width of the texture
  102272. * @param height defines the height of the texture
  102273. * @param depth defines the number of layers of the texture
  102274. * @param format defines the format of the texture
  102275. * @param generateMipMaps defines if the engine must generate mip levels
  102276. * @param invertY defines if data must be stored with Y axis inverted
  102277. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102278. * @param compression defines the compressed used (can be null)
  102279. * @param textureType defines the compressed used (can be null)
  102280. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102281. */
  102282. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102283. private _unpackFlipYCached;
  102284. /**
  102285. * In case you are sharing the context with other applications, it might
  102286. * be interested to not cache the unpack flip y state to ensure a consistent
  102287. * value would be set.
  102288. */
  102289. enableUnpackFlipYCached: boolean;
  102290. /** @hidden */
  102291. _unpackFlipY(value: boolean): void;
  102292. /** @hidden */
  102293. _getUnpackAlignement(): number;
  102294. private _getTextureTarget;
  102295. /**
  102296. * Update the sampling mode of a given texture
  102297. * @param samplingMode defines the required sampling mode
  102298. * @param texture defines the texture to update
  102299. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102300. */
  102301. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102302. /**
  102303. * Update the sampling mode of a given texture
  102304. * @param texture defines the texture to update
  102305. * @param wrapU defines the texture wrap mode of the u coordinates
  102306. * @param wrapV defines the texture wrap mode of the v coordinates
  102307. * @param wrapR defines the texture wrap mode of the r coordinates
  102308. */
  102309. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102310. /** @hidden */
  102311. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102312. width: number;
  102313. height: number;
  102314. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102315. /** @hidden */
  102316. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102317. /** @hidden */
  102318. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102319. /** @hidden */
  102320. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102321. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102322. private _prepareWebGLTexture;
  102323. /** @hidden */
  102324. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102325. private _getDepthStencilBuffer;
  102326. /** @hidden */
  102327. _releaseFramebufferObjects(texture: InternalTexture): void;
  102328. /** @hidden */
  102329. _releaseTexture(texture: InternalTexture): void;
  102330. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102331. protected _setProgram(program: WebGLProgram): void;
  102332. protected _boundUniforms: {
  102333. [key: number]: WebGLUniformLocation;
  102334. };
  102335. /**
  102336. * Binds an effect to the webGL context
  102337. * @param effect defines the effect to bind
  102338. */
  102339. bindSamplers(effect: Effect): void;
  102340. private _activateCurrentTexture;
  102341. /** @hidden */
  102342. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102343. /** @hidden */
  102344. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102345. /**
  102346. * Unbind all textures from the webGL context
  102347. */
  102348. unbindAllTextures(): void;
  102349. /**
  102350. * Sets a texture to the according uniform.
  102351. * @param channel The texture channel
  102352. * @param uniform The uniform to set
  102353. * @param texture The texture to apply
  102354. */
  102355. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102356. private _bindSamplerUniformToChannel;
  102357. private _getTextureWrapMode;
  102358. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102359. /**
  102360. * Sets an array of texture to the webGL context
  102361. * @param channel defines the channel where the texture array must be set
  102362. * @param uniform defines the associated uniform location
  102363. * @param textures defines the array of textures to bind
  102364. */
  102365. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102366. /** @hidden */
  102367. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  102368. private _setTextureParameterFloat;
  102369. private _setTextureParameterInteger;
  102370. /**
  102371. * Unbind all vertex attributes from the webGL context
  102372. */
  102373. unbindAllAttributes(): void;
  102374. /**
  102375. * 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
  102376. */
  102377. releaseEffects(): void;
  102378. /**
  102379. * Dispose and release all associated resources
  102380. */
  102381. dispose(): void;
  102382. /**
  102383. * Attach a new callback raised when context lost event is fired
  102384. * @param callback defines the callback to call
  102385. */
  102386. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102387. /**
  102388. * Attach a new callback raised when context restored event is fired
  102389. * @param callback defines the callback to call
  102390. */
  102391. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102392. /**
  102393. * Get the current error code of the webGL context
  102394. * @returns the error code
  102395. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102396. */
  102397. getError(): number;
  102398. private _canRenderToFloatFramebuffer;
  102399. private _canRenderToHalfFloatFramebuffer;
  102400. private _canRenderToFramebuffer;
  102401. /** @hidden */
  102402. _getWebGLTextureType(type: number): number;
  102403. /** @hidden */
  102404. _getInternalFormat(format: number): number;
  102405. /** @hidden */
  102406. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102407. /** @hidden */
  102408. _getRGBAMultiSampleBufferFormat(type: number): number;
  102409. /** @hidden */
  102410. _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;
  102411. /**
  102412. * Loads a file from a url
  102413. * @param url url to load
  102414. * @param onSuccess callback called when the file successfully loads
  102415. * @param onProgress callback called while file is loading (if the server supports this mode)
  102416. * @param offlineProvider defines the offline provider for caching
  102417. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102418. * @param onError callback called when the file fails to load
  102419. * @returns a file request object
  102420. * @hidden
  102421. */
  102422. 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;
  102423. /**
  102424. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102425. * @param x defines the x coordinate of the rectangle where pixels must be read
  102426. * @param y defines the y coordinate of the rectangle where pixels must be read
  102427. * @param width defines the width of the rectangle where pixels must be read
  102428. * @param height defines the height of the rectangle where pixels must be read
  102429. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102430. * @returns a Uint8Array containing RGBA colors
  102431. */
  102432. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102433. private static _isSupported;
  102434. /**
  102435. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102436. * @returns true if the engine can be created
  102437. * @ignorenaming
  102438. */
  102439. static isSupported(): boolean;
  102440. /**
  102441. * Find the next highest power of two.
  102442. * @param x Number to start search from.
  102443. * @return Next highest power of two.
  102444. */
  102445. static CeilingPOT(x: number): number;
  102446. /**
  102447. * Find the next lowest power of two.
  102448. * @param x Number to start search from.
  102449. * @return Next lowest power of two.
  102450. */
  102451. static FloorPOT(x: number): number;
  102452. /**
  102453. * Find the nearest power of two.
  102454. * @param x Number to start search from.
  102455. * @return Next nearest power of two.
  102456. */
  102457. static NearestPOT(x: number): number;
  102458. /**
  102459. * Get the closest exponent of two
  102460. * @param value defines the value to approximate
  102461. * @param max defines the maximum value to return
  102462. * @param mode defines how to define the closest value
  102463. * @returns closest exponent of two of the given value
  102464. */
  102465. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102466. /**
  102467. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102468. * @param func - the function to be called
  102469. * @param requester - the object that will request the next frame. Falls back to window.
  102470. * @returns frame number
  102471. */
  102472. static QueueNewFrame(func: () => void, requester?: any): number;
  102473. /**
  102474. * Gets host document
  102475. * @returns the host document object
  102476. */
  102477. getHostDocument(): Nullable<Document>;
  102478. }
  102479. }
  102480. declare module BABYLON {
  102481. /**
  102482. * Class representing spherical harmonics coefficients to the 3rd degree
  102483. */
  102484. export class SphericalHarmonics {
  102485. /**
  102486. * Defines whether or not the harmonics have been prescaled for rendering.
  102487. */
  102488. preScaled: boolean;
  102489. /**
  102490. * The l0,0 coefficients of the spherical harmonics
  102491. */
  102492. l00: Vector3;
  102493. /**
  102494. * The l1,-1 coefficients of the spherical harmonics
  102495. */
  102496. l1_1: Vector3;
  102497. /**
  102498. * The l1,0 coefficients of the spherical harmonics
  102499. */
  102500. l10: Vector3;
  102501. /**
  102502. * The l1,1 coefficients of the spherical harmonics
  102503. */
  102504. l11: Vector3;
  102505. /**
  102506. * The l2,-2 coefficients of the spherical harmonics
  102507. */
  102508. l2_2: Vector3;
  102509. /**
  102510. * The l2,-1 coefficients of the spherical harmonics
  102511. */
  102512. l2_1: Vector3;
  102513. /**
  102514. * The l2,0 coefficients of the spherical harmonics
  102515. */
  102516. l20: Vector3;
  102517. /**
  102518. * The l2,1 coefficients of the spherical harmonics
  102519. */
  102520. l21: Vector3;
  102521. /**
  102522. * The l2,2 coefficients of the spherical harmonics
  102523. */
  102524. l22: Vector3;
  102525. /**
  102526. * Adds a light to the spherical harmonics
  102527. * @param direction the direction of the light
  102528. * @param color the color of the light
  102529. * @param deltaSolidAngle the delta solid angle of the light
  102530. */
  102531. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102532. /**
  102533. * Scales the spherical harmonics by the given amount
  102534. * @param scale the amount to scale
  102535. */
  102536. scaleInPlace(scale: number): void;
  102537. /**
  102538. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102539. *
  102540. * ```
  102541. * E_lm = A_l * L_lm
  102542. * ```
  102543. *
  102544. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102545. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102546. * the scaling factors are given in equation 9.
  102547. */
  102548. convertIncidentRadianceToIrradiance(): void;
  102549. /**
  102550. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102551. *
  102552. * ```
  102553. * L = (1/pi) * E * rho
  102554. * ```
  102555. *
  102556. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102557. */
  102558. convertIrradianceToLambertianRadiance(): void;
  102559. /**
  102560. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102561. * required operations at run time.
  102562. *
  102563. * This is simply done by scaling back the SH with Ylm constants parameter.
  102564. * The trigonometric part being applied by the shader at run time.
  102565. */
  102566. preScaleForRendering(): void;
  102567. /**
  102568. * Constructs a spherical harmonics from an array.
  102569. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102570. * @returns the spherical harmonics
  102571. */
  102572. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102573. /**
  102574. * Gets the spherical harmonics from polynomial
  102575. * @param polynomial the spherical polynomial
  102576. * @returns the spherical harmonics
  102577. */
  102578. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102579. }
  102580. /**
  102581. * Class representing spherical polynomial coefficients to the 3rd degree
  102582. */
  102583. export class SphericalPolynomial {
  102584. private _harmonics;
  102585. /**
  102586. * The spherical harmonics used to create the polynomials.
  102587. */
  102588. get preScaledHarmonics(): SphericalHarmonics;
  102589. /**
  102590. * The x coefficients of the spherical polynomial
  102591. */
  102592. x: Vector3;
  102593. /**
  102594. * The y coefficients of the spherical polynomial
  102595. */
  102596. y: Vector3;
  102597. /**
  102598. * The z coefficients of the spherical polynomial
  102599. */
  102600. z: Vector3;
  102601. /**
  102602. * The xx coefficients of the spherical polynomial
  102603. */
  102604. xx: Vector3;
  102605. /**
  102606. * The yy coefficients of the spherical polynomial
  102607. */
  102608. yy: Vector3;
  102609. /**
  102610. * The zz coefficients of the spherical polynomial
  102611. */
  102612. zz: Vector3;
  102613. /**
  102614. * The xy coefficients of the spherical polynomial
  102615. */
  102616. xy: Vector3;
  102617. /**
  102618. * The yz coefficients of the spherical polynomial
  102619. */
  102620. yz: Vector3;
  102621. /**
  102622. * The zx coefficients of the spherical polynomial
  102623. */
  102624. zx: Vector3;
  102625. /**
  102626. * Adds an ambient color to the spherical polynomial
  102627. * @param color the color to add
  102628. */
  102629. addAmbient(color: Color3): void;
  102630. /**
  102631. * Scales the spherical polynomial by the given amount
  102632. * @param scale the amount to scale
  102633. */
  102634. scaleInPlace(scale: number): void;
  102635. /**
  102636. * Gets the spherical polynomial from harmonics
  102637. * @param harmonics the spherical harmonics
  102638. * @returns the spherical polynomial
  102639. */
  102640. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102641. /**
  102642. * Constructs a spherical polynomial from an array.
  102643. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102644. * @returns the spherical polynomial
  102645. */
  102646. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102647. }
  102648. }
  102649. declare module BABYLON {
  102650. /**
  102651. * Defines the source of the internal texture
  102652. */
  102653. export enum InternalTextureSource {
  102654. /**
  102655. * The source of the texture data is unknown
  102656. */
  102657. Unknown = 0,
  102658. /**
  102659. * Texture data comes from an URL
  102660. */
  102661. Url = 1,
  102662. /**
  102663. * Texture data is only used for temporary storage
  102664. */
  102665. Temp = 2,
  102666. /**
  102667. * Texture data comes from raw data (ArrayBuffer)
  102668. */
  102669. Raw = 3,
  102670. /**
  102671. * Texture content is dynamic (video or dynamic texture)
  102672. */
  102673. Dynamic = 4,
  102674. /**
  102675. * Texture content is generated by rendering to it
  102676. */
  102677. RenderTarget = 5,
  102678. /**
  102679. * Texture content is part of a multi render target process
  102680. */
  102681. MultiRenderTarget = 6,
  102682. /**
  102683. * Texture data comes from a cube data file
  102684. */
  102685. Cube = 7,
  102686. /**
  102687. * Texture data comes from a raw cube data
  102688. */
  102689. CubeRaw = 8,
  102690. /**
  102691. * Texture data come from a prefiltered cube data file
  102692. */
  102693. CubePrefiltered = 9,
  102694. /**
  102695. * Texture content is raw 3D data
  102696. */
  102697. Raw3D = 10,
  102698. /**
  102699. * Texture content is raw 2D array data
  102700. */
  102701. Raw2DArray = 11,
  102702. /**
  102703. * Texture content is a depth texture
  102704. */
  102705. Depth = 12,
  102706. /**
  102707. * Texture data comes from a raw cube data encoded with RGBD
  102708. */
  102709. CubeRawRGBD = 13
  102710. }
  102711. /**
  102712. * Class used to store data associated with WebGL texture data for the engine
  102713. * This class should not be used directly
  102714. */
  102715. export class InternalTexture {
  102716. /** @hidden */
  102717. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102718. /**
  102719. * Defines if the texture is ready
  102720. */
  102721. isReady: boolean;
  102722. /**
  102723. * Defines if the texture is a cube texture
  102724. */
  102725. isCube: boolean;
  102726. /**
  102727. * Defines if the texture contains 3D data
  102728. */
  102729. is3D: boolean;
  102730. /**
  102731. * Defines if the texture contains 2D array data
  102732. */
  102733. is2DArray: boolean;
  102734. /**
  102735. * Defines if the texture contains multiview data
  102736. */
  102737. isMultiview: boolean;
  102738. /**
  102739. * Gets the URL used to load this texture
  102740. */
  102741. url: string;
  102742. /**
  102743. * Gets the sampling mode of the texture
  102744. */
  102745. samplingMode: number;
  102746. /**
  102747. * Gets a boolean indicating if the texture needs mipmaps generation
  102748. */
  102749. generateMipMaps: boolean;
  102750. /**
  102751. * Gets the number of samples used by the texture (WebGL2+ only)
  102752. */
  102753. samples: number;
  102754. /**
  102755. * Gets the type of the texture (int, float...)
  102756. */
  102757. type: number;
  102758. /**
  102759. * Gets the format of the texture (RGB, RGBA...)
  102760. */
  102761. format: number;
  102762. /**
  102763. * Observable called when the texture is loaded
  102764. */
  102765. onLoadedObservable: Observable<InternalTexture>;
  102766. /**
  102767. * Gets the width of the texture
  102768. */
  102769. width: number;
  102770. /**
  102771. * Gets the height of the texture
  102772. */
  102773. height: number;
  102774. /**
  102775. * Gets the depth of the texture
  102776. */
  102777. depth: number;
  102778. /**
  102779. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102780. */
  102781. baseWidth: number;
  102782. /**
  102783. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102784. */
  102785. baseHeight: number;
  102786. /**
  102787. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102788. */
  102789. baseDepth: number;
  102790. /**
  102791. * Gets a boolean indicating if the texture is inverted on Y axis
  102792. */
  102793. invertY: boolean;
  102794. /** @hidden */
  102795. _invertVScale: boolean;
  102796. /** @hidden */
  102797. _associatedChannel: number;
  102798. /** @hidden */
  102799. _source: InternalTextureSource;
  102800. /** @hidden */
  102801. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102802. /** @hidden */
  102803. _bufferView: Nullable<ArrayBufferView>;
  102804. /** @hidden */
  102805. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102806. /** @hidden */
  102807. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102808. /** @hidden */
  102809. _size: number;
  102810. /** @hidden */
  102811. _extension: string;
  102812. /** @hidden */
  102813. _files: Nullable<string[]>;
  102814. /** @hidden */
  102815. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102816. /** @hidden */
  102817. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102818. /** @hidden */
  102819. _framebuffer: Nullable<WebGLFramebuffer>;
  102820. /** @hidden */
  102821. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102822. /** @hidden */
  102823. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102824. /** @hidden */
  102825. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102826. /** @hidden */
  102827. _attachments: Nullable<number[]>;
  102828. /** @hidden */
  102829. _cachedCoordinatesMode: Nullable<number>;
  102830. /** @hidden */
  102831. _cachedWrapU: Nullable<number>;
  102832. /** @hidden */
  102833. _cachedWrapV: Nullable<number>;
  102834. /** @hidden */
  102835. _cachedWrapR: Nullable<number>;
  102836. /** @hidden */
  102837. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102838. /** @hidden */
  102839. _isDisabled: boolean;
  102840. /** @hidden */
  102841. _compression: Nullable<string>;
  102842. /** @hidden */
  102843. _generateStencilBuffer: boolean;
  102844. /** @hidden */
  102845. _generateDepthBuffer: boolean;
  102846. /** @hidden */
  102847. _comparisonFunction: number;
  102848. /** @hidden */
  102849. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102850. /** @hidden */
  102851. _lodGenerationScale: number;
  102852. /** @hidden */
  102853. _lodGenerationOffset: number;
  102854. /** @hidden */
  102855. _colorTextureArray: Nullable<WebGLTexture>;
  102856. /** @hidden */
  102857. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102858. /** @hidden */
  102859. _lodTextureHigh: Nullable<BaseTexture>;
  102860. /** @hidden */
  102861. _lodTextureMid: Nullable<BaseTexture>;
  102862. /** @hidden */
  102863. _lodTextureLow: Nullable<BaseTexture>;
  102864. /** @hidden */
  102865. _isRGBD: boolean;
  102866. /** @hidden */
  102867. _linearSpecularLOD: boolean;
  102868. /** @hidden */
  102869. _irradianceTexture: Nullable<BaseTexture>;
  102870. /** @hidden */
  102871. _webGLTexture: Nullable<WebGLTexture>;
  102872. /** @hidden */
  102873. _references: number;
  102874. private _engine;
  102875. /**
  102876. * Gets the Engine the texture belongs to.
  102877. * @returns The babylon engine
  102878. */
  102879. getEngine(): ThinEngine;
  102880. /**
  102881. * Gets the data source type of the texture
  102882. */
  102883. get source(): InternalTextureSource;
  102884. /**
  102885. * Creates a new InternalTexture
  102886. * @param engine defines the engine to use
  102887. * @param source defines the type of data that will be used
  102888. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102889. */
  102890. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102891. /**
  102892. * Increments the number of references (ie. the number of Texture that point to it)
  102893. */
  102894. incrementReferences(): void;
  102895. /**
  102896. * Change the size of the texture (not the size of the content)
  102897. * @param width defines the new width
  102898. * @param height defines the new height
  102899. * @param depth defines the new depth (1 by default)
  102900. */
  102901. updateSize(width: int, height: int, depth?: int): void;
  102902. /** @hidden */
  102903. _rebuild(): void;
  102904. /** @hidden */
  102905. _swapAndDie(target: InternalTexture): void;
  102906. /**
  102907. * Dispose the current allocated resources
  102908. */
  102909. dispose(): void;
  102910. }
  102911. }
  102912. declare module BABYLON {
  102913. /**
  102914. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102916. */
  102917. export class Analyser {
  102918. /**
  102919. * Gets or sets the smoothing
  102920. * @ignorenaming
  102921. */
  102922. SMOOTHING: number;
  102923. /**
  102924. * Gets or sets the FFT table size
  102925. * @ignorenaming
  102926. */
  102927. FFT_SIZE: number;
  102928. /**
  102929. * Gets or sets the bar graph amplitude
  102930. * @ignorenaming
  102931. */
  102932. BARGRAPHAMPLITUDE: number;
  102933. /**
  102934. * Gets or sets the position of the debug canvas
  102935. * @ignorenaming
  102936. */
  102937. DEBUGCANVASPOS: {
  102938. x: number;
  102939. y: number;
  102940. };
  102941. /**
  102942. * Gets or sets the debug canvas size
  102943. * @ignorenaming
  102944. */
  102945. DEBUGCANVASSIZE: {
  102946. width: number;
  102947. height: number;
  102948. };
  102949. private _byteFreqs;
  102950. private _byteTime;
  102951. private _floatFreqs;
  102952. private _webAudioAnalyser;
  102953. private _debugCanvas;
  102954. private _debugCanvasContext;
  102955. private _scene;
  102956. private _registerFunc;
  102957. private _audioEngine;
  102958. /**
  102959. * Creates a new analyser
  102960. * @param scene defines hosting scene
  102961. */
  102962. constructor(scene: Scene);
  102963. /**
  102964. * Get the number of data values you will have to play with for the visualization
  102965. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102966. * @returns a number
  102967. */
  102968. getFrequencyBinCount(): number;
  102969. /**
  102970. * Gets the current frequency data as a byte array
  102971. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102972. * @returns a Uint8Array
  102973. */
  102974. getByteFrequencyData(): Uint8Array;
  102975. /**
  102976. * Gets the current waveform as a byte array
  102977. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102978. * @returns a Uint8Array
  102979. */
  102980. getByteTimeDomainData(): Uint8Array;
  102981. /**
  102982. * Gets the current frequency data as a float array
  102983. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102984. * @returns a Float32Array
  102985. */
  102986. getFloatFrequencyData(): Float32Array;
  102987. /**
  102988. * Renders the debug canvas
  102989. */
  102990. drawDebugCanvas(): void;
  102991. /**
  102992. * Stops rendering the debug canvas and removes it
  102993. */
  102994. stopDebugCanvas(): void;
  102995. /**
  102996. * Connects two audio nodes
  102997. * @param inputAudioNode defines first node to connect
  102998. * @param outputAudioNode defines second node to connect
  102999. */
  103000. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  103001. /**
  103002. * Releases all associated resources
  103003. */
  103004. dispose(): void;
  103005. }
  103006. }
  103007. declare module BABYLON {
  103008. /**
  103009. * This represents an audio engine and it is responsible
  103010. * to play, synchronize and analyse sounds throughout the application.
  103011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103012. */
  103013. export interface IAudioEngine extends IDisposable {
  103014. /**
  103015. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103016. */
  103017. readonly canUseWebAudio: boolean;
  103018. /**
  103019. * Gets the current AudioContext if available.
  103020. */
  103021. readonly audioContext: Nullable<AudioContext>;
  103022. /**
  103023. * The master gain node defines the global audio volume of your audio engine.
  103024. */
  103025. readonly masterGain: GainNode;
  103026. /**
  103027. * Gets whether or not mp3 are supported by your browser.
  103028. */
  103029. readonly isMP3supported: boolean;
  103030. /**
  103031. * Gets whether or not ogg are supported by your browser.
  103032. */
  103033. readonly isOGGsupported: boolean;
  103034. /**
  103035. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103036. * @ignoreNaming
  103037. */
  103038. WarnedWebAudioUnsupported: boolean;
  103039. /**
  103040. * Defines if the audio engine relies on a custom unlocked button.
  103041. * In this case, the embedded button will not be displayed.
  103042. */
  103043. useCustomUnlockedButton: boolean;
  103044. /**
  103045. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  103046. */
  103047. readonly unlocked: boolean;
  103048. /**
  103049. * Event raised when audio has been unlocked on the browser.
  103050. */
  103051. onAudioUnlockedObservable: Observable<AudioEngine>;
  103052. /**
  103053. * Event raised when audio has been locked on the browser.
  103054. */
  103055. onAudioLockedObservable: Observable<AudioEngine>;
  103056. /**
  103057. * Flags the audio engine in Locked state.
  103058. * This happens due to new browser policies preventing audio to autoplay.
  103059. */
  103060. lock(): void;
  103061. /**
  103062. * Unlocks the audio engine once a user action has been done on the dom.
  103063. * This is helpful to resume play once browser policies have been satisfied.
  103064. */
  103065. unlock(): void;
  103066. }
  103067. /**
  103068. * This represents the default audio engine used in babylon.
  103069. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103071. */
  103072. export class AudioEngine implements IAudioEngine {
  103073. private _audioContext;
  103074. private _audioContextInitialized;
  103075. private _muteButton;
  103076. private _hostElement;
  103077. /**
  103078. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103079. */
  103080. canUseWebAudio: boolean;
  103081. /**
  103082. * The master gain node defines the global audio volume of your audio engine.
  103083. */
  103084. masterGain: GainNode;
  103085. /**
  103086. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103087. * @ignoreNaming
  103088. */
  103089. WarnedWebAudioUnsupported: boolean;
  103090. /**
  103091. * Gets whether or not mp3 are supported by your browser.
  103092. */
  103093. isMP3supported: boolean;
  103094. /**
  103095. * Gets whether or not ogg are supported by your browser.
  103096. */
  103097. isOGGsupported: boolean;
  103098. /**
  103099. * Gets whether audio has been unlocked on the device.
  103100. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103101. * a user interaction has happened.
  103102. */
  103103. unlocked: boolean;
  103104. /**
  103105. * Defines if the audio engine relies on a custom unlocked button.
  103106. * In this case, the embedded button will not be displayed.
  103107. */
  103108. useCustomUnlockedButton: boolean;
  103109. /**
  103110. * Event raised when audio has been unlocked on the browser.
  103111. */
  103112. onAudioUnlockedObservable: Observable<AudioEngine>;
  103113. /**
  103114. * Event raised when audio has been locked on the browser.
  103115. */
  103116. onAudioLockedObservable: Observable<AudioEngine>;
  103117. /**
  103118. * Gets the current AudioContext if available.
  103119. */
  103120. get audioContext(): Nullable<AudioContext>;
  103121. private _connectedAnalyser;
  103122. /**
  103123. * Instantiates a new audio engine.
  103124. *
  103125. * There should be only one per page as some browsers restrict the number
  103126. * of audio contexts you can create.
  103127. * @param hostElement defines the host element where to display the mute icon if necessary
  103128. */
  103129. constructor(hostElement?: Nullable<HTMLElement>);
  103130. /**
  103131. * Flags the audio engine in Locked state.
  103132. * This happens due to new browser policies preventing audio to autoplay.
  103133. */
  103134. lock(): void;
  103135. /**
  103136. * Unlocks the audio engine once a user action has been done on the dom.
  103137. * This is helpful to resume play once browser policies have been satisfied.
  103138. */
  103139. unlock(): void;
  103140. private _resumeAudioContext;
  103141. private _initializeAudioContext;
  103142. private _tryToRun;
  103143. private _triggerRunningState;
  103144. private _triggerSuspendedState;
  103145. private _displayMuteButton;
  103146. private _moveButtonToTopLeft;
  103147. private _onResize;
  103148. private _hideMuteButton;
  103149. /**
  103150. * Destroy and release the resources associated with the audio ccontext.
  103151. */
  103152. dispose(): void;
  103153. /**
  103154. * Gets the global volume sets on the master gain.
  103155. * @returns the global volume if set or -1 otherwise
  103156. */
  103157. getGlobalVolume(): number;
  103158. /**
  103159. * Sets the global volume of your experience (sets on the master gain).
  103160. * @param newVolume Defines the new global volume of the application
  103161. */
  103162. setGlobalVolume(newVolume: number): void;
  103163. /**
  103164. * Connect the audio engine to an audio analyser allowing some amazing
  103165. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103167. * @param analyser The analyser to connect to the engine
  103168. */
  103169. connectToAnalyser(analyser: Analyser): void;
  103170. }
  103171. }
  103172. declare module BABYLON {
  103173. /**
  103174. * Interface used to present a loading screen while loading a scene
  103175. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103176. */
  103177. export interface ILoadingScreen {
  103178. /**
  103179. * Function called to display the loading screen
  103180. */
  103181. displayLoadingUI: () => void;
  103182. /**
  103183. * Function called to hide the loading screen
  103184. */
  103185. hideLoadingUI: () => void;
  103186. /**
  103187. * Gets or sets the color to use for the background
  103188. */
  103189. loadingUIBackgroundColor: string;
  103190. /**
  103191. * Gets or sets the text to display while loading
  103192. */
  103193. loadingUIText: string;
  103194. }
  103195. /**
  103196. * Class used for the default loading screen
  103197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103198. */
  103199. export class DefaultLoadingScreen implements ILoadingScreen {
  103200. private _renderingCanvas;
  103201. private _loadingText;
  103202. private _loadingDivBackgroundColor;
  103203. private _loadingDiv;
  103204. private _loadingTextDiv;
  103205. /** Gets or sets the logo url to use for the default loading screen */
  103206. static DefaultLogoUrl: string;
  103207. /** Gets or sets the spinner url to use for the default loading screen */
  103208. static DefaultSpinnerUrl: string;
  103209. /**
  103210. * Creates a new default loading screen
  103211. * @param _renderingCanvas defines the canvas used to render the scene
  103212. * @param _loadingText defines the default text to display
  103213. * @param _loadingDivBackgroundColor defines the default background color
  103214. */
  103215. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103216. /**
  103217. * Function called to display the loading screen
  103218. */
  103219. displayLoadingUI(): void;
  103220. /**
  103221. * Function called to hide the loading screen
  103222. */
  103223. hideLoadingUI(): void;
  103224. /**
  103225. * Gets or sets the text to display while loading
  103226. */
  103227. set loadingUIText(text: string);
  103228. get loadingUIText(): string;
  103229. /**
  103230. * Gets or sets the color to use for the background
  103231. */
  103232. get loadingUIBackgroundColor(): string;
  103233. set loadingUIBackgroundColor(color: string);
  103234. private _resizeLoadingUI;
  103235. }
  103236. }
  103237. declare module BABYLON {
  103238. /**
  103239. * Interface for any object that can request an animation frame
  103240. */
  103241. export interface ICustomAnimationFrameRequester {
  103242. /**
  103243. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103244. */
  103245. renderFunction?: Function;
  103246. /**
  103247. * Called to request the next frame to render to
  103248. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103249. */
  103250. requestAnimationFrame: Function;
  103251. /**
  103252. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103253. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103254. */
  103255. requestID?: number;
  103256. }
  103257. }
  103258. declare module BABYLON {
  103259. /**
  103260. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103261. */
  103262. export class PerformanceMonitor {
  103263. private _enabled;
  103264. private _rollingFrameTime;
  103265. private _lastFrameTimeMs;
  103266. /**
  103267. * constructor
  103268. * @param frameSampleSize The number of samples required to saturate the sliding window
  103269. */
  103270. constructor(frameSampleSize?: number);
  103271. /**
  103272. * Samples current frame
  103273. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103274. */
  103275. sampleFrame(timeMs?: number): void;
  103276. /**
  103277. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103278. */
  103279. get averageFrameTime(): number;
  103280. /**
  103281. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103282. */
  103283. get averageFrameTimeVariance(): number;
  103284. /**
  103285. * Returns the frame time of the most recent frame
  103286. */
  103287. get instantaneousFrameTime(): number;
  103288. /**
  103289. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103290. */
  103291. get averageFPS(): number;
  103292. /**
  103293. * Returns the average framerate in frames per second using the most recent frame time
  103294. */
  103295. get instantaneousFPS(): number;
  103296. /**
  103297. * Returns true if enough samples have been taken to completely fill the sliding window
  103298. */
  103299. get isSaturated(): boolean;
  103300. /**
  103301. * Enables contributions to the sliding window sample set
  103302. */
  103303. enable(): void;
  103304. /**
  103305. * Disables contributions to the sliding window sample set
  103306. * Samples will not be interpolated over the disabled period
  103307. */
  103308. disable(): void;
  103309. /**
  103310. * Returns true if sampling is enabled
  103311. */
  103312. get isEnabled(): boolean;
  103313. /**
  103314. * Resets performance monitor
  103315. */
  103316. reset(): void;
  103317. }
  103318. /**
  103319. * RollingAverage
  103320. *
  103321. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103322. */
  103323. export class RollingAverage {
  103324. /**
  103325. * Current average
  103326. */
  103327. average: number;
  103328. /**
  103329. * Current variance
  103330. */
  103331. variance: number;
  103332. protected _samples: Array<number>;
  103333. protected _sampleCount: number;
  103334. protected _pos: number;
  103335. protected _m2: number;
  103336. /**
  103337. * constructor
  103338. * @param length The number of samples required to saturate the sliding window
  103339. */
  103340. constructor(length: number);
  103341. /**
  103342. * Adds a sample to the sample set
  103343. * @param v The sample value
  103344. */
  103345. add(v: number): void;
  103346. /**
  103347. * Returns previously added values or null if outside of history or outside the sliding window domain
  103348. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103349. * @return Value previously recorded with add() or null if outside of range
  103350. */
  103351. history(i: number): number;
  103352. /**
  103353. * Returns true if enough samples have been taken to completely fill the sliding window
  103354. * @return true if sample-set saturated
  103355. */
  103356. isSaturated(): boolean;
  103357. /**
  103358. * Resets the rolling average (equivalent to 0 samples taken so far)
  103359. */
  103360. reset(): void;
  103361. /**
  103362. * Wraps a value around the sample range boundaries
  103363. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103364. * @return Wrapped position in sample range
  103365. */
  103366. protected _wrapPosition(i: number): number;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * This class is used to track a performance counter which is number based.
  103372. * The user has access to many properties which give statistics of different nature.
  103373. *
  103374. * The implementer can track two kinds of Performance Counter: time and count.
  103375. * 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.
  103376. * 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.
  103377. */
  103378. export class PerfCounter {
  103379. /**
  103380. * Gets or sets a global boolean to turn on and off all the counters
  103381. */
  103382. static Enabled: boolean;
  103383. /**
  103384. * Returns the smallest value ever
  103385. */
  103386. get min(): number;
  103387. /**
  103388. * Returns the biggest value ever
  103389. */
  103390. get max(): number;
  103391. /**
  103392. * Returns the average value since the performance counter is running
  103393. */
  103394. get average(): number;
  103395. /**
  103396. * Returns the average value of the last second the counter was monitored
  103397. */
  103398. get lastSecAverage(): number;
  103399. /**
  103400. * Returns the current value
  103401. */
  103402. get current(): number;
  103403. /**
  103404. * Gets the accumulated total
  103405. */
  103406. get total(): number;
  103407. /**
  103408. * Gets the total value count
  103409. */
  103410. get count(): number;
  103411. /**
  103412. * Creates a new counter
  103413. */
  103414. constructor();
  103415. /**
  103416. * Call this method to start monitoring a new frame.
  103417. * 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.
  103418. */
  103419. fetchNewFrame(): void;
  103420. /**
  103421. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103422. * @param newCount the count value to add to the monitored count
  103423. * @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.
  103424. */
  103425. addCount(newCount: number, fetchResult: boolean): void;
  103426. /**
  103427. * Start monitoring this performance counter
  103428. */
  103429. beginMonitoring(): void;
  103430. /**
  103431. * Compute the time lapsed since the previous beginMonitoring() call.
  103432. * @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
  103433. */
  103434. endMonitoring(newFrame?: boolean): void;
  103435. private _fetchResult;
  103436. private _startMonitoringTime;
  103437. private _min;
  103438. private _max;
  103439. private _average;
  103440. private _current;
  103441. private _totalValueCount;
  103442. private _totalAccumulated;
  103443. private _lastSecAverage;
  103444. private _lastSecAccumulated;
  103445. private _lastSecTime;
  103446. private _lastSecValueCount;
  103447. }
  103448. }
  103449. declare module BABYLON {
  103450. interface ThinEngine {
  103451. /**
  103452. * Sets alpha constants used by some alpha blending modes
  103453. * @param r defines the red component
  103454. * @param g defines the green component
  103455. * @param b defines the blue component
  103456. * @param a defines the alpha component
  103457. */
  103458. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103459. /**
  103460. * Sets the current alpha mode
  103461. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103462. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103463. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103464. */
  103465. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103466. /**
  103467. * Gets the current alpha mode
  103468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103469. * @returns the current alpha mode
  103470. */
  103471. getAlphaMode(): number;
  103472. /**
  103473. * Sets the current alpha equation
  103474. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103475. */
  103476. setAlphaEquation(equation: number): void;
  103477. /**
  103478. * Gets the current alpha equation.
  103479. * @returns the current alpha equation
  103480. */
  103481. getAlphaEquation(): number;
  103482. }
  103483. }
  103484. declare module BABYLON {
  103485. /**
  103486. * Defines the interface used by display changed events
  103487. */
  103488. export interface IDisplayChangedEventArgs {
  103489. /** Gets the vrDisplay object (if any) */
  103490. vrDisplay: Nullable<any>;
  103491. /** Gets a boolean indicating if webVR is supported */
  103492. vrSupported: boolean;
  103493. }
  103494. /**
  103495. * Defines the interface used by objects containing a viewport (like a camera)
  103496. */
  103497. interface IViewportOwnerLike {
  103498. /**
  103499. * Gets or sets the viewport
  103500. */
  103501. viewport: IViewportLike;
  103502. }
  103503. /**
  103504. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103505. */
  103506. export class Engine extends ThinEngine {
  103507. /** Defines that alpha blending is disabled */
  103508. static readonly ALPHA_DISABLE: number;
  103509. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103510. static readonly ALPHA_ADD: number;
  103511. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103512. static readonly ALPHA_COMBINE: number;
  103513. /** Defines that alpha blending to DEST - SRC * DEST */
  103514. static readonly ALPHA_SUBTRACT: number;
  103515. /** Defines that alpha blending to SRC * DEST */
  103516. static readonly ALPHA_MULTIPLY: number;
  103517. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103518. static readonly ALPHA_MAXIMIZED: number;
  103519. /** Defines that alpha blending to SRC + DEST */
  103520. static readonly ALPHA_ONEONE: number;
  103521. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103522. static readonly ALPHA_PREMULTIPLIED: number;
  103523. /**
  103524. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103525. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103526. */
  103527. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103528. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103529. static readonly ALPHA_INTERPOLATE: number;
  103530. /**
  103531. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103532. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103533. */
  103534. static readonly ALPHA_SCREENMODE: number;
  103535. /** Defines that the ressource is not delayed*/
  103536. static readonly DELAYLOADSTATE_NONE: number;
  103537. /** Defines that the ressource was successfully delay loaded */
  103538. static readonly DELAYLOADSTATE_LOADED: number;
  103539. /** Defines that the ressource is currently delay loading */
  103540. static readonly DELAYLOADSTATE_LOADING: number;
  103541. /** Defines that the ressource is delayed and has not started loading */
  103542. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103543. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103544. static readonly NEVER: number;
  103545. /** 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 */
  103546. static readonly ALWAYS: number;
  103547. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103548. static readonly LESS: number;
  103549. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103550. static readonly EQUAL: number;
  103551. /** 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 */
  103552. static readonly LEQUAL: number;
  103553. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103554. static readonly GREATER: number;
  103555. /** 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 */
  103556. static readonly GEQUAL: number;
  103557. /** 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 */
  103558. static readonly NOTEQUAL: number;
  103559. /** Passed to stencilOperation to specify that stencil value must be kept */
  103560. static readonly KEEP: number;
  103561. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103562. static readonly REPLACE: number;
  103563. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103564. static readonly INCR: number;
  103565. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103566. static readonly DECR: number;
  103567. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103568. static readonly INVERT: number;
  103569. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103570. static readonly INCR_WRAP: number;
  103571. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103572. static readonly DECR_WRAP: number;
  103573. /** Texture is not repeating outside of 0..1 UVs */
  103574. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103575. /** Texture is repeating outside of 0..1 UVs */
  103576. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103577. /** Texture is repeating and mirrored */
  103578. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103579. /** ALPHA */
  103580. static readonly TEXTUREFORMAT_ALPHA: number;
  103581. /** LUMINANCE */
  103582. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103583. /** LUMINANCE_ALPHA */
  103584. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103585. /** RGB */
  103586. static readonly TEXTUREFORMAT_RGB: number;
  103587. /** RGBA */
  103588. static readonly TEXTUREFORMAT_RGBA: number;
  103589. /** RED */
  103590. static readonly TEXTUREFORMAT_RED: number;
  103591. /** RED (2nd reference) */
  103592. static readonly TEXTUREFORMAT_R: number;
  103593. /** RG */
  103594. static readonly TEXTUREFORMAT_RG: number;
  103595. /** RED_INTEGER */
  103596. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103597. /** RED_INTEGER (2nd reference) */
  103598. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103599. /** RG_INTEGER */
  103600. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103601. /** RGB_INTEGER */
  103602. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103603. /** RGBA_INTEGER */
  103604. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103605. /** UNSIGNED_BYTE */
  103606. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103607. /** UNSIGNED_BYTE (2nd reference) */
  103608. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103609. /** FLOAT */
  103610. static readonly TEXTURETYPE_FLOAT: number;
  103611. /** HALF_FLOAT */
  103612. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103613. /** BYTE */
  103614. static readonly TEXTURETYPE_BYTE: number;
  103615. /** SHORT */
  103616. static readonly TEXTURETYPE_SHORT: number;
  103617. /** UNSIGNED_SHORT */
  103618. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103619. /** INT */
  103620. static readonly TEXTURETYPE_INT: number;
  103621. /** UNSIGNED_INT */
  103622. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103623. /** UNSIGNED_SHORT_4_4_4_4 */
  103624. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103625. /** UNSIGNED_SHORT_5_5_5_1 */
  103626. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103627. /** UNSIGNED_SHORT_5_6_5 */
  103628. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103629. /** UNSIGNED_INT_2_10_10_10_REV */
  103630. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103631. /** UNSIGNED_INT_24_8 */
  103632. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103633. /** UNSIGNED_INT_10F_11F_11F_REV */
  103634. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103635. /** UNSIGNED_INT_5_9_9_9_REV */
  103636. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103637. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103638. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103639. /** nearest is mag = nearest and min = nearest and mip = linear */
  103640. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103641. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103642. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103643. /** Trilinear is mag = linear and min = linear and mip = linear */
  103644. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103645. /** nearest is mag = nearest and min = nearest and mip = linear */
  103646. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103647. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103648. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103649. /** Trilinear is mag = linear and min = linear and mip = linear */
  103650. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103651. /** mag = nearest and min = nearest and mip = nearest */
  103652. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103653. /** mag = nearest and min = linear and mip = nearest */
  103654. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103655. /** mag = nearest and min = linear and mip = linear */
  103656. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103657. /** mag = nearest and min = linear and mip = none */
  103658. static readonly TEXTURE_NEAREST_LINEAR: number;
  103659. /** mag = nearest and min = nearest and mip = none */
  103660. static readonly TEXTURE_NEAREST_NEAREST: number;
  103661. /** mag = linear and min = nearest and mip = nearest */
  103662. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103663. /** mag = linear and min = nearest and mip = linear */
  103664. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103665. /** mag = linear and min = linear and mip = none */
  103666. static readonly TEXTURE_LINEAR_LINEAR: number;
  103667. /** mag = linear and min = nearest and mip = none */
  103668. static readonly TEXTURE_LINEAR_NEAREST: number;
  103669. /** Explicit coordinates mode */
  103670. static readonly TEXTURE_EXPLICIT_MODE: number;
  103671. /** Spherical coordinates mode */
  103672. static readonly TEXTURE_SPHERICAL_MODE: number;
  103673. /** Planar coordinates mode */
  103674. static readonly TEXTURE_PLANAR_MODE: number;
  103675. /** Cubic coordinates mode */
  103676. static readonly TEXTURE_CUBIC_MODE: number;
  103677. /** Projection coordinates mode */
  103678. static readonly TEXTURE_PROJECTION_MODE: number;
  103679. /** Skybox coordinates mode */
  103680. static readonly TEXTURE_SKYBOX_MODE: number;
  103681. /** Inverse Cubic coordinates mode */
  103682. static readonly TEXTURE_INVCUBIC_MODE: number;
  103683. /** Equirectangular coordinates mode */
  103684. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103685. /** Equirectangular Fixed coordinates mode */
  103686. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103687. /** Equirectangular Fixed Mirrored coordinates mode */
  103688. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103689. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103690. static readonly SCALEMODE_FLOOR: number;
  103691. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103692. static readonly SCALEMODE_NEAREST: number;
  103693. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103694. static readonly SCALEMODE_CEILING: number;
  103695. /**
  103696. * Returns the current npm package of the sdk
  103697. */
  103698. static get NpmPackage(): string;
  103699. /**
  103700. * Returns the current version of the framework
  103701. */
  103702. static get Version(): string;
  103703. /** Gets the list of created engines */
  103704. static get Instances(): Engine[];
  103705. /**
  103706. * Gets the latest created engine
  103707. */
  103708. static get LastCreatedEngine(): Nullable<Engine>;
  103709. /**
  103710. * Gets the latest created scene
  103711. */
  103712. static get LastCreatedScene(): Nullable<Scene>;
  103713. /**
  103714. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103715. * @param flag defines which part of the materials must be marked as dirty
  103716. * @param predicate defines a predicate used to filter which materials should be affected
  103717. */
  103718. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103719. /**
  103720. * Method called to create the default loading screen.
  103721. * This can be overriden in your own app.
  103722. * @param canvas The rendering canvas element
  103723. * @returns The loading screen
  103724. */
  103725. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103726. /**
  103727. * Method called to create the default rescale post process on each engine.
  103728. */
  103729. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103730. /**
  103731. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103732. **/
  103733. enableOfflineSupport: boolean;
  103734. /**
  103735. * 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)
  103736. **/
  103737. disableManifestCheck: boolean;
  103738. /**
  103739. * Gets the list of created scenes
  103740. */
  103741. scenes: Scene[];
  103742. /**
  103743. * Event raised when a new scene is created
  103744. */
  103745. onNewSceneAddedObservable: Observable<Scene>;
  103746. /**
  103747. * Gets the list of created postprocesses
  103748. */
  103749. postProcesses: PostProcess[];
  103750. /**
  103751. * Gets a boolean indicating if the pointer is currently locked
  103752. */
  103753. isPointerLock: boolean;
  103754. /**
  103755. * Observable event triggered each time the rendering canvas is resized
  103756. */
  103757. onResizeObservable: Observable<Engine>;
  103758. /**
  103759. * Observable event triggered each time the canvas loses focus
  103760. */
  103761. onCanvasBlurObservable: Observable<Engine>;
  103762. /**
  103763. * Observable event triggered each time the canvas gains focus
  103764. */
  103765. onCanvasFocusObservable: Observable<Engine>;
  103766. /**
  103767. * Observable event triggered each time the canvas receives pointerout event
  103768. */
  103769. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103770. /**
  103771. * Observable raised when the engine begins a new frame
  103772. */
  103773. onBeginFrameObservable: Observable<Engine>;
  103774. /**
  103775. * If set, will be used to request the next animation frame for the render loop
  103776. */
  103777. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103778. /**
  103779. * Observable raised when the engine ends the current frame
  103780. */
  103781. onEndFrameObservable: Observable<Engine>;
  103782. /**
  103783. * Observable raised when the engine is about to compile a shader
  103784. */
  103785. onBeforeShaderCompilationObservable: Observable<Engine>;
  103786. /**
  103787. * Observable raised when the engine has jsut compiled a shader
  103788. */
  103789. onAfterShaderCompilationObservable: Observable<Engine>;
  103790. /**
  103791. * Gets the audio engine
  103792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103793. * @ignorenaming
  103794. */
  103795. static audioEngine: IAudioEngine;
  103796. /**
  103797. * Default AudioEngine factory responsible of creating the Audio Engine.
  103798. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103799. */
  103800. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103801. /**
  103802. * Default offline support factory responsible of creating a tool used to store data locally.
  103803. * By default, this will create a Database object if the workload has been embedded.
  103804. */
  103805. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103806. private _loadingScreen;
  103807. private _pointerLockRequested;
  103808. private _dummyFramebuffer;
  103809. private _rescalePostProcess;
  103810. private _deterministicLockstep;
  103811. private _lockstepMaxSteps;
  103812. private _timeStep;
  103813. protected get _supportsHardwareTextureRescaling(): boolean;
  103814. private _fps;
  103815. private _deltaTime;
  103816. /** @hidden */
  103817. _drawCalls: PerfCounter;
  103818. /**
  103819. * Turn this value on if you want to pause FPS computation when in background
  103820. */
  103821. disablePerformanceMonitorInBackground: boolean;
  103822. private _performanceMonitor;
  103823. /**
  103824. * Gets the performance monitor attached to this engine
  103825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103826. */
  103827. get performanceMonitor(): PerformanceMonitor;
  103828. private _onFocus;
  103829. private _onBlur;
  103830. private _onCanvasPointerOut;
  103831. private _onCanvasBlur;
  103832. private _onCanvasFocus;
  103833. private _onFullscreenChange;
  103834. private _onPointerLockChange;
  103835. /**
  103836. * Gets the HTML element used to attach event listeners
  103837. * @returns a HTML element
  103838. */
  103839. getInputElement(): Nullable<HTMLElement>;
  103840. /**
  103841. * Creates a new engine
  103842. * @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
  103843. * @param antialias defines enable antialiasing (default: false)
  103844. * @param options defines further options to be sent to the getContext() function
  103845. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103846. */
  103847. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103848. /**
  103849. * Gets current aspect ratio
  103850. * @param viewportOwner defines the camera to use to get the aspect ratio
  103851. * @param useScreen defines if screen size must be used (or the current render target if any)
  103852. * @returns a number defining the aspect ratio
  103853. */
  103854. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103855. /**
  103856. * Gets current screen aspect ratio
  103857. * @returns a number defining the aspect ratio
  103858. */
  103859. getScreenAspectRatio(): number;
  103860. /**
  103861. * Gets the client rect of the HTML canvas attached with the current webGL context
  103862. * @returns a client rectanglee
  103863. */
  103864. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103865. /**
  103866. * Gets the client rect of the HTML element used for events
  103867. * @returns a client rectanglee
  103868. */
  103869. getInputElementClientRect(): Nullable<ClientRect>;
  103870. /**
  103871. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103872. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103873. * @returns true if engine is in deterministic lock step mode
  103874. */
  103875. isDeterministicLockStep(): boolean;
  103876. /**
  103877. * Gets the max steps when engine is running in deterministic lock step
  103878. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103879. * @returns the max steps
  103880. */
  103881. getLockstepMaxSteps(): number;
  103882. /**
  103883. * Returns the time in ms between steps when using deterministic lock step.
  103884. * @returns time step in (ms)
  103885. */
  103886. getTimeStep(): number;
  103887. /**
  103888. * Force the mipmap generation for the given render target texture
  103889. * @param texture defines the render target texture to use
  103890. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103891. */
  103892. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103893. /** States */
  103894. /**
  103895. * Set various states to the webGL context
  103896. * @param culling defines backface culling state
  103897. * @param zOffset defines the value to apply to zOffset (0 by default)
  103898. * @param force defines if states must be applied even if cache is up to date
  103899. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103900. */
  103901. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103902. /**
  103903. * Set the z offset to apply to current rendering
  103904. * @param value defines the offset to apply
  103905. */
  103906. setZOffset(value: number): void;
  103907. /**
  103908. * Gets the current value of the zOffset
  103909. * @returns the current zOffset state
  103910. */
  103911. getZOffset(): number;
  103912. /**
  103913. * Enable or disable depth buffering
  103914. * @param enable defines the state to set
  103915. */
  103916. setDepthBuffer(enable: boolean): void;
  103917. /**
  103918. * Gets a boolean indicating if depth writing is enabled
  103919. * @returns the current depth writing state
  103920. */
  103921. getDepthWrite(): boolean;
  103922. /**
  103923. * Enable or disable depth writing
  103924. * @param enable defines the state to set
  103925. */
  103926. setDepthWrite(enable: boolean): void;
  103927. /**
  103928. * Gets a boolean indicating if stencil buffer is enabled
  103929. * @returns the current stencil buffer state
  103930. */
  103931. getStencilBuffer(): boolean;
  103932. /**
  103933. * Enable or disable the stencil buffer
  103934. * @param enable defines if the stencil buffer must be enabled or disabled
  103935. */
  103936. setStencilBuffer(enable: boolean): void;
  103937. /**
  103938. * Gets the current stencil mask
  103939. * @returns a number defining the new stencil mask to use
  103940. */
  103941. getStencilMask(): number;
  103942. /**
  103943. * Sets the current stencil mask
  103944. * @param mask defines the new stencil mask to use
  103945. */
  103946. setStencilMask(mask: number): void;
  103947. /**
  103948. * Gets the current stencil function
  103949. * @returns a number defining the stencil function to use
  103950. */
  103951. getStencilFunction(): number;
  103952. /**
  103953. * Gets the current stencil reference value
  103954. * @returns a number defining the stencil reference value to use
  103955. */
  103956. getStencilFunctionReference(): number;
  103957. /**
  103958. * Gets the current stencil mask
  103959. * @returns a number defining the stencil mask to use
  103960. */
  103961. getStencilFunctionMask(): number;
  103962. /**
  103963. * Sets the current stencil function
  103964. * @param stencilFunc defines the new stencil function to use
  103965. */
  103966. setStencilFunction(stencilFunc: number): void;
  103967. /**
  103968. * Sets the current stencil reference
  103969. * @param reference defines the new stencil reference to use
  103970. */
  103971. setStencilFunctionReference(reference: number): void;
  103972. /**
  103973. * Sets the current stencil mask
  103974. * @param mask defines the new stencil mask to use
  103975. */
  103976. setStencilFunctionMask(mask: number): void;
  103977. /**
  103978. * Gets the current stencil operation when stencil fails
  103979. * @returns a number defining stencil operation to use when stencil fails
  103980. */
  103981. getStencilOperationFail(): number;
  103982. /**
  103983. * Gets the current stencil operation when depth fails
  103984. * @returns a number defining stencil operation to use when depth fails
  103985. */
  103986. getStencilOperationDepthFail(): number;
  103987. /**
  103988. * Gets the current stencil operation when stencil passes
  103989. * @returns a number defining stencil operation to use when stencil passes
  103990. */
  103991. getStencilOperationPass(): number;
  103992. /**
  103993. * Sets the stencil operation to use when stencil fails
  103994. * @param operation defines the stencil operation to use when stencil fails
  103995. */
  103996. setStencilOperationFail(operation: number): void;
  103997. /**
  103998. * Sets the stencil operation to use when depth fails
  103999. * @param operation defines the stencil operation to use when depth fails
  104000. */
  104001. setStencilOperationDepthFail(operation: number): void;
  104002. /**
  104003. * Sets the stencil operation to use when stencil passes
  104004. * @param operation defines the stencil operation to use when stencil passes
  104005. */
  104006. setStencilOperationPass(operation: number): void;
  104007. /**
  104008. * Sets a boolean indicating if the dithering state is enabled or disabled
  104009. * @param value defines the dithering state
  104010. */
  104011. setDitheringState(value: boolean): void;
  104012. /**
  104013. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  104014. * @param value defines the rasterizer state
  104015. */
  104016. setRasterizerState(value: boolean): void;
  104017. /**
  104018. * Gets the current depth function
  104019. * @returns a number defining the depth function
  104020. */
  104021. getDepthFunction(): Nullable<number>;
  104022. /**
  104023. * Sets the current depth function
  104024. * @param depthFunc defines the function to use
  104025. */
  104026. setDepthFunction(depthFunc: number): void;
  104027. /**
  104028. * Sets the current depth function to GREATER
  104029. */
  104030. setDepthFunctionToGreater(): void;
  104031. /**
  104032. * Sets the current depth function to GEQUAL
  104033. */
  104034. setDepthFunctionToGreaterOrEqual(): void;
  104035. /**
  104036. * Sets the current depth function to LESS
  104037. */
  104038. setDepthFunctionToLess(): void;
  104039. /**
  104040. * Sets the current depth function to LEQUAL
  104041. */
  104042. setDepthFunctionToLessOrEqual(): void;
  104043. private _cachedStencilBuffer;
  104044. private _cachedStencilFunction;
  104045. private _cachedStencilMask;
  104046. private _cachedStencilOperationPass;
  104047. private _cachedStencilOperationFail;
  104048. private _cachedStencilOperationDepthFail;
  104049. private _cachedStencilReference;
  104050. /**
  104051. * Caches the the state of the stencil buffer
  104052. */
  104053. cacheStencilState(): void;
  104054. /**
  104055. * Restores the state of the stencil buffer
  104056. */
  104057. restoreStencilState(): void;
  104058. /**
  104059. * Directly set the WebGL Viewport
  104060. * @param x defines the x coordinate of the viewport (in screen space)
  104061. * @param y defines the y coordinate of the viewport (in screen space)
  104062. * @param width defines the width of the viewport (in screen space)
  104063. * @param height defines the height of the viewport (in screen space)
  104064. * @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
  104065. */
  104066. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104067. /**
  104068. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104069. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104070. * @param y defines the y-coordinate of the corner of the clear rectangle
  104071. * @param width defines the width of the clear rectangle
  104072. * @param height defines the height of the clear rectangle
  104073. * @param clearColor defines the clear color
  104074. */
  104075. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104076. /**
  104077. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104078. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104079. * @param y defines the y-coordinate of the corner of the clear rectangle
  104080. * @param width defines the width of the clear rectangle
  104081. * @param height defines the height of the clear rectangle
  104082. */
  104083. enableScissor(x: number, y: number, width: number, height: number): void;
  104084. /**
  104085. * Disable previously set scissor test rectangle
  104086. */
  104087. disableScissor(): void;
  104088. protected _reportDrawCall(): void;
  104089. /**
  104090. * Initializes a webVR display and starts listening to display change events
  104091. * The onVRDisplayChangedObservable will be notified upon these changes
  104092. * @returns The onVRDisplayChangedObservable
  104093. */
  104094. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104095. /** @hidden */
  104096. _prepareVRComponent(): void;
  104097. /** @hidden */
  104098. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104099. /** @hidden */
  104100. _submitVRFrame(): void;
  104101. /**
  104102. * Call this function to leave webVR mode
  104103. * Will do nothing if webVR is not supported or if there is no webVR device
  104104. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104105. */
  104106. disableVR(): void;
  104107. /**
  104108. * Gets a boolean indicating that the system is in VR mode and is presenting
  104109. * @returns true if VR mode is engaged
  104110. */
  104111. isVRPresenting(): boolean;
  104112. /** @hidden */
  104113. _requestVRFrame(): void;
  104114. /** @hidden */
  104115. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104116. /**
  104117. * Gets the source code of the vertex shader associated with a specific webGL program
  104118. * @param program defines the program to use
  104119. * @returns a string containing the source code of the vertex shader associated with the program
  104120. */
  104121. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104122. /**
  104123. * Gets the source code of the fragment shader associated with a specific webGL program
  104124. * @param program defines the program to use
  104125. * @returns a string containing the source code of the fragment shader associated with the program
  104126. */
  104127. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104128. /**
  104129. * Sets a depth stencil texture from a render target to the according uniform.
  104130. * @param channel The texture channel
  104131. * @param uniform The uniform to set
  104132. * @param texture The render target texture containing the depth stencil texture to apply
  104133. */
  104134. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104135. /**
  104136. * Sets a texture to the webGL context from a postprocess
  104137. * @param channel defines the channel to use
  104138. * @param postProcess defines the source postprocess
  104139. */
  104140. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104141. /**
  104142. * Binds the output of the passed in post process to the texture channel specified
  104143. * @param channel The channel the texture should be bound to
  104144. * @param postProcess The post process which's output should be bound
  104145. */
  104146. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104147. /** @hidden */
  104148. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104149. protected _rebuildBuffers(): void;
  104150. /** @hidden */
  104151. _renderFrame(): void;
  104152. _renderLoop(): void;
  104153. /** @hidden */
  104154. _renderViews(): boolean;
  104155. /**
  104156. * Toggle full screen mode
  104157. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104158. */
  104159. switchFullscreen(requestPointerLock: boolean): void;
  104160. /**
  104161. * Enters full screen mode
  104162. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104163. */
  104164. enterFullscreen(requestPointerLock: boolean): void;
  104165. /**
  104166. * Exits full screen mode
  104167. */
  104168. exitFullscreen(): void;
  104169. /**
  104170. * Enters Pointerlock mode
  104171. */
  104172. enterPointerlock(): void;
  104173. /**
  104174. * Exits Pointerlock mode
  104175. */
  104176. exitPointerlock(): void;
  104177. /**
  104178. * Begin a new frame
  104179. */
  104180. beginFrame(): void;
  104181. /**
  104182. * Enf the current frame
  104183. */
  104184. endFrame(): void;
  104185. resize(): void;
  104186. /**
  104187. * Set the compressed texture format to use, based on the formats you have, and the formats
  104188. * supported by the hardware / browser.
  104189. *
  104190. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104191. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104192. * to API arguments needed to compressed textures. This puts the burden on the container
  104193. * generator to house the arcane code for determining these for current & future formats.
  104194. *
  104195. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104196. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104197. *
  104198. * Note: The result of this call is not taken into account when a texture is base64.
  104199. *
  104200. * @param formatsAvailable defines the list of those format families you have created
  104201. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104202. *
  104203. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104204. * @returns The extension selected.
  104205. */
  104206. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104207. /**
  104208. * Set the compressed texture extensions or file names to skip.
  104209. *
  104210. * @param skippedFiles defines the list of those texture files you want to skip
  104211. * Example: [".dds", ".env", "myfile.png"]
  104212. */
  104213. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104214. /**
  104215. * Force a specific size of the canvas
  104216. * @param width defines the new canvas' width
  104217. * @param height defines the new canvas' height
  104218. */
  104219. setSize(width: number, height: number): void;
  104220. /**
  104221. * Updates a dynamic vertex buffer.
  104222. * @param vertexBuffer the vertex buffer to update
  104223. * @param data the data used to update the vertex buffer
  104224. * @param byteOffset the byte offset of the data
  104225. * @param byteLength the byte length of the data
  104226. */
  104227. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104228. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104229. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104230. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104231. _releaseTexture(texture: InternalTexture): void;
  104232. /**
  104233. * @hidden
  104234. * Rescales a texture
  104235. * @param source input texutre
  104236. * @param destination destination texture
  104237. * @param scene scene to use to render the resize
  104238. * @param internalFormat format to use when resizing
  104239. * @param onComplete callback to be called when resize has completed
  104240. */
  104241. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104242. /**
  104243. * Gets the current framerate
  104244. * @returns a number representing the framerate
  104245. */
  104246. getFps(): number;
  104247. /**
  104248. * Gets the time spent between current and previous frame
  104249. * @returns a number representing the delta time in ms
  104250. */
  104251. getDeltaTime(): number;
  104252. private _measureFps;
  104253. /** @hidden */
  104254. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104255. /**
  104256. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104257. * @param renderTarget The render target to set the frame buffer for
  104258. */
  104259. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104260. /**
  104261. * Update a dynamic index buffer
  104262. * @param indexBuffer defines the target index buffer
  104263. * @param indices defines the data to update
  104264. * @param offset defines the offset in the target index buffer where update should start
  104265. */
  104266. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104267. /**
  104268. * Updates the sample count of a render target texture
  104269. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104270. * @param texture defines the texture to update
  104271. * @param samples defines the sample count to set
  104272. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104273. */
  104274. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104275. /**
  104276. * Updates a depth texture Comparison Mode and Function.
  104277. * If the comparison Function is equal to 0, the mode will be set to none.
  104278. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104279. * @param texture The texture to set the comparison function for
  104280. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104281. */
  104282. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104283. /**
  104284. * Creates a webGL buffer to use with instanciation
  104285. * @param capacity defines the size of the buffer
  104286. * @returns the webGL buffer
  104287. */
  104288. createInstancesBuffer(capacity: number): DataBuffer;
  104289. /**
  104290. * Delete a webGL buffer used with instanciation
  104291. * @param buffer defines the webGL buffer to delete
  104292. */
  104293. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104294. /** @hidden */
  104295. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104296. dispose(): void;
  104297. private _disableTouchAction;
  104298. /**
  104299. * Display the loading screen
  104300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104301. */
  104302. displayLoadingUI(): void;
  104303. /**
  104304. * Hide the loading screen
  104305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104306. */
  104307. hideLoadingUI(): void;
  104308. /**
  104309. * Gets the current loading screen object
  104310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104311. */
  104312. get loadingScreen(): ILoadingScreen;
  104313. /**
  104314. * Sets the current loading screen object
  104315. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104316. */
  104317. set loadingScreen(loadingScreen: ILoadingScreen);
  104318. /**
  104319. * Sets the current loading screen text
  104320. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104321. */
  104322. set loadingUIText(text: string);
  104323. /**
  104324. * Sets the current loading screen background color
  104325. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104326. */
  104327. set loadingUIBackgroundColor(color: string);
  104328. /** Pointerlock and fullscreen */
  104329. /**
  104330. * Ask the browser to promote the current element to pointerlock mode
  104331. * @param element defines the DOM element to promote
  104332. */
  104333. static _RequestPointerlock(element: HTMLElement): void;
  104334. /**
  104335. * Asks the browser to exit pointerlock mode
  104336. */
  104337. static _ExitPointerlock(): void;
  104338. /**
  104339. * Ask the browser to promote the current element to fullscreen rendering mode
  104340. * @param element defines the DOM element to promote
  104341. */
  104342. static _RequestFullscreen(element: HTMLElement): void;
  104343. /**
  104344. * Asks the browser to exit fullscreen mode
  104345. */
  104346. static _ExitFullscreen(): void;
  104347. }
  104348. }
  104349. declare module BABYLON {
  104350. /**
  104351. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104352. * during the life time of the application.
  104353. */
  104354. export class EngineStore {
  104355. /** Gets the list of created engines */
  104356. static Instances: Engine[];
  104357. /** @hidden */
  104358. static _LastCreatedScene: Nullable<Scene>;
  104359. /**
  104360. * Gets the latest created engine
  104361. */
  104362. static get LastCreatedEngine(): Nullable<Engine>;
  104363. /**
  104364. * Gets the latest created scene
  104365. */
  104366. static get LastCreatedScene(): Nullable<Scene>;
  104367. /**
  104368. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104369. * @ignorenaming
  104370. */
  104371. static UseFallbackTexture: boolean;
  104372. /**
  104373. * Texture content used if a texture cannot loaded
  104374. * @ignorenaming
  104375. */
  104376. static FallbackTexture: string;
  104377. }
  104378. }
  104379. declare module BABYLON {
  104380. /**
  104381. * Helper class that provides a small promise polyfill
  104382. */
  104383. export class PromisePolyfill {
  104384. /**
  104385. * Static function used to check if the polyfill is required
  104386. * If this is the case then the function will inject the polyfill to window.Promise
  104387. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104388. */
  104389. static Apply(force?: boolean): void;
  104390. }
  104391. }
  104392. declare module BABYLON {
  104393. /**
  104394. * Interface for screenshot methods with describe argument called `size` as object with options
  104395. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104396. */
  104397. export interface IScreenshotSize {
  104398. /**
  104399. * number in pixels for canvas height
  104400. */
  104401. height?: number;
  104402. /**
  104403. * multiplier allowing render at a higher or lower resolution
  104404. * If value is defined then height and width will be ignored and taken from camera
  104405. */
  104406. precision?: number;
  104407. /**
  104408. * number in pixels for canvas width
  104409. */
  104410. width?: number;
  104411. }
  104412. }
  104413. declare module BABYLON {
  104414. interface IColor4Like {
  104415. r: float;
  104416. g: float;
  104417. b: float;
  104418. a: float;
  104419. }
  104420. /**
  104421. * Class containing a set of static utilities functions
  104422. */
  104423. export class Tools {
  104424. /**
  104425. * Gets or sets the base URL to use to load assets
  104426. */
  104427. static get BaseUrl(): string;
  104428. static set BaseUrl(value: string);
  104429. /**
  104430. * Enable/Disable Custom HTTP Request Headers globally.
  104431. * default = false
  104432. * @see CustomRequestHeaders
  104433. */
  104434. static UseCustomRequestHeaders: boolean;
  104435. /**
  104436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104437. * i.e. when loading files, where the server/service expects an Authorization header
  104438. */
  104439. static CustomRequestHeaders: {
  104440. [key: string]: string;
  104441. };
  104442. /**
  104443. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104444. */
  104445. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104446. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104447. /**
  104448. * Default behaviour for cors in the application.
  104449. * It can be a string if the expected behavior is identical in the entire app.
  104450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104451. */
  104452. static CorsBehavior: string | ((url: string | string[]) => string);
  104453. /**
  104454. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104455. * @ignorenaming
  104456. */
  104457. static get UseFallbackTexture(): boolean;
  104458. static set UseFallbackTexture(value: boolean);
  104459. /**
  104460. * Use this object to register external classes like custom textures or material
  104461. * to allow the laoders to instantiate them
  104462. */
  104463. static get RegisteredExternalClasses(): {
  104464. [key: string]: Object;
  104465. };
  104466. static set RegisteredExternalClasses(classes: {
  104467. [key: string]: Object;
  104468. });
  104469. /**
  104470. * Texture content used if a texture cannot loaded
  104471. * @ignorenaming
  104472. */
  104473. static get fallbackTexture(): string;
  104474. static set fallbackTexture(value: string);
  104475. /**
  104476. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104477. * @param u defines the coordinate on X axis
  104478. * @param v defines the coordinate on Y axis
  104479. * @param width defines the width of the source data
  104480. * @param height defines the height of the source data
  104481. * @param pixels defines the source byte array
  104482. * @param color defines the output color
  104483. */
  104484. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104485. /**
  104486. * Interpolates between a and b via alpha
  104487. * @param a The lower value (returned when alpha = 0)
  104488. * @param b The upper value (returned when alpha = 1)
  104489. * @param alpha The interpolation-factor
  104490. * @return The mixed value
  104491. */
  104492. static Mix(a: number, b: number, alpha: number): number;
  104493. /**
  104494. * Tries to instantiate a new object from a given class name
  104495. * @param className defines the class name to instantiate
  104496. * @returns the new object or null if the system was not able to do the instantiation
  104497. */
  104498. static Instantiate(className: string): any;
  104499. /**
  104500. * Provides a slice function that will work even on IE
  104501. * @param data defines the array to slice
  104502. * @param start defines the start of the data (optional)
  104503. * @param end defines the end of the data (optional)
  104504. * @returns the new sliced array
  104505. */
  104506. static Slice<T>(data: T, start?: number, end?: number): T;
  104507. /**
  104508. * Polyfill for setImmediate
  104509. * @param action defines the action to execute after the current execution block
  104510. */
  104511. static SetImmediate(action: () => void): void;
  104512. /**
  104513. * Function indicating if a number is an exponent of 2
  104514. * @param value defines the value to test
  104515. * @returns true if the value is an exponent of 2
  104516. */
  104517. static IsExponentOfTwo(value: number): boolean;
  104518. private static _tmpFloatArray;
  104519. /**
  104520. * Returns the nearest 32-bit single precision float representation of a Number
  104521. * @param value A Number. If the parameter is of a different type, it will get converted
  104522. * to a number or to NaN if it cannot be converted
  104523. * @returns number
  104524. */
  104525. static FloatRound(value: number): number;
  104526. /**
  104527. * Extracts the filename from a path
  104528. * @param path defines the path to use
  104529. * @returns the filename
  104530. */
  104531. static GetFilename(path: string): string;
  104532. /**
  104533. * Extracts the "folder" part of a path (everything before the filename).
  104534. * @param uri The URI to extract the info from
  104535. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104536. * @returns The "folder" part of the path
  104537. */
  104538. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104539. /**
  104540. * Extracts text content from a DOM element hierarchy
  104541. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104542. */
  104543. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104544. /**
  104545. * Convert an angle in radians to degrees
  104546. * @param angle defines the angle to convert
  104547. * @returns the angle in degrees
  104548. */
  104549. static ToDegrees(angle: number): number;
  104550. /**
  104551. * Convert an angle in degrees to radians
  104552. * @param angle defines the angle to convert
  104553. * @returns the angle in radians
  104554. */
  104555. static ToRadians(angle: number): number;
  104556. /**
  104557. * Returns an array if obj is not an array
  104558. * @param obj defines the object to evaluate as an array
  104559. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104560. * @returns either obj directly if obj is an array or a new array containing obj
  104561. */
  104562. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104563. /**
  104564. * Gets the pointer prefix to use
  104565. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104566. */
  104567. static GetPointerPrefix(): string;
  104568. /**
  104569. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104570. * @param url define the url we are trying
  104571. * @param element define the dom element where to configure the cors policy
  104572. */
  104573. static SetCorsBehavior(url: string | string[], element: {
  104574. crossOrigin: string | null;
  104575. }): void;
  104576. /**
  104577. * Removes unwanted characters from an url
  104578. * @param url defines the url to clean
  104579. * @returns the cleaned url
  104580. */
  104581. static CleanUrl(url: string): string;
  104582. /**
  104583. * Gets or sets a function used to pre-process url before using them to load assets
  104584. */
  104585. static get PreprocessUrl(): (url: string) => string;
  104586. static set PreprocessUrl(processor: (url: string) => string);
  104587. /**
  104588. * Loads an image as an HTMLImageElement.
  104589. * @param input url string, ArrayBuffer, or Blob to load
  104590. * @param onLoad callback called when the image successfully loads
  104591. * @param onError callback called when the image fails to load
  104592. * @param offlineProvider offline provider for caching
  104593. * @param mimeType optional mime type
  104594. * @returns the HTMLImageElement of the loaded image
  104595. */
  104596. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104597. /**
  104598. * Loads a file from a url
  104599. * @param url url string, ArrayBuffer, or Blob to load
  104600. * @param onSuccess callback called when the file successfully loads
  104601. * @param onProgress callback called while file is loading (if the server supports this mode)
  104602. * @param offlineProvider defines the offline provider for caching
  104603. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104604. * @param onError callback called when the file fails to load
  104605. * @returns a file request object
  104606. */
  104607. 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;
  104608. /**
  104609. * Loads a file from a url
  104610. * @param url the file url to load
  104611. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104612. */
  104613. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104614. /**
  104615. * Load a script (identified by an url). When the url returns, the
  104616. * content of this file is added into a new script element, attached to the DOM (body element)
  104617. * @param scriptUrl defines the url of the script to laod
  104618. * @param onSuccess defines the callback called when the script is loaded
  104619. * @param onError defines the callback to call if an error occurs
  104620. * @param scriptId defines the id of the script element
  104621. */
  104622. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104623. /**
  104624. * Load an asynchronous script (identified by an url). When the url returns, the
  104625. * content of this file is added into a new script element, attached to the DOM (body element)
  104626. * @param scriptUrl defines the url of the script to laod
  104627. * @param scriptId defines the id of the script element
  104628. * @returns a promise request object
  104629. */
  104630. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  104631. /**
  104632. * Loads a file from a blob
  104633. * @param fileToLoad defines the blob to use
  104634. * @param callback defines the callback to call when data is loaded
  104635. * @param progressCallback defines the callback to call during loading process
  104636. * @returns a file request object
  104637. */
  104638. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104639. /**
  104640. * Reads a file from a File object
  104641. * @param file defines the file to load
  104642. * @param onSuccess defines the callback to call when data is loaded
  104643. * @param onProgress defines the callback to call during loading process
  104644. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104645. * @param onError defines the callback to call when an error occurs
  104646. * @returns a file request object
  104647. */
  104648. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104649. /**
  104650. * Creates a data url from a given string content
  104651. * @param content defines the content to convert
  104652. * @returns the new data url link
  104653. */
  104654. static FileAsURL(content: string): string;
  104655. /**
  104656. * Format the given number to a specific decimal format
  104657. * @param value defines the number to format
  104658. * @param decimals defines the number of decimals to use
  104659. * @returns the formatted string
  104660. */
  104661. static Format(value: number, decimals?: number): string;
  104662. /**
  104663. * Tries to copy an object by duplicating every property
  104664. * @param source defines the source object
  104665. * @param destination defines the target object
  104666. * @param doNotCopyList defines a list of properties to avoid
  104667. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104668. */
  104669. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104670. /**
  104671. * Gets a boolean indicating if the given object has no own property
  104672. * @param obj defines the object to test
  104673. * @returns true if object has no own property
  104674. */
  104675. static IsEmpty(obj: any): boolean;
  104676. /**
  104677. * Function used to register events at window level
  104678. * @param windowElement defines the Window object to use
  104679. * @param events defines the events to register
  104680. */
  104681. static RegisterTopRootEvents(windowElement: Window, events: {
  104682. name: string;
  104683. handler: Nullable<(e: FocusEvent) => any>;
  104684. }[]): void;
  104685. /**
  104686. * Function used to unregister events from window level
  104687. * @param windowElement defines the Window object to use
  104688. * @param events defines the events to unregister
  104689. */
  104690. static UnregisterTopRootEvents(windowElement: Window, events: {
  104691. name: string;
  104692. handler: Nullable<(e: FocusEvent) => any>;
  104693. }[]): void;
  104694. /**
  104695. * @ignore
  104696. */
  104697. static _ScreenshotCanvas: HTMLCanvasElement;
  104698. /**
  104699. * Dumps the current bound framebuffer
  104700. * @param width defines the rendering width
  104701. * @param height defines the rendering height
  104702. * @param engine defines the hosting engine
  104703. * @param successCallback defines the callback triggered once the data are available
  104704. * @param mimeType defines the mime type of the result
  104705. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104706. */
  104707. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104708. /**
  104709. * Converts the canvas data to blob.
  104710. * This acts as a polyfill for browsers not supporting the to blob function.
  104711. * @param canvas Defines the canvas to extract the data from
  104712. * @param successCallback Defines the callback triggered once the data are available
  104713. * @param mimeType Defines the mime type of the result
  104714. */
  104715. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104716. /**
  104717. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104718. * @param successCallback defines the callback triggered once the data are available
  104719. * @param mimeType defines the mime type of the result
  104720. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104721. */
  104722. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104723. /**
  104724. * Downloads a blob in the browser
  104725. * @param blob defines the blob to download
  104726. * @param fileName defines the name of the downloaded file
  104727. */
  104728. static Download(blob: Blob, fileName: string): void;
  104729. /**
  104730. * Captures a screenshot of the current rendering
  104731. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104732. * @param engine defines the rendering engine
  104733. * @param camera defines the source camera
  104734. * @param size This parameter can be set to a single number or to an object with the
  104735. * following (optional) properties: precision, width, height. If a single number is passed,
  104736. * it will be used for both width and height. If an object is passed, the screenshot size
  104737. * will be derived from the parameters. The precision property is a multiplier allowing
  104738. * rendering at a higher or lower resolution
  104739. * @param successCallback defines the callback receives a single parameter which contains the
  104740. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104741. * src parameter of an <img> to display it
  104742. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104743. * Check your browser for supported MIME types
  104744. */
  104745. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104746. /**
  104747. * Captures a screenshot of the current rendering
  104748. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104749. * @param engine defines the rendering engine
  104750. * @param camera defines the source camera
  104751. * @param size This parameter can be set to a single number or to an object with the
  104752. * following (optional) properties: precision, width, height. If a single number is passed,
  104753. * it will be used for both width and height. If an object is passed, the screenshot size
  104754. * will be derived from the parameters. The precision property is a multiplier allowing
  104755. * rendering at a higher or lower resolution
  104756. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104757. * Check your browser for supported MIME types
  104758. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104759. * to the src parameter of an <img> to display it
  104760. */
  104761. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104762. /**
  104763. * Generates an image screenshot from the specified camera.
  104764. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104765. * @param engine The engine to use for rendering
  104766. * @param camera The camera to use for rendering
  104767. * @param size This parameter can be set to a single number or to an object with the
  104768. * following (optional) properties: precision, width, height. If a single number is passed,
  104769. * it will be used for both width and height. If an object is passed, the screenshot size
  104770. * will be derived from the parameters. The precision property is a multiplier allowing
  104771. * rendering at a higher or lower resolution
  104772. * @param successCallback The callback receives a single parameter which contains the
  104773. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104774. * src parameter of an <img> to display it
  104775. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104776. * Check your browser for supported MIME types
  104777. * @param samples Texture samples (default: 1)
  104778. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104779. * @param fileName A name for for the downloaded file.
  104780. */
  104781. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104782. /**
  104783. * Generates an image screenshot from the specified camera.
  104784. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104785. * @param engine The engine to use for rendering
  104786. * @param camera The camera to use for rendering
  104787. * @param size This parameter can be set to a single number or to an object with the
  104788. * following (optional) properties: precision, width, height. If a single number is passed,
  104789. * it will be used for both width and height. If an object is passed, the screenshot size
  104790. * will be derived from the parameters. The precision property is a multiplier allowing
  104791. * rendering at a higher or lower resolution
  104792. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104793. * Check your browser for supported MIME types
  104794. * @param samples Texture samples (default: 1)
  104795. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104796. * @param fileName A name for for the downloaded file.
  104797. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104798. * to the src parameter of an <img> to display it
  104799. */
  104800. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104801. /**
  104802. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104803. * Be aware Math.random() could cause collisions, but:
  104804. * "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"
  104805. * @returns a pseudo random id
  104806. */
  104807. static RandomId(): string;
  104808. /**
  104809. * Test if the given uri is a base64 string
  104810. * @param uri The uri to test
  104811. * @return True if the uri is a base64 string or false otherwise
  104812. */
  104813. static IsBase64(uri: string): boolean;
  104814. /**
  104815. * Decode the given base64 uri.
  104816. * @param uri The uri to decode
  104817. * @return The decoded base64 data.
  104818. */
  104819. static DecodeBase64(uri: string): ArrayBuffer;
  104820. /**
  104821. * Gets the absolute url.
  104822. * @param url the input url
  104823. * @return the absolute url
  104824. */
  104825. static GetAbsoluteUrl(url: string): string;
  104826. /**
  104827. * No log
  104828. */
  104829. static readonly NoneLogLevel: number;
  104830. /**
  104831. * Only message logs
  104832. */
  104833. static readonly MessageLogLevel: number;
  104834. /**
  104835. * Only warning logs
  104836. */
  104837. static readonly WarningLogLevel: number;
  104838. /**
  104839. * Only error logs
  104840. */
  104841. static readonly ErrorLogLevel: number;
  104842. /**
  104843. * All logs
  104844. */
  104845. static readonly AllLogLevel: number;
  104846. /**
  104847. * Gets a value indicating the number of loading errors
  104848. * @ignorenaming
  104849. */
  104850. static get errorsCount(): number;
  104851. /**
  104852. * Callback called when a new log is added
  104853. */
  104854. static OnNewCacheEntry: (entry: string) => void;
  104855. /**
  104856. * Log a message to the console
  104857. * @param message defines the message to log
  104858. */
  104859. static Log(message: string): void;
  104860. /**
  104861. * Write a warning message to the console
  104862. * @param message defines the message to log
  104863. */
  104864. static Warn(message: string): void;
  104865. /**
  104866. * Write an error message to the console
  104867. * @param message defines the message to log
  104868. */
  104869. static Error(message: string): void;
  104870. /**
  104871. * Gets current log cache (list of logs)
  104872. */
  104873. static get LogCache(): string;
  104874. /**
  104875. * Clears the log cache
  104876. */
  104877. static ClearLogCache(): void;
  104878. /**
  104879. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104880. */
  104881. static set LogLevels(level: number);
  104882. /**
  104883. * Checks if the window object exists
  104884. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104885. */
  104886. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104887. /**
  104888. * No performance log
  104889. */
  104890. static readonly PerformanceNoneLogLevel: number;
  104891. /**
  104892. * Use user marks to log performance
  104893. */
  104894. static readonly PerformanceUserMarkLogLevel: number;
  104895. /**
  104896. * Log performance to the console
  104897. */
  104898. static readonly PerformanceConsoleLogLevel: number;
  104899. private static _performance;
  104900. /**
  104901. * Sets the current performance log level
  104902. */
  104903. static set PerformanceLogLevel(level: number);
  104904. private static _StartPerformanceCounterDisabled;
  104905. private static _EndPerformanceCounterDisabled;
  104906. private static _StartUserMark;
  104907. private static _EndUserMark;
  104908. private static _StartPerformanceConsole;
  104909. private static _EndPerformanceConsole;
  104910. /**
  104911. * Starts a performance counter
  104912. */
  104913. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104914. /**
  104915. * Ends a specific performance coutner
  104916. */
  104917. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104918. /**
  104919. * Gets either window.performance.now() if supported or Date.now() else
  104920. */
  104921. static get Now(): number;
  104922. /**
  104923. * This method will return the name of the class used to create the instance of the given object.
  104924. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104925. * @param object the object to get the class name from
  104926. * @param isType defines if the object is actually a type
  104927. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104928. */
  104929. static GetClassName(object: any, isType?: boolean): string;
  104930. /**
  104931. * Gets the first element of an array satisfying a given predicate
  104932. * @param array defines the array to browse
  104933. * @param predicate defines the predicate to use
  104934. * @returns null if not found or the element
  104935. */
  104936. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104937. /**
  104938. * This method will return the name of the full name of the class, including its owning module (if any).
  104939. * 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).
  104940. * @param object the object to get the class name from
  104941. * @param isType defines if the object is actually a type
  104942. * @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.
  104943. * @ignorenaming
  104944. */
  104945. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104946. /**
  104947. * Returns a promise that resolves after the given amount of time.
  104948. * @param delay Number of milliseconds to delay
  104949. * @returns Promise that resolves after the given amount of time
  104950. */
  104951. static DelayAsync(delay: number): Promise<void>;
  104952. /**
  104953. * Utility function to detect if the current user agent is Safari
  104954. * @returns whether or not the current user agent is safari
  104955. */
  104956. static IsSafari(): boolean;
  104957. }
  104958. /**
  104959. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104960. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104961. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104962. * @param name The name of the class, case should be preserved
  104963. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104964. */
  104965. export function className(name: string, module?: string): (target: Object) => void;
  104966. /**
  104967. * An implementation of a loop for asynchronous functions.
  104968. */
  104969. export class AsyncLoop {
  104970. /**
  104971. * Defines the number of iterations for the loop
  104972. */
  104973. iterations: number;
  104974. /**
  104975. * Defines the current index of the loop.
  104976. */
  104977. index: number;
  104978. private _done;
  104979. private _fn;
  104980. private _successCallback;
  104981. /**
  104982. * Constructor.
  104983. * @param iterations the number of iterations.
  104984. * @param func the function to run each iteration
  104985. * @param successCallback the callback that will be called upon succesful execution
  104986. * @param offset starting offset.
  104987. */
  104988. constructor(
  104989. /**
  104990. * Defines the number of iterations for the loop
  104991. */
  104992. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104993. /**
  104994. * Execute the next iteration. Must be called after the last iteration was finished.
  104995. */
  104996. executeNext(): void;
  104997. /**
  104998. * Break the loop and run the success callback.
  104999. */
  105000. breakLoop(): void;
  105001. /**
  105002. * Create and run an async loop.
  105003. * @param iterations the number of iterations.
  105004. * @param fn the function to run each iteration
  105005. * @param successCallback the callback that will be called upon succesful execution
  105006. * @param offset starting offset.
  105007. * @returns the created async loop object
  105008. */
  105009. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  105010. /**
  105011. * A for-loop that will run a given number of iterations synchronous and the rest async.
  105012. * @param iterations total number of iterations
  105013. * @param syncedIterations number of synchronous iterations in each async iteration.
  105014. * @param fn the function to call each iteration.
  105015. * @param callback a success call back that will be called when iterating stops.
  105016. * @param breakFunction a break condition (optional)
  105017. * @param timeout timeout settings for the setTimeout function. default - 0.
  105018. * @returns the created async loop object
  105019. */
  105020. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  105021. }
  105022. }
  105023. declare module BABYLON {
  105024. /**
  105025. * This class implement a typical dictionary using a string as key and the generic type T as value.
  105026. * The underlying implementation relies on an associative array to ensure the best performances.
  105027. * The value can be anything including 'null' but except 'undefined'
  105028. */
  105029. export class StringDictionary<T> {
  105030. /**
  105031. * This will clear this dictionary and copy the content from the 'source' one.
  105032. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  105033. * @param source the dictionary to take the content from and copy to this dictionary
  105034. */
  105035. copyFrom(source: StringDictionary<T>): void;
  105036. /**
  105037. * Get a value based from its key
  105038. * @param key the given key to get the matching value from
  105039. * @return the value if found, otherwise undefined is returned
  105040. */
  105041. get(key: string): T | undefined;
  105042. /**
  105043. * Get a value from its key or add it if it doesn't exist.
  105044. * This method will ensure you that a given key/data will be present in the dictionary.
  105045. * @param key the given key to get the matching value from
  105046. * @param factory the factory that will create the value if the key is not present in the dictionary.
  105047. * The factory will only be invoked if there's no data for the given key.
  105048. * @return the value corresponding to the key.
  105049. */
  105050. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  105051. /**
  105052. * Get a value from its key if present in the dictionary otherwise add it
  105053. * @param key the key to get the value from
  105054. * @param val if there's no such key/value pair in the dictionary add it with this value
  105055. * @return the value corresponding to the key
  105056. */
  105057. getOrAdd(key: string, val: T): T;
  105058. /**
  105059. * Check if there's a given key in the dictionary
  105060. * @param key the key to check for
  105061. * @return true if the key is present, false otherwise
  105062. */
  105063. contains(key: string): boolean;
  105064. /**
  105065. * Add a new key and its corresponding value
  105066. * @param key the key to add
  105067. * @param value the value corresponding to the key
  105068. * @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
  105069. */
  105070. add(key: string, value: T): boolean;
  105071. /**
  105072. * Update a specific value associated to a key
  105073. * @param key defines the key to use
  105074. * @param value defines the value to store
  105075. * @returns true if the value was updated (or false if the key was not found)
  105076. */
  105077. set(key: string, value: T): boolean;
  105078. /**
  105079. * Get the element of the given key and remove it from the dictionary
  105080. * @param key defines the key to search
  105081. * @returns the value associated with the key or null if not found
  105082. */
  105083. getAndRemove(key: string): Nullable<T>;
  105084. /**
  105085. * Remove a key/value from the dictionary.
  105086. * @param key the key to remove
  105087. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105088. */
  105089. remove(key: string): boolean;
  105090. /**
  105091. * Clear the whole content of the dictionary
  105092. */
  105093. clear(): void;
  105094. /**
  105095. * Gets the current count
  105096. */
  105097. get count(): number;
  105098. /**
  105099. * Execute a callback on each key/val of the dictionary.
  105100. * Note that you can remove any element in this dictionary in the callback implementation
  105101. * @param callback the callback to execute on a given key/value pair
  105102. */
  105103. forEach(callback: (key: string, val: T) => void): void;
  105104. /**
  105105. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105106. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105107. * Note that you can remove any element in this dictionary in the callback implementation
  105108. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105109. * @returns the first item
  105110. */
  105111. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105112. private _count;
  105113. private _data;
  105114. }
  105115. }
  105116. declare module BABYLON {
  105117. /** @hidden */
  105118. export interface ICollisionCoordinator {
  105119. createCollider(): Collider;
  105120. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105121. init(scene: Scene): void;
  105122. }
  105123. /** @hidden */
  105124. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105125. private _scene;
  105126. private _scaledPosition;
  105127. private _scaledVelocity;
  105128. private _finalPosition;
  105129. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105130. createCollider(): Collider;
  105131. init(scene: Scene): void;
  105132. private _collideWithWorld;
  105133. }
  105134. }
  105135. declare module BABYLON {
  105136. /**
  105137. * Class used to manage all inputs for the scene.
  105138. */
  105139. export class InputManager {
  105140. /** The distance in pixel that you have to move to prevent some events */
  105141. static DragMovementThreshold: number;
  105142. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105143. static LongPressDelay: number;
  105144. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105145. static DoubleClickDelay: number;
  105146. /** If you need to check double click without raising a single click at first click, enable this flag */
  105147. static ExclusiveDoubleClickMode: boolean;
  105148. private _wheelEventName;
  105149. private _onPointerMove;
  105150. private _onPointerDown;
  105151. private _onPointerUp;
  105152. private _initClickEvent;
  105153. private _initActionManager;
  105154. private _delayedSimpleClick;
  105155. private _delayedSimpleClickTimeout;
  105156. private _previousDelayedSimpleClickTimeout;
  105157. private _meshPickProceed;
  105158. private _previousButtonPressed;
  105159. private _currentPickResult;
  105160. private _previousPickResult;
  105161. private _totalPointersPressed;
  105162. private _doubleClickOccured;
  105163. private _pointerOverMesh;
  105164. private _pickedDownMesh;
  105165. private _pickedUpMesh;
  105166. private _pointerX;
  105167. private _pointerY;
  105168. private _unTranslatedPointerX;
  105169. private _unTranslatedPointerY;
  105170. private _startingPointerPosition;
  105171. private _previousStartingPointerPosition;
  105172. private _startingPointerTime;
  105173. private _previousStartingPointerTime;
  105174. private _pointerCaptures;
  105175. private _onKeyDown;
  105176. private _onKeyUp;
  105177. private _onCanvasFocusObserver;
  105178. private _onCanvasBlurObserver;
  105179. private _scene;
  105180. /**
  105181. * Creates a new InputManager
  105182. * @param scene defines the hosting scene
  105183. */
  105184. constructor(scene: Scene);
  105185. /**
  105186. * Gets the mesh that is currently under the pointer
  105187. */
  105188. get meshUnderPointer(): Nullable<AbstractMesh>;
  105189. /**
  105190. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105191. */
  105192. get unTranslatedPointer(): Vector2;
  105193. /**
  105194. * Gets or sets the current on-screen X position of the pointer
  105195. */
  105196. get pointerX(): number;
  105197. set pointerX(value: number);
  105198. /**
  105199. * Gets or sets the current on-screen Y position of the pointer
  105200. */
  105201. get pointerY(): number;
  105202. set pointerY(value: number);
  105203. private _updatePointerPosition;
  105204. private _processPointerMove;
  105205. private _setRayOnPointerInfo;
  105206. private _checkPrePointerObservable;
  105207. /**
  105208. * Use this method to simulate a pointer move on a mesh
  105209. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105210. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105211. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105212. */
  105213. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105214. /**
  105215. * Use this method to simulate a pointer down 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. */
  105220. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105221. private _processPointerDown;
  105222. /** @hidden */
  105223. _isPointerSwiping(): boolean;
  105224. /**
  105225. * Use this method to simulate a pointer up on a mesh
  105226. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105227. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105228. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105229. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105230. */
  105231. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105232. private _processPointerUp;
  105233. /**
  105234. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105235. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105236. * @returns true if the pointer was captured
  105237. */
  105238. isPointerCaptured(pointerId?: number): boolean;
  105239. /**
  105240. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105241. * @param attachUp defines if you want to attach events to pointerup
  105242. * @param attachDown defines if you want to attach events to pointerdown
  105243. * @param attachMove defines if you want to attach events to pointermove
  105244. */
  105245. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105246. /**
  105247. * Detaches all event handlers
  105248. */
  105249. detachControl(): void;
  105250. /**
  105251. * Force the value of meshUnderPointer
  105252. * @param mesh defines the mesh to use
  105253. */
  105254. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105255. /**
  105256. * Gets the mesh under the pointer
  105257. * @returns a Mesh or null if no mesh is under the pointer
  105258. */
  105259. getPointerOverMesh(): Nullable<AbstractMesh>;
  105260. }
  105261. }
  105262. declare module BABYLON {
  105263. /**
  105264. * Helper class used to generate session unique ID
  105265. */
  105266. export class UniqueIdGenerator {
  105267. private static _UniqueIdCounter;
  105268. /**
  105269. * Gets an unique (relatively to the current scene) Id
  105270. */
  105271. static get UniqueId(): number;
  105272. }
  105273. }
  105274. declare module BABYLON {
  105275. /**
  105276. * This class defines the direct association between an animation and a target
  105277. */
  105278. export class TargetedAnimation {
  105279. /**
  105280. * Animation to perform
  105281. */
  105282. animation: Animation;
  105283. /**
  105284. * Target to animate
  105285. */
  105286. target: any;
  105287. /**
  105288. * Serialize the object
  105289. * @returns the JSON object representing the current entity
  105290. */
  105291. serialize(): any;
  105292. }
  105293. /**
  105294. * Use this class to create coordinated animations on multiple targets
  105295. */
  105296. export class AnimationGroup implements IDisposable {
  105297. /** The name of the animation group */
  105298. name: string;
  105299. private _scene;
  105300. private _targetedAnimations;
  105301. private _animatables;
  105302. private _from;
  105303. private _to;
  105304. private _isStarted;
  105305. private _isPaused;
  105306. private _speedRatio;
  105307. private _loopAnimation;
  105308. /**
  105309. * Gets or sets the unique id of the node
  105310. */
  105311. uniqueId: number;
  105312. /**
  105313. * This observable will notify when one animation have ended
  105314. */
  105315. onAnimationEndObservable: Observable<TargetedAnimation>;
  105316. /**
  105317. * Observer raised when one animation loops
  105318. */
  105319. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105320. /**
  105321. * Observer raised when all animations have looped
  105322. */
  105323. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105324. /**
  105325. * This observable will notify when all animations have ended.
  105326. */
  105327. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105328. /**
  105329. * This observable will notify when all animations have paused.
  105330. */
  105331. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105332. /**
  105333. * This observable will notify when all animations are playing.
  105334. */
  105335. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105336. /**
  105337. * Gets the first frame
  105338. */
  105339. get from(): number;
  105340. /**
  105341. * Gets the last frame
  105342. */
  105343. get to(): number;
  105344. /**
  105345. * Define if the animations are started
  105346. */
  105347. get isStarted(): boolean;
  105348. /**
  105349. * Gets a value indicating that the current group is playing
  105350. */
  105351. get isPlaying(): boolean;
  105352. /**
  105353. * Gets or sets the speed ratio to use for all animations
  105354. */
  105355. get speedRatio(): number;
  105356. /**
  105357. * Gets or sets the speed ratio to use for all animations
  105358. */
  105359. set speedRatio(value: number);
  105360. /**
  105361. * Gets or sets if all animations should loop or not
  105362. */
  105363. get loopAnimation(): boolean;
  105364. set loopAnimation(value: boolean);
  105365. /**
  105366. * Gets the targeted animations for this animation group
  105367. */
  105368. get targetedAnimations(): Array<TargetedAnimation>;
  105369. /**
  105370. * returning the list of animatables controlled by this animation group.
  105371. */
  105372. get animatables(): Array<Animatable>;
  105373. /**
  105374. * Instantiates a new Animation Group.
  105375. * This helps managing several animations at once.
  105376. * @see http://doc.babylonjs.com/how_to/group
  105377. * @param name Defines the name of the group
  105378. * @param scene Defines the scene the group belongs to
  105379. */
  105380. constructor(
  105381. /** The name of the animation group */
  105382. name: string, scene?: Nullable<Scene>);
  105383. /**
  105384. * Add an animation (with its target) in the group
  105385. * @param animation defines the animation we want to add
  105386. * @param target defines the target of the animation
  105387. * @returns the TargetedAnimation object
  105388. */
  105389. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105390. /**
  105391. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105392. * It can add constant keys at begin or end
  105393. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105394. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105395. * @returns the animation group
  105396. */
  105397. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105398. private _animationLoopCount;
  105399. private _animationLoopFlags;
  105400. private _processLoop;
  105401. /**
  105402. * Start all animations on given targets
  105403. * @param loop defines if animations must loop
  105404. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105405. * @param from defines the from key (optional)
  105406. * @param to defines the to key (optional)
  105407. * @returns the current animation group
  105408. */
  105409. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105410. /**
  105411. * Pause all animations
  105412. * @returns the animation group
  105413. */
  105414. pause(): AnimationGroup;
  105415. /**
  105416. * Play all animations to initial state
  105417. * This function will start() the animations if they were not started or will restart() them if they were paused
  105418. * @param loop defines if animations must loop
  105419. * @returns the animation group
  105420. */
  105421. play(loop?: boolean): AnimationGroup;
  105422. /**
  105423. * Reset all animations to initial state
  105424. * @returns the animation group
  105425. */
  105426. reset(): AnimationGroup;
  105427. /**
  105428. * Restart animations from key 0
  105429. * @returns the animation group
  105430. */
  105431. restart(): AnimationGroup;
  105432. /**
  105433. * Stop all animations
  105434. * @returns the animation group
  105435. */
  105436. stop(): AnimationGroup;
  105437. /**
  105438. * Set animation weight for all animatables
  105439. * @param weight defines the weight to use
  105440. * @return the animationGroup
  105441. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105442. */
  105443. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105444. /**
  105445. * Synchronize and normalize all animatables with a source animatable
  105446. * @param root defines the root animatable to synchronize with
  105447. * @return the animationGroup
  105448. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105449. */
  105450. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105451. /**
  105452. * Goes to a specific frame in this animation group
  105453. * @param frame the frame number to go to
  105454. * @return the animationGroup
  105455. */
  105456. goToFrame(frame: number): AnimationGroup;
  105457. /**
  105458. * Dispose all associated resources
  105459. */
  105460. dispose(): void;
  105461. private _checkAnimationGroupEnded;
  105462. /**
  105463. * Clone the current animation group and returns a copy
  105464. * @param newName defines the name of the new group
  105465. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105466. * @returns the new aniamtion group
  105467. */
  105468. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105469. /**
  105470. * Serializes the animationGroup to an object
  105471. * @returns Serialized object
  105472. */
  105473. serialize(): any;
  105474. /**
  105475. * Returns a new AnimationGroup object parsed from the source provided.
  105476. * @param parsedAnimationGroup defines the source
  105477. * @param scene defines the scene that will receive the animationGroup
  105478. * @returns a new AnimationGroup
  105479. */
  105480. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105481. /**
  105482. * Returns the string "AnimationGroup"
  105483. * @returns "AnimationGroup"
  105484. */
  105485. getClassName(): string;
  105486. /**
  105487. * Creates a detailled string about the object
  105488. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105489. * @returns a string representing the object
  105490. */
  105491. toString(fullDetails?: boolean): string;
  105492. }
  105493. }
  105494. declare module BABYLON {
  105495. /**
  105496. * Define an interface for all classes that will hold resources
  105497. */
  105498. export interface IDisposable {
  105499. /**
  105500. * Releases all held resources
  105501. */
  105502. dispose(): void;
  105503. }
  105504. /** Interface defining initialization parameters for Scene class */
  105505. export interface SceneOptions {
  105506. /**
  105507. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105508. * It will improve performance when the number of geometries becomes important.
  105509. */
  105510. useGeometryUniqueIdsMap?: boolean;
  105511. /**
  105512. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105513. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105514. */
  105515. useMaterialMeshMap?: boolean;
  105516. /**
  105517. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105518. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105519. */
  105520. useClonedMeshMap?: boolean;
  105521. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105522. virtual?: boolean;
  105523. }
  105524. /**
  105525. * Represents a scene to be rendered by the engine.
  105526. * @see http://doc.babylonjs.com/features/scene
  105527. */
  105528. export class Scene extends AbstractScene implements IAnimatable {
  105529. /** The fog is deactivated */
  105530. static readonly FOGMODE_NONE: number;
  105531. /** The fog density is following an exponential function */
  105532. static readonly FOGMODE_EXP: number;
  105533. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105534. static readonly FOGMODE_EXP2: number;
  105535. /** The fog density is following a linear function. */
  105536. static readonly FOGMODE_LINEAR: number;
  105537. /**
  105538. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105540. */
  105541. static MinDeltaTime: number;
  105542. /**
  105543. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105544. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105545. */
  105546. static MaxDeltaTime: number;
  105547. /**
  105548. * Factory used to create the default material.
  105549. * @param name The name of the material to create
  105550. * @param scene The scene to create the material for
  105551. * @returns The default material
  105552. */
  105553. static DefaultMaterialFactory(scene: Scene): Material;
  105554. /**
  105555. * Factory used to create the a collision coordinator.
  105556. * @returns The collision coordinator
  105557. */
  105558. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105559. /** @hidden */
  105560. _inputManager: InputManager;
  105561. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105562. cameraToUseForPointers: Nullable<Camera>;
  105563. /** @hidden */
  105564. readonly _isScene: boolean;
  105565. /**
  105566. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105567. */
  105568. autoClear: boolean;
  105569. /**
  105570. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105571. */
  105572. autoClearDepthAndStencil: boolean;
  105573. /**
  105574. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105575. */
  105576. clearColor: Color4;
  105577. /**
  105578. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105579. */
  105580. ambientColor: Color3;
  105581. /**
  105582. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105583. * It should only be one of the following (if not the default embedded one):
  105584. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105585. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105586. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105587. * The material properties need to be setup according to the type of texture in use.
  105588. */
  105589. environmentBRDFTexture: BaseTexture;
  105590. /** @hidden */
  105591. protected _environmentTexture: Nullable<BaseTexture>;
  105592. /**
  105593. * Texture used in all pbr material as the reflection texture.
  105594. * As in the majority of the scene they are the same (exception for multi room and so on),
  105595. * this is easier to reference from here than from all the materials.
  105596. */
  105597. get environmentTexture(): Nullable<BaseTexture>;
  105598. /**
  105599. * Texture used in all pbr material as the reflection texture.
  105600. * As in the majority of the scene they are the same (exception for multi room and so on),
  105601. * this is easier to set here than in all the materials.
  105602. */
  105603. set environmentTexture(value: Nullable<BaseTexture>);
  105604. /** @hidden */
  105605. protected _environmentIntensity: number;
  105606. /**
  105607. * Intensity of the environment in all pbr material.
  105608. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105609. * As in the majority of the scene they are the same (exception for multi room and so on),
  105610. * this is easier to reference from here than from all the materials.
  105611. */
  105612. get environmentIntensity(): number;
  105613. /**
  105614. * Intensity of the environment in all pbr material.
  105615. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105616. * As in the majority of the scene they are the same (exception for multi room and so on),
  105617. * this is easier to set here than in all the materials.
  105618. */
  105619. set environmentIntensity(value: number);
  105620. /** @hidden */
  105621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105622. /**
  105623. * Default image processing configuration used either in the rendering
  105624. * Forward main pass or through the imageProcessingPostProcess if present.
  105625. * As in the majority of the scene they are the same (exception for multi camera),
  105626. * this is easier to reference from here than from all the materials and post process.
  105627. *
  105628. * No setter as we it is a shared configuration, you can set the values instead.
  105629. */
  105630. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105631. private _forceWireframe;
  105632. /**
  105633. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105634. */
  105635. set forceWireframe(value: boolean);
  105636. get forceWireframe(): boolean;
  105637. private _skipFrustumClipping;
  105638. /**
  105639. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  105640. */
  105641. set skipFrustumClipping(value: boolean);
  105642. get skipFrustumClipping(): boolean;
  105643. private _forcePointsCloud;
  105644. /**
  105645. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105646. */
  105647. set forcePointsCloud(value: boolean);
  105648. get forcePointsCloud(): boolean;
  105649. /**
  105650. * Gets or sets the active clipplane 1
  105651. */
  105652. clipPlane: Nullable<Plane>;
  105653. /**
  105654. * Gets or sets the active clipplane 2
  105655. */
  105656. clipPlane2: Nullable<Plane>;
  105657. /**
  105658. * Gets or sets the active clipplane 3
  105659. */
  105660. clipPlane3: Nullable<Plane>;
  105661. /**
  105662. * Gets or sets the active clipplane 4
  105663. */
  105664. clipPlane4: Nullable<Plane>;
  105665. /**
  105666. * Gets or sets the active clipplane 5
  105667. */
  105668. clipPlane5: Nullable<Plane>;
  105669. /**
  105670. * Gets or sets the active clipplane 6
  105671. */
  105672. clipPlane6: Nullable<Plane>;
  105673. /**
  105674. * Gets or sets a boolean indicating if animations are enabled
  105675. */
  105676. animationsEnabled: boolean;
  105677. private _animationPropertiesOverride;
  105678. /**
  105679. * Gets or sets the animation properties override
  105680. */
  105681. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105682. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105683. /**
  105684. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105685. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105686. */
  105687. useConstantAnimationDeltaTime: boolean;
  105688. /**
  105689. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105690. * Please note that it requires to run a ray cast through the scene on every frame
  105691. */
  105692. constantlyUpdateMeshUnderPointer: boolean;
  105693. /**
  105694. * Defines the HTML cursor to use when hovering over interactive elements
  105695. */
  105696. hoverCursor: string;
  105697. /**
  105698. * Defines the HTML default cursor to use (empty by default)
  105699. */
  105700. defaultCursor: string;
  105701. /**
  105702. * Defines wether cursors are handled by the scene.
  105703. */
  105704. doNotHandleCursors: boolean;
  105705. /**
  105706. * This is used to call preventDefault() on pointer down
  105707. * in order to block unwanted artifacts like system double clicks
  105708. */
  105709. preventDefaultOnPointerDown: boolean;
  105710. /**
  105711. * This is used to call preventDefault() on pointer up
  105712. * in order to block unwanted artifacts like system double clicks
  105713. */
  105714. preventDefaultOnPointerUp: boolean;
  105715. /**
  105716. * Gets or sets user defined metadata
  105717. */
  105718. metadata: any;
  105719. /**
  105720. * For internal use only. Please do not use.
  105721. */
  105722. reservedDataStore: any;
  105723. /**
  105724. * Gets the name of the plugin used to load this scene (null by default)
  105725. */
  105726. loadingPluginName: string;
  105727. /**
  105728. * Use this array to add regular expressions used to disable offline support for specific urls
  105729. */
  105730. disableOfflineSupportExceptionRules: RegExp[];
  105731. /**
  105732. * An event triggered when the scene is disposed.
  105733. */
  105734. onDisposeObservable: Observable<Scene>;
  105735. private _onDisposeObserver;
  105736. /** Sets a function to be executed when this scene is disposed. */
  105737. set onDispose(callback: () => void);
  105738. /**
  105739. * An event triggered before rendering the scene (right after animations and physics)
  105740. */
  105741. onBeforeRenderObservable: Observable<Scene>;
  105742. private _onBeforeRenderObserver;
  105743. /** Sets a function to be executed before rendering this scene */
  105744. set beforeRender(callback: Nullable<() => void>);
  105745. /**
  105746. * An event triggered after rendering the scene
  105747. */
  105748. onAfterRenderObservable: Observable<Scene>;
  105749. /**
  105750. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105751. */
  105752. onAfterRenderCameraObservable: Observable<Camera>;
  105753. private _onAfterRenderObserver;
  105754. /** Sets a function to be executed after rendering this scene */
  105755. set afterRender(callback: Nullable<() => void>);
  105756. /**
  105757. * An event triggered before animating the scene
  105758. */
  105759. onBeforeAnimationsObservable: Observable<Scene>;
  105760. /**
  105761. * An event triggered after animations processing
  105762. */
  105763. onAfterAnimationsObservable: Observable<Scene>;
  105764. /**
  105765. * An event triggered before draw calls are ready to be sent
  105766. */
  105767. onBeforeDrawPhaseObservable: Observable<Scene>;
  105768. /**
  105769. * An event triggered after draw calls have been sent
  105770. */
  105771. onAfterDrawPhaseObservable: Observable<Scene>;
  105772. /**
  105773. * An event triggered when the scene is ready
  105774. */
  105775. onReadyObservable: Observable<Scene>;
  105776. /**
  105777. * An event triggered before rendering a camera
  105778. */
  105779. onBeforeCameraRenderObservable: Observable<Camera>;
  105780. private _onBeforeCameraRenderObserver;
  105781. /** Sets a function to be executed before rendering a camera*/
  105782. set beforeCameraRender(callback: () => void);
  105783. /**
  105784. * An event triggered after rendering a camera
  105785. */
  105786. onAfterCameraRenderObservable: Observable<Camera>;
  105787. private _onAfterCameraRenderObserver;
  105788. /** Sets a function to be executed after rendering a camera*/
  105789. set afterCameraRender(callback: () => void);
  105790. /**
  105791. * An event triggered when active meshes evaluation is about to start
  105792. */
  105793. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105794. /**
  105795. * An event triggered when active meshes evaluation is done
  105796. */
  105797. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105798. /**
  105799. * An event triggered when particles rendering is about to start
  105800. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105801. */
  105802. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105803. /**
  105804. * An event triggered when particles rendering is done
  105805. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105806. */
  105807. onAfterParticlesRenderingObservable: Observable<Scene>;
  105808. /**
  105809. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105810. */
  105811. onDataLoadedObservable: Observable<Scene>;
  105812. /**
  105813. * An event triggered when a camera is created
  105814. */
  105815. onNewCameraAddedObservable: Observable<Camera>;
  105816. /**
  105817. * An event triggered when a camera is removed
  105818. */
  105819. onCameraRemovedObservable: Observable<Camera>;
  105820. /**
  105821. * An event triggered when a light is created
  105822. */
  105823. onNewLightAddedObservable: Observable<Light>;
  105824. /**
  105825. * An event triggered when a light is removed
  105826. */
  105827. onLightRemovedObservable: Observable<Light>;
  105828. /**
  105829. * An event triggered when a geometry is created
  105830. */
  105831. onNewGeometryAddedObservable: Observable<Geometry>;
  105832. /**
  105833. * An event triggered when a geometry is removed
  105834. */
  105835. onGeometryRemovedObservable: Observable<Geometry>;
  105836. /**
  105837. * An event triggered when a transform node is created
  105838. */
  105839. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105840. /**
  105841. * An event triggered when a transform node is removed
  105842. */
  105843. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105844. /**
  105845. * An event triggered when a mesh is created
  105846. */
  105847. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105848. /**
  105849. * An event triggered when a mesh is removed
  105850. */
  105851. onMeshRemovedObservable: Observable<AbstractMesh>;
  105852. /**
  105853. * An event triggered when a skeleton is created
  105854. */
  105855. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105856. /**
  105857. * An event triggered when a skeleton is removed
  105858. */
  105859. onSkeletonRemovedObservable: Observable<Skeleton>;
  105860. /**
  105861. * An event triggered when a material is created
  105862. */
  105863. onNewMaterialAddedObservable: Observable<Material>;
  105864. /**
  105865. * An event triggered when a material is removed
  105866. */
  105867. onMaterialRemovedObservable: Observable<Material>;
  105868. /**
  105869. * An event triggered when a texture is created
  105870. */
  105871. onNewTextureAddedObservable: Observable<BaseTexture>;
  105872. /**
  105873. * An event triggered when a texture is removed
  105874. */
  105875. onTextureRemovedObservable: Observable<BaseTexture>;
  105876. /**
  105877. * An event triggered when render targets are about to be rendered
  105878. * Can happen multiple times per frame.
  105879. */
  105880. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105881. /**
  105882. * An event triggered when render targets were rendered.
  105883. * Can happen multiple times per frame.
  105884. */
  105885. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105886. /**
  105887. * An event triggered before calculating deterministic simulation step
  105888. */
  105889. onBeforeStepObservable: Observable<Scene>;
  105890. /**
  105891. * An event triggered after calculating deterministic simulation step
  105892. */
  105893. onAfterStepObservable: Observable<Scene>;
  105894. /**
  105895. * An event triggered when the activeCamera property is updated
  105896. */
  105897. onActiveCameraChanged: Observable<Scene>;
  105898. /**
  105899. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105900. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105901. * 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)
  105902. */
  105903. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105904. /**
  105905. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105906. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105907. * 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)
  105908. */
  105909. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105910. /**
  105911. * This Observable will when a mesh has been imported into the scene.
  105912. */
  105913. onMeshImportedObservable: Observable<AbstractMesh>;
  105914. /**
  105915. * This Observable will when an animation file has been imported into the scene.
  105916. */
  105917. onAnimationFileImportedObservable: Observable<Scene>;
  105918. /**
  105919. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105920. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105921. */
  105922. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105923. /** @hidden */
  105924. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105925. /**
  105926. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105927. */
  105928. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105929. /**
  105930. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105931. */
  105932. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105933. /**
  105934. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105935. */
  105936. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105937. /** Callback called when a pointer move is detected */
  105938. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105939. /** Callback called when a pointer down is detected */
  105940. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105941. /** Callback called when a pointer up is detected */
  105942. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105943. /** Callback called when a pointer pick is detected */
  105944. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105945. /**
  105946. * 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).
  105947. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105948. */
  105949. onPrePointerObservable: Observable<PointerInfoPre>;
  105950. /**
  105951. * Observable event triggered each time an input event is received from the rendering canvas
  105952. */
  105953. onPointerObservable: Observable<PointerInfo>;
  105954. /**
  105955. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105956. */
  105957. get unTranslatedPointer(): Vector2;
  105958. /**
  105959. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105960. */
  105961. static get DragMovementThreshold(): number;
  105962. static set DragMovementThreshold(value: number);
  105963. /**
  105964. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105965. */
  105966. static get LongPressDelay(): number;
  105967. static set LongPressDelay(value: number);
  105968. /**
  105969. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105970. */
  105971. static get DoubleClickDelay(): number;
  105972. static set DoubleClickDelay(value: number);
  105973. /** If you need to check double click without raising a single click at first click, enable this flag */
  105974. static get ExclusiveDoubleClickMode(): boolean;
  105975. static set ExclusiveDoubleClickMode(value: boolean);
  105976. /** @hidden */
  105977. _mirroredCameraPosition: Nullable<Vector3>;
  105978. /**
  105979. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105980. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105981. */
  105982. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105983. /**
  105984. * Observable event triggered each time an keyboard event is received from the hosting window
  105985. */
  105986. onKeyboardObservable: Observable<KeyboardInfo>;
  105987. private _useRightHandedSystem;
  105988. /**
  105989. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105990. */
  105991. set useRightHandedSystem(value: boolean);
  105992. get useRightHandedSystem(): boolean;
  105993. private _timeAccumulator;
  105994. private _currentStepId;
  105995. private _currentInternalStep;
  105996. /**
  105997. * Sets the step Id used by deterministic lock step
  105998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105999. * @param newStepId defines the step Id
  106000. */
  106001. setStepId(newStepId: number): void;
  106002. /**
  106003. * Gets the step Id used by deterministic lock step
  106004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106005. * @returns the step Id
  106006. */
  106007. getStepId(): number;
  106008. /**
  106009. * Gets the internal step used by deterministic lock step
  106010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106011. * @returns the internal step
  106012. */
  106013. getInternalStep(): number;
  106014. private _fogEnabled;
  106015. /**
  106016. * Gets or sets a boolean indicating if fog is enabled on this scene
  106017. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106018. * (Default is true)
  106019. */
  106020. set fogEnabled(value: boolean);
  106021. get fogEnabled(): boolean;
  106022. private _fogMode;
  106023. /**
  106024. * Gets or sets the fog mode to use
  106025. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106026. * | mode | value |
  106027. * | --- | --- |
  106028. * | FOGMODE_NONE | 0 |
  106029. * | FOGMODE_EXP | 1 |
  106030. * | FOGMODE_EXP2 | 2 |
  106031. * | FOGMODE_LINEAR | 3 |
  106032. */
  106033. set fogMode(value: number);
  106034. get fogMode(): number;
  106035. /**
  106036. * Gets or sets the fog color to use
  106037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106038. * (Default is Color3(0.2, 0.2, 0.3))
  106039. */
  106040. fogColor: Color3;
  106041. /**
  106042. * Gets or sets the fog density to use
  106043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106044. * (Default is 0.1)
  106045. */
  106046. fogDensity: number;
  106047. /**
  106048. * Gets or sets the fog start distance to use
  106049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106050. * (Default is 0)
  106051. */
  106052. fogStart: number;
  106053. /**
  106054. * Gets or sets the fog end distance to use
  106055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106056. * (Default is 1000)
  106057. */
  106058. fogEnd: number;
  106059. private _shadowsEnabled;
  106060. /**
  106061. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106062. */
  106063. set shadowsEnabled(value: boolean);
  106064. get shadowsEnabled(): boolean;
  106065. private _lightsEnabled;
  106066. /**
  106067. * Gets or sets a boolean indicating if lights are enabled on this scene
  106068. */
  106069. set lightsEnabled(value: boolean);
  106070. get lightsEnabled(): boolean;
  106071. /** All of the active cameras added to this scene. */
  106072. activeCameras: Camera[];
  106073. /** @hidden */
  106074. _activeCamera: Nullable<Camera>;
  106075. /** Gets or sets the current active camera */
  106076. get activeCamera(): Nullable<Camera>;
  106077. set activeCamera(value: Nullable<Camera>);
  106078. private _defaultMaterial;
  106079. /** The default material used on meshes when no material is affected */
  106080. get defaultMaterial(): Material;
  106081. /** The default material used on meshes when no material is affected */
  106082. set defaultMaterial(value: Material);
  106083. private _texturesEnabled;
  106084. /**
  106085. * Gets or sets a boolean indicating if textures are enabled on this scene
  106086. */
  106087. set texturesEnabled(value: boolean);
  106088. get texturesEnabled(): boolean;
  106089. /**
  106090. * Gets or sets a boolean indicating if particles are enabled on this scene
  106091. */
  106092. particlesEnabled: boolean;
  106093. /**
  106094. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106095. */
  106096. spritesEnabled: boolean;
  106097. private _skeletonsEnabled;
  106098. /**
  106099. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106100. */
  106101. set skeletonsEnabled(value: boolean);
  106102. get skeletonsEnabled(): boolean;
  106103. /**
  106104. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106105. */
  106106. lensFlaresEnabled: boolean;
  106107. /**
  106108. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106109. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106110. */
  106111. collisionsEnabled: boolean;
  106112. private _collisionCoordinator;
  106113. /** @hidden */
  106114. get collisionCoordinator(): ICollisionCoordinator;
  106115. /**
  106116. * Defines the gravity applied to this scene (used only for collisions)
  106117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106118. */
  106119. gravity: Vector3;
  106120. /**
  106121. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106122. */
  106123. postProcessesEnabled: boolean;
  106124. /**
  106125. * The list of postprocesses added to the scene
  106126. */
  106127. postProcesses: PostProcess[];
  106128. /**
  106129. * Gets the current postprocess manager
  106130. */
  106131. postProcessManager: PostProcessManager;
  106132. /**
  106133. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106134. */
  106135. renderTargetsEnabled: boolean;
  106136. /**
  106137. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106138. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106139. */
  106140. dumpNextRenderTargets: boolean;
  106141. /**
  106142. * The list of user defined render targets added to the scene
  106143. */
  106144. customRenderTargets: RenderTargetTexture[];
  106145. /**
  106146. * Defines if texture loading must be delayed
  106147. * If true, textures will only be loaded when they need to be rendered
  106148. */
  106149. useDelayedTextureLoading: boolean;
  106150. /**
  106151. * Gets the list of meshes imported to the scene through SceneLoader
  106152. */
  106153. importedMeshesFiles: String[];
  106154. /**
  106155. * Gets or sets a boolean indicating if probes are enabled on this scene
  106156. */
  106157. probesEnabled: boolean;
  106158. /**
  106159. * Gets or sets the current offline provider to use to store scene data
  106160. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106161. */
  106162. offlineProvider: IOfflineProvider;
  106163. /**
  106164. * Gets or sets the action manager associated with the scene
  106165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106166. */
  106167. actionManager: AbstractActionManager;
  106168. private _meshesForIntersections;
  106169. /**
  106170. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106171. */
  106172. proceduralTexturesEnabled: boolean;
  106173. private _engine;
  106174. private _totalVertices;
  106175. /** @hidden */
  106176. _activeIndices: PerfCounter;
  106177. /** @hidden */
  106178. _activeParticles: PerfCounter;
  106179. /** @hidden */
  106180. _activeBones: PerfCounter;
  106181. private _animationRatio;
  106182. /** @hidden */
  106183. _animationTimeLast: number;
  106184. /** @hidden */
  106185. _animationTime: number;
  106186. /**
  106187. * Gets or sets a general scale for animation speed
  106188. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106189. */
  106190. animationTimeScale: number;
  106191. /** @hidden */
  106192. _cachedMaterial: Nullable<Material>;
  106193. /** @hidden */
  106194. _cachedEffect: Nullable<Effect>;
  106195. /** @hidden */
  106196. _cachedVisibility: Nullable<number>;
  106197. private _renderId;
  106198. private _frameId;
  106199. private _executeWhenReadyTimeoutId;
  106200. private _intermediateRendering;
  106201. private _viewUpdateFlag;
  106202. private _projectionUpdateFlag;
  106203. /** @hidden */
  106204. _toBeDisposed: Nullable<IDisposable>[];
  106205. private _activeRequests;
  106206. /** @hidden */
  106207. _pendingData: any[];
  106208. private _isDisposed;
  106209. /**
  106210. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106211. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106212. */
  106213. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106214. private _activeMeshes;
  106215. private _processedMaterials;
  106216. private _renderTargets;
  106217. /** @hidden */
  106218. _activeParticleSystems: SmartArray<IParticleSystem>;
  106219. private _activeSkeletons;
  106220. private _softwareSkinnedMeshes;
  106221. private _renderingManager;
  106222. /** @hidden */
  106223. _activeAnimatables: Animatable[];
  106224. private _transformMatrix;
  106225. private _sceneUbo;
  106226. /** @hidden */
  106227. _viewMatrix: Matrix;
  106228. private _projectionMatrix;
  106229. /** @hidden */
  106230. _forcedViewPosition: Nullable<Vector3>;
  106231. /** @hidden */
  106232. _frustumPlanes: Plane[];
  106233. /**
  106234. * Gets the list of frustum planes (built from the active camera)
  106235. */
  106236. get frustumPlanes(): Plane[];
  106237. /**
  106238. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106239. * This is useful if there are more lights that the maximum simulteanous authorized
  106240. */
  106241. requireLightSorting: boolean;
  106242. /** @hidden */
  106243. readonly useMaterialMeshMap: boolean;
  106244. /** @hidden */
  106245. readonly useClonedMeshMap: boolean;
  106246. private _externalData;
  106247. private _uid;
  106248. /**
  106249. * @hidden
  106250. * Backing store of defined scene components.
  106251. */
  106252. _components: ISceneComponent[];
  106253. /**
  106254. * @hidden
  106255. * Backing store of defined scene components.
  106256. */
  106257. _serializableComponents: ISceneSerializableComponent[];
  106258. /**
  106259. * List of components to register on the next registration step.
  106260. */
  106261. private _transientComponents;
  106262. /**
  106263. * Registers the transient components if needed.
  106264. */
  106265. private _registerTransientComponents;
  106266. /**
  106267. * @hidden
  106268. * Add a component to the scene.
  106269. * Note that the ccomponent could be registered on th next frame if this is called after
  106270. * the register component stage.
  106271. * @param component Defines the component to add to the scene
  106272. */
  106273. _addComponent(component: ISceneComponent): void;
  106274. /**
  106275. * @hidden
  106276. * Gets a component from the scene.
  106277. * @param name defines the name of the component to retrieve
  106278. * @returns the component or null if not present
  106279. */
  106280. _getComponent(name: string): Nullable<ISceneComponent>;
  106281. /**
  106282. * @hidden
  106283. * Defines the actions happening before camera updates.
  106284. */
  106285. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106286. /**
  106287. * @hidden
  106288. * Defines the actions happening before clear the canvas.
  106289. */
  106290. _beforeClearStage: Stage<SimpleStageAction>;
  106291. /**
  106292. * @hidden
  106293. * Defines the actions when collecting render targets for the frame.
  106294. */
  106295. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106296. /**
  106297. * @hidden
  106298. * Defines the actions happening for one camera in the frame.
  106299. */
  106300. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106301. /**
  106302. * @hidden
  106303. * Defines the actions happening during the per mesh ready checks.
  106304. */
  106305. _isReadyForMeshStage: Stage<MeshStageAction>;
  106306. /**
  106307. * @hidden
  106308. * Defines the actions happening before evaluate active mesh checks.
  106309. */
  106310. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106311. /**
  106312. * @hidden
  106313. * Defines the actions happening during the evaluate sub mesh checks.
  106314. */
  106315. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106316. /**
  106317. * @hidden
  106318. * Defines the actions happening during the active mesh stage.
  106319. */
  106320. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106321. /**
  106322. * @hidden
  106323. * Defines the actions happening during the per camera render target step.
  106324. */
  106325. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106326. /**
  106327. * @hidden
  106328. * Defines the actions happening just before the active camera is drawing.
  106329. */
  106330. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106331. /**
  106332. * @hidden
  106333. * Defines the actions happening just before a render target is drawing.
  106334. */
  106335. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106336. /**
  106337. * @hidden
  106338. * Defines the actions happening just before a rendering group is drawing.
  106339. */
  106340. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106341. /**
  106342. * @hidden
  106343. * Defines the actions happening just before a mesh is drawing.
  106344. */
  106345. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106346. /**
  106347. * @hidden
  106348. * Defines the actions happening just after a mesh has been drawn.
  106349. */
  106350. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106351. /**
  106352. * @hidden
  106353. * Defines the actions happening just after a rendering group has been drawn.
  106354. */
  106355. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106356. /**
  106357. * @hidden
  106358. * Defines the actions happening just after the active camera has been drawn.
  106359. */
  106360. _afterCameraDrawStage: Stage<CameraStageAction>;
  106361. /**
  106362. * @hidden
  106363. * Defines the actions happening just after a render target has been drawn.
  106364. */
  106365. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106366. /**
  106367. * @hidden
  106368. * Defines the actions happening just after rendering all cameras and computing intersections.
  106369. */
  106370. _afterRenderStage: Stage<SimpleStageAction>;
  106371. /**
  106372. * @hidden
  106373. * Defines the actions happening when a pointer move event happens.
  106374. */
  106375. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106376. /**
  106377. * @hidden
  106378. * Defines the actions happening when a pointer down event happens.
  106379. */
  106380. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106381. /**
  106382. * @hidden
  106383. * Defines the actions happening when a pointer up event happens.
  106384. */
  106385. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106386. /**
  106387. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106388. */
  106389. private geometriesByUniqueId;
  106390. /**
  106391. * Creates a new Scene
  106392. * @param engine defines the engine to use to render this scene
  106393. * @param options defines the scene options
  106394. */
  106395. constructor(engine: Engine, options?: SceneOptions);
  106396. /**
  106397. * Gets a string idenfifying the name of the class
  106398. * @returns "Scene" string
  106399. */
  106400. getClassName(): string;
  106401. private _defaultMeshCandidates;
  106402. /**
  106403. * @hidden
  106404. */
  106405. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106406. private _defaultSubMeshCandidates;
  106407. /**
  106408. * @hidden
  106409. */
  106410. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106411. /**
  106412. * Sets the default candidate providers for the scene.
  106413. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106414. * and getCollidingSubMeshCandidates to their default function
  106415. */
  106416. setDefaultCandidateProviders(): void;
  106417. /**
  106418. * Gets the mesh that is currently under the pointer
  106419. */
  106420. get meshUnderPointer(): Nullable<AbstractMesh>;
  106421. /**
  106422. * Gets or sets the current on-screen X position of the pointer
  106423. */
  106424. get pointerX(): number;
  106425. set pointerX(value: number);
  106426. /**
  106427. * Gets or sets the current on-screen Y position of the pointer
  106428. */
  106429. get pointerY(): number;
  106430. set pointerY(value: number);
  106431. /**
  106432. * Gets the cached material (ie. the latest rendered one)
  106433. * @returns the cached material
  106434. */
  106435. getCachedMaterial(): Nullable<Material>;
  106436. /**
  106437. * Gets the cached effect (ie. the latest rendered one)
  106438. * @returns the cached effect
  106439. */
  106440. getCachedEffect(): Nullable<Effect>;
  106441. /**
  106442. * Gets the cached visibility state (ie. the latest rendered one)
  106443. * @returns the cached visibility state
  106444. */
  106445. getCachedVisibility(): Nullable<number>;
  106446. /**
  106447. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106448. * @param material defines the current material
  106449. * @param effect defines the current effect
  106450. * @param visibility defines the current visibility state
  106451. * @returns true if one parameter is not cached
  106452. */
  106453. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106454. /**
  106455. * Gets the engine associated with the scene
  106456. * @returns an Engine
  106457. */
  106458. getEngine(): Engine;
  106459. /**
  106460. * Gets the total number of vertices rendered per frame
  106461. * @returns the total number of vertices rendered per frame
  106462. */
  106463. getTotalVertices(): number;
  106464. /**
  106465. * Gets the performance counter for total vertices
  106466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106467. */
  106468. get totalVerticesPerfCounter(): PerfCounter;
  106469. /**
  106470. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106471. * @returns the total number of active indices rendered per frame
  106472. */
  106473. getActiveIndices(): number;
  106474. /**
  106475. * Gets the performance counter for active indices
  106476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106477. */
  106478. get totalActiveIndicesPerfCounter(): PerfCounter;
  106479. /**
  106480. * Gets the total number of active particles rendered per frame
  106481. * @returns the total number of active particles rendered per frame
  106482. */
  106483. getActiveParticles(): number;
  106484. /**
  106485. * Gets the performance counter for active particles
  106486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106487. */
  106488. get activeParticlesPerfCounter(): PerfCounter;
  106489. /**
  106490. * Gets the total number of active bones rendered per frame
  106491. * @returns the total number of active bones rendered per frame
  106492. */
  106493. getActiveBones(): number;
  106494. /**
  106495. * Gets the performance counter for active bones
  106496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106497. */
  106498. get activeBonesPerfCounter(): PerfCounter;
  106499. /**
  106500. * Gets the array of active meshes
  106501. * @returns an array of AbstractMesh
  106502. */
  106503. getActiveMeshes(): SmartArray<AbstractMesh>;
  106504. /**
  106505. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106506. * @returns a number
  106507. */
  106508. getAnimationRatio(): number;
  106509. /**
  106510. * Gets an unique Id for the current render phase
  106511. * @returns a number
  106512. */
  106513. getRenderId(): number;
  106514. /**
  106515. * Gets an unique Id for the current frame
  106516. * @returns a number
  106517. */
  106518. getFrameId(): number;
  106519. /** Call this function if you want to manually increment the render Id*/
  106520. incrementRenderId(): void;
  106521. private _createUbo;
  106522. /**
  106523. * Use this method to simulate a pointer move on a mesh
  106524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106527. * @returns the current scene
  106528. */
  106529. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106530. /**
  106531. * Use this method to simulate a pointer down on a mesh
  106532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106535. * @returns the current scene
  106536. */
  106537. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106538. /**
  106539. * Use this method to simulate a pointer up on a mesh
  106540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106543. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106544. * @returns the current scene
  106545. */
  106546. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106547. /**
  106548. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106549. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106550. * @returns true if the pointer was captured
  106551. */
  106552. isPointerCaptured(pointerId?: number): boolean;
  106553. /**
  106554. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106555. * @param attachUp defines if you want to attach events to pointerup
  106556. * @param attachDown defines if you want to attach events to pointerdown
  106557. * @param attachMove defines if you want to attach events to pointermove
  106558. */
  106559. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106560. /** Detaches all event handlers*/
  106561. detachControl(): void;
  106562. /**
  106563. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106564. * Delay loaded resources are not taking in account
  106565. * @return true if all required resources are ready
  106566. */
  106567. isReady(): boolean;
  106568. /** Resets all cached information relative to material (including effect and visibility) */
  106569. resetCachedMaterial(): void;
  106570. /**
  106571. * Registers a function to be called before every frame render
  106572. * @param func defines the function to register
  106573. */
  106574. registerBeforeRender(func: () => void): void;
  106575. /**
  106576. * Unregisters a function called before every frame render
  106577. * @param func defines the function to unregister
  106578. */
  106579. unregisterBeforeRender(func: () => void): void;
  106580. /**
  106581. * Registers a function to be called after every frame render
  106582. * @param func defines the function to register
  106583. */
  106584. registerAfterRender(func: () => void): void;
  106585. /**
  106586. * Unregisters a function called after every frame render
  106587. * @param func defines the function to unregister
  106588. */
  106589. unregisterAfterRender(func: () => void): void;
  106590. private _executeOnceBeforeRender;
  106591. /**
  106592. * The provided function will run before render once and will be disposed afterwards.
  106593. * A timeout delay can be provided so that the function will be executed in N ms.
  106594. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106595. * @param func The function to be executed.
  106596. * @param timeout optional delay in ms
  106597. */
  106598. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106599. /** @hidden */
  106600. _addPendingData(data: any): void;
  106601. /** @hidden */
  106602. _removePendingData(data: any): void;
  106603. /**
  106604. * Returns the number of items waiting to be loaded
  106605. * @returns the number of items waiting to be loaded
  106606. */
  106607. getWaitingItemsCount(): number;
  106608. /**
  106609. * Returns a boolean indicating if the scene is still loading data
  106610. */
  106611. get isLoading(): boolean;
  106612. /**
  106613. * Registers a function to be executed when the scene is ready
  106614. * @param {Function} func - the function to be executed
  106615. */
  106616. executeWhenReady(func: () => void): void;
  106617. /**
  106618. * Returns a promise that resolves when the scene is ready
  106619. * @returns A promise that resolves when the scene is ready
  106620. */
  106621. whenReadyAsync(): Promise<void>;
  106622. /** @hidden */
  106623. _checkIsReady(): void;
  106624. /**
  106625. * Gets all animatable attached to the scene
  106626. */
  106627. get animatables(): Animatable[];
  106628. /**
  106629. * Resets the last animation time frame.
  106630. * Useful to override when animations start running when loading a scene for the first time.
  106631. */
  106632. resetLastAnimationTimeFrame(): void;
  106633. /**
  106634. * Gets the current view matrix
  106635. * @returns a Matrix
  106636. */
  106637. getViewMatrix(): Matrix;
  106638. /**
  106639. * Gets the current projection matrix
  106640. * @returns a Matrix
  106641. */
  106642. getProjectionMatrix(): Matrix;
  106643. /**
  106644. * Gets the current transform matrix
  106645. * @returns a Matrix made of View * Projection
  106646. */
  106647. getTransformMatrix(): Matrix;
  106648. /**
  106649. * Sets the current transform matrix
  106650. * @param viewL defines the View matrix to use
  106651. * @param projectionL defines the Projection matrix to use
  106652. * @param viewR defines the right View matrix to use (if provided)
  106653. * @param projectionR defines the right Projection matrix to use (if provided)
  106654. */
  106655. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106656. /**
  106657. * Gets the uniform buffer used to store scene data
  106658. * @returns a UniformBuffer
  106659. */
  106660. getSceneUniformBuffer(): UniformBuffer;
  106661. /**
  106662. * Gets an unique (relatively to the current scene) Id
  106663. * @returns an unique number for the scene
  106664. */
  106665. getUniqueId(): number;
  106666. /**
  106667. * Add a mesh to the list of scene's meshes
  106668. * @param newMesh defines the mesh to add
  106669. * @param recursive if all child meshes should also be added to the scene
  106670. */
  106671. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106672. /**
  106673. * Remove a mesh for the list of scene's meshes
  106674. * @param toRemove defines the mesh to remove
  106675. * @param recursive if all child meshes should also be removed from the scene
  106676. * @returns the index where the mesh was in the mesh list
  106677. */
  106678. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106679. /**
  106680. * Add a transform node to the list of scene's transform nodes
  106681. * @param newTransformNode defines the transform node to add
  106682. */
  106683. addTransformNode(newTransformNode: TransformNode): void;
  106684. /**
  106685. * Remove a transform node for the list of scene's transform nodes
  106686. * @param toRemove defines the transform node to remove
  106687. * @returns the index where the transform node was in the transform node list
  106688. */
  106689. removeTransformNode(toRemove: TransformNode): number;
  106690. /**
  106691. * Remove a skeleton for the list of scene's skeletons
  106692. * @param toRemove defines the skeleton to remove
  106693. * @returns the index where the skeleton was in the skeleton list
  106694. */
  106695. removeSkeleton(toRemove: Skeleton): number;
  106696. /**
  106697. * Remove a morph target for the list of scene's morph targets
  106698. * @param toRemove defines the morph target to remove
  106699. * @returns the index where the morph target was in the morph target list
  106700. */
  106701. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106702. /**
  106703. * Remove a light for the list of scene's lights
  106704. * @param toRemove defines the light to remove
  106705. * @returns the index where the light was in the light list
  106706. */
  106707. removeLight(toRemove: Light): number;
  106708. /**
  106709. * Remove a camera for the list of scene's cameras
  106710. * @param toRemove defines the camera to remove
  106711. * @returns the index where the camera was in the camera list
  106712. */
  106713. removeCamera(toRemove: Camera): number;
  106714. /**
  106715. * Remove a particle system for the list of scene's particle systems
  106716. * @param toRemove defines the particle system to remove
  106717. * @returns the index where the particle system was in the particle system list
  106718. */
  106719. removeParticleSystem(toRemove: IParticleSystem): number;
  106720. /**
  106721. * Remove a animation for the list of scene's animations
  106722. * @param toRemove defines the animation to remove
  106723. * @returns the index where the animation was in the animation list
  106724. */
  106725. removeAnimation(toRemove: Animation): number;
  106726. /**
  106727. * Will stop the animation of the given target
  106728. * @param target - the target
  106729. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106730. * @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)
  106731. */
  106732. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106733. /**
  106734. * Removes the given animation group from this scene.
  106735. * @param toRemove The animation group to remove
  106736. * @returns The index of the removed animation group
  106737. */
  106738. removeAnimationGroup(toRemove: AnimationGroup): number;
  106739. /**
  106740. * Removes the given multi-material from this scene.
  106741. * @param toRemove The multi-material to remove
  106742. * @returns The index of the removed multi-material
  106743. */
  106744. removeMultiMaterial(toRemove: MultiMaterial): number;
  106745. /**
  106746. * Removes the given material from this scene.
  106747. * @param toRemove The material to remove
  106748. * @returns The index of the removed material
  106749. */
  106750. removeMaterial(toRemove: Material): number;
  106751. /**
  106752. * Removes the given action manager from this scene.
  106753. * @param toRemove The action manager to remove
  106754. * @returns The index of the removed action manager
  106755. */
  106756. removeActionManager(toRemove: AbstractActionManager): number;
  106757. /**
  106758. * Removes the given texture from this scene.
  106759. * @param toRemove The texture to remove
  106760. * @returns The index of the removed texture
  106761. */
  106762. removeTexture(toRemove: BaseTexture): number;
  106763. /**
  106764. * Adds the given light to this scene
  106765. * @param newLight The light to add
  106766. */
  106767. addLight(newLight: Light): void;
  106768. /**
  106769. * Sorts the list list based on light priorities
  106770. */
  106771. sortLightsByPriority(): void;
  106772. /**
  106773. * Adds the given camera to this scene
  106774. * @param newCamera The camera to add
  106775. */
  106776. addCamera(newCamera: Camera): void;
  106777. /**
  106778. * Adds the given skeleton to this scene
  106779. * @param newSkeleton The skeleton to add
  106780. */
  106781. addSkeleton(newSkeleton: Skeleton): void;
  106782. /**
  106783. * Adds the given particle system to this scene
  106784. * @param newParticleSystem The particle system to add
  106785. */
  106786. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106787. /**
  106788. * Adds the given animation to this scene
  106789. * @param newAnimation The animation to add
  106790. */
  106791. addAnimation(newAnimation: Animation): void;
  106792. /**
  106793. * Adds the given animation group to this scene.
  106794. * @param newAnimationGroup The animation group to add
  106795. */
  106796. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106797. /**
  106798. * Adds the given multi-material to this scene
  106799. * @param newMultiMaterial The multi-material to add
  106800. */
  106801. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106802. /**
  106803. * Adds the given material to this scene
  106804. * @param newMaterial The material to add
  106805. */
  106806. addMaterial(newMaterial: Material): void;
  106807. /**
  106808. * Adds the given morph target to this scene
  106809. * @param newMorphTargetManager The morph target to add
  106810. */
  106811. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106812. /**
  106813. * Adds the given geometry to this scene
  106814. * @param newGeometry The geometry to add
  106815. */
  106816. addGeometry(newGeometry: Geometry): void;
  106817. /**
  106818. * Adds the given action manager to this scene
  106819. * @param newActionManager The action manager to add
  106820. */
  106821. addActionManager(newActionManager: AbstractActionManager): void;
  106822. /**
  106823. * Adds the given texture to this scene.
  106824. * @param newTexture The texture to add
  106825. */
  106826. addTexture(newTexture: BaseTexture): void;
  106827. /**
  106828. * Switch active camera
  106829. * @param newCamera defines the new active camera
  106830. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106831. */
  106832. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106833. /**
  106834. * sets the active camera of the scene using its ID
  106835. * @param id defines the camera's ID
  106836. * @return the new active camera or null if none found.
  106837. */
  106838. setActiveCameraByID(id: string): Nullable<Camera>;
  106839. /**
  106840. * sets the active camera of the scene using its name
  106841. * @param name defines the camera's name
  106842. * @returns the new active camera or null if none found.
  106843. */
  106844. setActiveCameraByName(name: string): Nullable<Camera>;
  106845. /**
  106846. * get an animation group using its name
  106847. * @param name defines the material's name
  106848. * @return the animation group or null if none found.
  106849. */
  106850. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106851. /**
  106852. * Get a material using its unique id
  106853. * @param uniqueId defines the material's unique id
  106854. * @return the material or null if none found.
  106855. */
  106856. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106857. /**
  106858. * get a material using its id
  106859. * @param id defines the material's ID
  106860. * @return the material or null if none found.
  106861. */
  106862. getMaterialByID(id: string): Nullable<Material>;
  106863. /**
  106864. * Gets a the last added material using a given id
  106865. * @param id defines the material's ID
  106866. * @return the last material with the given id or null if none found.
  106867. */
  106868. getLastMaterialByID(id: string): Nullable<Material>;
  106869. /**
  106870. * Gets a material using its name
  106871. * @param name defines the material's name
  106872. * @return the material or null if none found.
  106873. */
  106874. getMaterialByName(name: string): Nullable<Material>;
  106875. /**
  106876. * Get a texture using its unique id
  106877. * @param uniqueId defines the texture's unique id
  106878. * @return the texture or null if none found.
  106879. */
  106880. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106881. /**
  106882. * Gets a camera using its id
  106883. * @param id defines the id to look for
  106884. * @returns the camera or null if not found
  106885. */
  106886. getCameraByID(id: string): Nullable<Camera>;
  106887. /**
  106888. * Gets a camera using its unique id
  106889. * @param uniqueId defines the unique id to look for
  106890. * @returns the camera or null if not found
  106891. */
  106892. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106893. /**
  106894. * Gets a camera using its name
  106895. * @param name defines the camera's name
  106896. * @return the camera or null if none found.
  106897. */
  106898. getCameraByName(name: string): Nullable<Camera>;
  106899. /**
  106900. * Gets a bone using its id
  106901. * @param id defines the bone's id
  106902. * @return the bone or null if not found
  106903. */
  106904. getBoneByID(id: string): Nullable<Bone>;
  106905. /**
  106906. * Gets a bone using its id
  106907. * @param name defines the bone's name
  106908. * @return the bone or null if not found
  106909. */
  106910. getBoneByName(name: string): Nullable<Bone>;
  106911. /**
  106912. * Gets a light node using its name
  106913. * @param name defines the the light's name
  106914. * @return the light or null if none found.
  106915. */
  106916. getLightByName(name: string): Nullable<Light>;
  106917. /**
  106918. * Gets a light node using its id
  106919. * @param id defines the light's id
  106920. * @return the light or null if none found.
  106921. */
  106922. getLightByID(id: string): Nullable<Light>;
  106923. /**
  106924. * Gets a light node using its scene-generated unique ID
  106925. * @param uniqueId defines the light's unique id
  106926. * @return the light or null if none found.
  106927. */
  106928. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106929. /**
  106930. * Gets a particle system by id
  106931. * @param id defines the particle system id
  106932. * @return the corresponding system or null if none found
  106933. */
  106934. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106935. /**
  106936. * Gets a geometry using its ID
  106937. * @param id defines the geometry's id
  106938. * @return the geometry or null if none found.
  106939. */
  106940. getGeometryByID(id: string): Nullable<Geometry>;
  106941. private _getGeometryByUniqueID;
  106942. /**
  106943. * Add a new geometry to this scene
  106944. * @param geometry defines the geometry to be added to the scene.
  106945. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106946. * @return a boolean defining if the geometry was added or not
  106947. */
  106948. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106949. /**
  106950. * Removes an existing geometry
  106951. * @param geometry defines the geometry to be removed from the scene
  106952. * @return a boolean defining if the geometry was removed or not
  106953. */
  106954. removeGeometry(geometry: Geometry): boolean;
  106955. /**
  106956. * Gets the list of geometries attached to the scene
  106957. * @returns an array of Geometry
  106958. */
  106959. getGeometries(): Geometry[];
  106960. /**
  106961. * Gets the first added mesh found of a given ID
  106962. * @param id defines the id to search for
  106963. * @return the mesh found or null if not found at all
  106964. */
  106965. getMeshByID(id: string): Nullable<AbstractMesh>;
  106966. /**
  106967. * Gets a list of meshes using their id
  106968. * @param id defines the id to search for
  106969. * @returns a list of meshes
  106970. */
  106971. getMeshesByID(id: string): Array<AbstractMesh>;
  106972. /**
  106973. * Gets the first added transform node found of a given ID
  106974. * @param id defines the id to search for
  106975. * @return the found transform node or null if not found at all.
  106976. */
  106977. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106978. /**
  106979. * Gets a transform node with its auto-generated unique id
  106980. * @param uniqueId efines the unique id to search for
  106981. * @return the found transform node or null if not found at all.
  106982. */
  106983. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106984. /**
  106985. * Gets a list of transform nodes using their id
  106986. * @param id defines the id to search for
  106987. * @returns a list of transform nodes
  106988. */
  106989. getTransformNodesByID(id: string): Array<TransformNode>;
  106990. /**
  106991. * Gets a mesh with its auto-generated unique id
  106992. * @param uniqueId defines the unique id to search for
  106993. * @return the found mesh or null if not found at all.
  106994. */
  106995. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106996. /**
  106997. * Gets a the last added mesh using a given id
  106998. * @param id defines the id to search for
  106999. * @return the found mesh or null if not found at all.
  107000. */
  107001. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  107002. /**
  107003. * Gets a the last added node (Mesh, Camera, Light) using a given id
  107004. * @param id defines the id to search for
  107005. * @return the found node or null if not found at all
  107006. */
  107007. getLastEntryByID(id: string): Nullable<Node>;
  107008. /**
  107009. * Gets a node (Mesh, Camera, Light) using a given id
  107010. * @param id defines the id to search for
  107011. * @return the found node or null if not found at all
  107012. */
  107013. getNodeByID(id: string): Nullable<Node>;
  107014. /**
  107015. * Gets a node (Mesh, Camera, Light) using a given name
  107016. * @param name defines the name to search for
  107017. * @return the found node or null if not found at all.
  107018. */
  107019. getNodeByName(name: string): Nullable<Node>;
  107020. /**
  107021. * Gets a mesh using a given name
  107022. * @param name defines the name to search for
  107023. * @return the found mesh or null if not found at all.
  107024. */
  107025. getMeshByName(name: string): Nullable<AbstractMesh>;
  107026. /**
  107027. * Gets a transform node using a given name
  107028. * @param name defines the name to search for
  107029. * @return the found transform node or null if not found at all.
  107030. */
  107031. getTransformNodeByName(name: string): Nullable<TransformNode>;
  107032. /**
  107033. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  107034. * @param id defines the id to search for
  107035. * @return the found skeleton or null if not found at all.
  107036. */
  107037. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  107038. /**
  107039. * Gets a skeleton using a given auto generated unique id
  107040. * @param uniqueId defines the unique id to search for
  107041. * @return the found skeleton or null if not found at all.
  107042. */
  107043. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  107044. /**
  107045. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  107046. * @param id defines the id to search for
  107047. * @return the found skeleton or null if not found at all.
  107048. */
  107049. getSkeletonById(id: string): Nullable<Skeleton>;
  107050. /**
  107051. * Gets a skeleton using a given name
  107052. * @param name defines the name to search for
  107053. * @return the found skeleton or null if not found at all.
  107054. */
  107055. getSkeletonByName(name: string): Nullable<Skeleton>;
  107056. /**
  107057. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107058. * @param id defines the id to search for
  107059. * @return the found morph target manager or null if not found at all.
  107060. */
  107061. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107062. /**
  107063. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107064. * @param id defines the id to search for
  107065. * @return the found morph target or null if not found at all.
  107066. */
  107067. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107068. /**
  107069. * Gets a boolean indicating if the given mesh is active
  107070. * @param mesh defines the mesh to look for
  107071. * @returns true if the mesh is in the active list
  107072. */
  107073. isActiveMesh(mesh: AbstractMesh): boolean;
  107074. /**
  107075. * Return a unique id as a string which can serve as an identifier for the scene
  107076. */
  107077. get uid(): string;
  107078. /**
  107079. * Add an externaly attached data from its key.
  107080. * This method call will fail and return false, if such key already exists.
  107081. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107082. * @param key the unique key that identifies the data
  107083. * @param data the data object to associate to the key for this Engine instance
  107084. * @return true if no such key were already present and the data was added successfully, false otherwise
  107085. */
  107086. addExternalData<T>(key: string, data: T): boolean;
  107087. /**
  107088. * Get an externaly attached data from its key
  107089. * @param key the unique key that identifies the data
  107090. * @return the associated data, if present (can be null), or undefined if not present
  107091. */
  107092. getExternalData<T>(key: string): Nullable<T>;
  107093. /**
  107094. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107095. * @param key the unique key that identifies the data
  107096. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107097. * @return the associated data, can be null if the factory returned null.
  107098. */
  107099. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107100. /**
  107101. * Remove an externaly attached data from the Engine instance
  107102. * @param key the unique key that identifies the data
  107103. * @return true if the data was successfully removed, false if it doesn't exist
  107104. */
  107105. removeExternalData(key: string): boolean;
  107106. private _evaluateSubMesh;
  107107. /**
  107108. * Clear the processed materials smart array preventing retention point in material dispose.
  107109. */
  107110. freeProcessedMaterials(): void;
  107111. private _preventFreeActiveMeshesAndRenderingGroups;
  107112. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107113. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107114. * when disposing several meshes in a row or a hierarchy of meshes.
  107115. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107116. */
  107117. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107118. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107119. /**
  107120. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107121. */
  107122. freeActiveMeshes(): void;
  107123. /**
  107124. * Clear the info related to rendering groups preventing retention points during dispose.
  107125. */
  107126. freeRenderingGroups(): void;
  107127. /** @hidden */
  107128. _isInIntermediateRendering(): boolean;
  107129. /**
  107130. * Lambda returning the list of potentially active meshes.
  107131. */
  107132. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107133. /**
  107134. * Lambda returning the list of potentially active sub meshes.
  107135. */
  107136. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107137. /**
  107138. * Lambda returning the list of potentially intersecting sub meshes.
  107139. */
  107140. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107141. /**
  107142. * Lambda returning the list of potentially colliding sub meshes.
  107143. */
  107144. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107145. private _activeMeshesFrozen;
  107146. private _skipEvaluateActiveMeshesCompletely;
  107147. /**
  107148. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107149. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107150. * @returns the current scene
  107151. */
  107152. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107153. /**
  107154. * Use this function to restart evaluating active meshes on every frame
  107155. * @returns the current scene
  107156. */
  107157. unfreezeActiveMeshes(): Scene;
  107158. private _evaluateActiveMeshes;
  107159. private _activeMesh;
  107160. /**
  107161. * Update the transform matrix to update from the current active camera
  107162. * @param force defines a boolean used to force the update even if cache is up to date
  107163. */
  107164. updateTransformMatrix(force?: boolean): void;
  107165. private _bindFrameBuffer;
  107166. /** @hidden */
  107167. _allowPostProcessClearColor: boolean;
  107168. /** @hidden */
  107169. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107170. private _processSubCameras;
  107171. private _checkIntersections;
  107172. /** @hidden */
  107173. _advancePhysicsEngineStep(step: number): void;
  107174. /**
  107175. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107176. */
  107177. getDeterministicFrameTime: () => number;
  107178. /** @hidden */
  107179. _animate(): void;
  107180. /** Execute all animations (for a frame) */
  107181. animate(): void;
  107182. /**
  107183. * Render the scene
  107184. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107185. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107186. */
  107187. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107188. /**
  107189. * Freeze all materials
  107190. * A frozen material will not be updatable but should be faster to render
  107191. */
  107192. freezeMaterials(): void;
  107193. /**
  107194. * Unfreeze all materials
  107195. * A frozen material will not be updatable but should be faster to render
  107196. */
  107197. unfreezeMaterials(): void;
  107198. /**
  107199. * Releases all held ressources
  107200. */
  107201. dispose(): void;
  107202. /**
  107203. * Gets if the scene is already disposed
  107204. */
  107205. get isDisposed(): boolean;
  107206. /**
  107207. * Call this function to reduce memory footprint of the scene.
  107208. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107209. */
  107210. clearCachedVertexData(): void;
  107211. /**
  107212. * This function will remove the local cached buffer data from texture.
  107213. * It will save memory but will prevent the texture from being rebuilt
  107214. */
  107215. cleanCachedTextureBuffer(): void;
  107216. /**
  107217. * Get the world extend vectors with an optional filter
  107218. *
  107219. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107220. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107221. */
  107222. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107223. min: Vector3;
  107224. max: Vector3;
  107225. };
  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 camera defines the camera to use for the picking
  107232. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107233. * @returns a Ray
  107234. */
  107235. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107236. /**
  107237. * Creates a ray that can be used to pick in the scene
  107238. * @param x defines the x coordinate of the origin (on-screen)
  107239. * @param y defines the y coordinate of the origin (on-screen)
  107240. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107241. * @param result defines the ray where to store the picking ray
  107242. * @param camera defines the camera to use for the picking
  107243. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107244. * @returns the current scene
  107245. */
  107246. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107247. /**
  107248. * Creates a ray that can be used to pick in the scene
  107249. * @param x defines the x coordinate of the origin (on-screen)
  107250. * @param y defines the y coordinate of the origin (on-screen)
  107251. * @param camera defines the camera to use for the picking
  107252. * @returns a Ray
  107253. */
  107254. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107255. /**
  107256. * Creates a ray that can be used to pick in the scene
  107257. * @param x defines the x coordinate of the origin (on-screen)
  107258. * @param y defines the y coordinate of the origin (on-screen)
  107259. * @param result defines the ray where to store the picking ray
  107260. * @param camera defines the camera to use for the picking
  107261. * @returns the current scene
  107262. */
  107263. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107264. /** Launch a ray to try to pick a mesh in the scene
  107265. * @param x position on screen
  107266. * @param y position on screen
  107267. * @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
  107268. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107269. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107270. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107271. * @returns a PickingInfo
  107272. */
  107273. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107274. /** Use the given ray to pick a mesh in the scene
  107275. * @param ray The ray to use to pick meshes
  107276. * @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
  107277. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107279. * @returns a PickingInfo
  107280. */
  107281. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107282. /**
  107283. * Launch a ray to try to pick a mesh in the scene
  107284. * @param x X position on screen
  107285. * @param y Y position on screen
  107286. * @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
  107287. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107288. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107289. * @returns an array of PickingInfo
  107290. */
  107291. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107292. /**
  107293. * Launch a ray to try to pick a mesh in the scene
  107294. * @param ray Ray to use
  107295. * @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
  107296. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107297. * @returns an array of PickingInfo
  107298. */
  107299. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107300. /**
  107301. * Force the value of meshUnderPointer
  107302. * @param mesh defines the mesh to use
  107303. */
  107304. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107305. /**
  107306. * Gets the mesh under the pointer
  107307. * @returns a Mesh or null if no mesh is under the pointer
  107308. */
  107309. getPointerOverMesh(): Nullable<AbstractMesh>;
  107310. /** @hidden */
  107311. _rebuildGeometries(): void;
  107312. /** @hidden */
  107313. _rebuildTextures(): void;
  107314. private _getByTags;
  107315. /**
  107316. * Get a list of meshes by tags
  107317. * @param tagsQuery defines the tags query to use
  107318. * @param forEach defines a predicate used to filter results
  107319. * @returns an array of Mesh
  107320. */
  107321. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107322. /**
  107323. * Get a list of cameras by tags
  107324. * @param tagsQuery defines the tags query to use
  107325. * @param forEach defines a predicate used to filter results
  107326. * @returns an array of Camera
  107327. */
  107328. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107329. /**
  107330. * Get a list of lights by tags
  107331. * @param tagsQuery defines the tags query to use
  107332. * @param forEach defines a predicate used to filter results
  107333. * @returns an array of Light
  107334. */
  107335. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107336. /**
  107337. * Get a list of materials by tags
  107338. * @param tagsQuery defines the tags query to use
  107339. * @param forEach defines a predicate used to filter results
  107340. * @returns an array of Material
  107341. */
  107342. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107343. /**
  107344. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107345. * This allowed control for front to back rendering or reversly depending of the special needs.
  107346. *
  107347. * @param renderingGroupId The rendering group id corresponding to its index
  107348. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107349. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107350. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107351. */
  107352. 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;
  107353. /**
  107354. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107355. *
  107356. * @param renderingGroupId The rendering group id corresponding to its index
  107357. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107358. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107359. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107360. */
  107361. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107362. /**
  107363. * Gets the current auto clear configuration for one rendering group of the rendering
  107364. * manager.
  107365. * @param index the rendering group index to get the information for
  107366. * @returns The auto clear setup for the requested rendering group
  107367. */
  107368. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107369. private _blockMaterialDirtyMechanism;
  107370. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107371. get blockMaterialDirtyMechanism(): boolean;
  107372. set blockMaterialDirtyMechanism(value: boolean);
  107373. /**
  107374. * Will flag all materials as dirty to trigger new shader compilation
  107375. * @param flag defines the flag used to specify which material part must be marked as dirty
  107376. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107377. */
  107378. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107379. /** @hidden */
  107380. _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;
  107381. /** @hidden */
  107382. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107383. /** @hidden */
  107384. _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;
  107385. /** @hidden */
  107386. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107387. /** @hidden */
  107388. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107389. /** @hidden */
  107390. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107391. }
  107392. }
  107393. declare module BABYLON {
  107394. /**
  107395. * Set of assets to keep when moving a scene into an asset container.
  107396. */
  107397. export class KeepAssets extends AbstractScene {
  107398. }
  107399. /**
  107400. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107401. */
  107402. export class InstantiatedEntries {
  107403. /**
  107404. * List of new root nodes (eg. nodes with no parent)
  107405. */
  107406. rootNodes: TransformNode[];
  107407. /**
  107408. * List of new skeletons
  107409. */
  107410. skeletons: Skeleton[];
  107411. /**
  107412. * List of new animation groups
  107413. */
  107414. animationGroups: AnimationGroup[];
  107415. }
  107416. /**
  107417. * Container with a set of assets that can be added or removed from a scene.
  107418. */
  107419. export class AssetContainer extends AbstractScene {
  107420. /**
  107421. * The scene the AssetContainer belongs to.
  107422. */
  107423. scene: Scene;
  107424. /**
  107425. * Instantiates an AssetContainer.
  107426. * @param scene The scene the AssetContainer belongs to.
  107427. */
  107428. constructor(scene: Scene);
  107429. /**
  107430. * Instantiate or clone all meshes and add the new ones to the scene.
  107431. * Skeletons and animation groups will all be cloned
  107432. * @param nameFunction defines an optional function used to get new names for clones
  107433. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107434. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107435. */
  107436. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107437. /**
  107438. * Adds all the assets from the container to the scene.
  107439. */
  107440. addAllToScene(): void;
  107441. /**
  107442. * Removes all the assets in the container from the scene
  107443. */
  107444. removeAllFromScene(): void;
  107445. /**
  107446. * Disposes all the assets in the container
  107447. */
  107448. dispose(): void;
  107449. private _moveAssets;
  107450. /**
  107451. * Removes all the assets contained in the scene and adds them to the container.
  107452. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107453. */
  107454. moveAllFromScene(keepAssets?: KeepAssets): void;
  107455. /**
  107456. * 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.
  107457. * @returns the root mesh
  107458. */
  107459. createRootMesh(): Mesh;
  107460. /**
  107461. * Merge animations from this asset container into a scene
  107462. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107463. * @param animatables set of animatables to retarget to a node from the scene
  107464. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107465. */
  107466. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107467. }
  107468. }
  107469. declare module BABYLON {
  107470. /**
  107471. * Defines how the parser contract is defined.
  107472. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107473. */
  107474. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107475. /**
  107476. * Defines how the individual parser contract is defined.
  107477. * These parser can parse an individual asset
  107478. */
  107479. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107480. /**
  107481. * Base class of the scene acting as a container for the different elements composing a scene.
  107482. * This class is dynamically extended by the different components of the scene increasing
  107483. * flexibility and reducing coupling
  107484. */
  107485. export abstract class AbstractScene {
  107486. /**
  107487. * Stores the list of available parsers in the application.
  107488. */
  107489. private static _BabylonFileParsers;
  107490. /**
  107491. * Stores the list of available individual parsers in the application.
  107492. */
  107493. private static _IndividualBabylonFileParsers;
  107494. /**
  107495. * Adds a parser in the list of available ones
  107496. * @param name Defines the name of the parser
  107497. * @param parser Defines the parser to add
  107498. */
  107499. static AddParser(name: string, parser: BabylonFileParser): void;
  107500. /**
  107501. * Gets a general parser from the list of avaialble ones
  107502. * @param name Defines the name of the parser
  107503. * @returns the requested parser or null
  107504. */
  107505. static GetParser(name: string): Nullable<BabylonFileParser>;
  107506. /**
  107507. * Adds n individual parser in the list of available ones
  107508. * @param name Defines the name of the parser
  107509. * @param parser Defines the parser to add
  107510. */
  107511. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107512. /**
  107513. * Gets an individual parser from the list of avaialble ones
  107514. * @param name Defines the name of the parser
  107515. * @returns the requested parser or null
  107516. */
  107517. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107518. /**
  107519. * Parser json data and populate both a scene and its associated container object
  107520. * @param jsonData Defines the data to parse
  107521. * @param scene Defines the scene to parse the data for
  107522. * @param container Defines the container attached to the parsing sequence
  107523. * @param rootUrl Defines the root url of the data
  107524. */
  107525. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107526. /**
  107527. * Gets the list of root nodes (ie. nodes with no parent)
  107528. */
  107529. rootNodes: Node[];
  107530. /** All of the cameras added to this scene
  107531. * @see http://doc.babylonjs.com/babylon101/cameras
  107532. */
  107533. cameras: Camera[];
  107534. /**
  107535. * All of the lights added to this scene
  107536. * @see http://doc.babylonjs.com/babylon101/lights
  107537. */
  107538. lights: Light[];
  107539. /**
  107540. * All of the (abstract) meshes added to this scene
  107541. */
  107542. meshes: AbstractMesh[];
  107543. /**
  107544. * The list of skeletons added to the scene
  107545. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107546. */
  107547. skeletons: Skeleton[];
  107548. /**
  107549. * All of the particle systems added to this scene
  107550. * @see http://doc.babylonjs.com/babylon101/particles
  107551. */
  107552. particleSystems: IParticleSystem[];
  107553. /**
  107554. * Gets a list of Animations associated with the scene
  107555. */
  107556. animations: Animation[];
  107557. /**
  107558. * All of the animation groups added to this scene
  107559. * @see http://doc.babylonjs.com/how_to/group
  107560. */
  107561. animationGroups: AnimationGroup[];
  107562. /**
  107563. * All of the multi-materials added to this scene
  107564. * @see http://doc.babylonjs.com/how_to/multi_materials
  107565. */
  107566. multiMaterials: MultiMaterial[];
  107567. /**
  107568. * All of the materials added to this scene
  107569. * In the context of a Scene, it is not supposed to be modified manually.
  107570. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107571. * Note also that the order of the Material within the array is not significant and might change.
  107572. * @see http://doc.babylonjs.com/babylon101/materials
  107573. */
  107574. materials: Material[];
  107575. /**
  107576. * The list of morph target managers added to the scene
  107577. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107578. */
  107579. morphTargetManagers: MorphTargetManager[];
  107580. /**
  107581. * The list of geometries used in the scene.
  107582. */
  107583. geometries: Geometry[];
  107584. /**
  107585. * All of the tranform nodes added to this scene
  107586. * In the context of a Scene, it is not supposed to be modified manually.
  107587. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107588. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107589. * @see http://doc.babylonjs.com/how_to/transformnode
  107590. */
  107591. transformNodes: TransformNode[];
  107592. /**
  107593. * ActionManagers available on the scene.
  107594. */
  107595. actionManagers: AbstractActionManager[];
  107596. /**
  107597. * Textures to keep.
  107598. */
  107599. textures: BaseTexture[];
  107600. /**
  107601. * Environment texture for the scene
  107602. */
  107603. environmentTexture: Nullable<BaseTexture>;
  107604. /**
  107605. * @returns all meshes, lights, cameras, transformNodes and bones
  107606. */
  107607. getNodes(): Array<Node>;
  107608. }
  107609. }
  107610. declare module BABYLON {
  107611. /**
  107612. * Interface used to define options for Sound class
  107613. */
  107614. export interface ISoundOptions {
  107615. /**
  107616. * Does the sound autoplay once loaded.
  107617. */
  107618. autoplay?: boolean;
  107619. /**
  107620. * Does the sound loop after it finishes playing once.
  107621. */
  107622. loop?: boolean;
  107623. /**
  107624. * Sound's volume
  107625. */
  107626. volume?: number;
  107627. /**
  107628. * Is it a spatial sound?
  107629. */
  107630. spatialSound?: boolean;
  107631. /**
  107632. * Maximum distance to hear that sound
  107633. */
  107634. maxDistance?: number;
  107635. /**
  107636. * Uses user defined attenuation function
  107637. */
  107638. useCustomAttenuation?: boolean;
  107639. /**
  107640. * Define the roll off factor of spatial sounds.
  107641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107642. */
  107643. rolloffFactor?: number;
  107644. /**
  107645. * Define the reference distance the sound should be heard perfectly.
  107646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107647. */
  107648. refDistance?: number;
  107649. /**
  107650. * Define the distance attenuation model the sound will follow.
  107651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107652. */
  107653. distanceModel?: string;
  107654. /**
  107655. * Defines the playback speed (1 by default)
  107656. */
  107657. playbackRate?: number;
  107658. /**
  107659. * Defines if the sound is from a streaming source
  107660. */
  107661. streaming?: boolean;
  107662. /**
  107663. * Defines an optional length (in seconds) inside the sound file
  107664. */
  107665. length?: number;
  107666. /**
  107667. * Defines an optional offset (in seconds) inside the sound file
  107668. */
  107669. offset?: number;
  107670. /**
  107671. * If true, URLs will not be required to state the audio file codec to use.
  107672. */
  107673. skipCodecCheck?: boolean;
  107674. }
  107675. /**
  107676. * Defines a sound that can be played in the application.
  107677. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107679. */
  107680. export class Sound {
  107681. /**
  107682. * The name of the sound in the scene.
  107683. */
  107684. name: string;
  107685. /**
  107686. * Does the sound autoplay once loaded.
  107687. */
  107688. autoplay: boolean;
  107689. /**
  107690. * Does the sound loop after it finishes playing once.
  107691. */
  107692. loop: boolean;
  107693. /**
  107694. * Does the sound use a custom attenuation curve to simulate the falloff
  107695. * happening when the source gets further away from the camera.
  107696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107697. */
  107698. useCustomAttenuation: boolean;
  107699. /**
  107700. * The sound track id this sound belongs to.
  107701. */
  107702. soundTrackId: number;
  107703. /**
  107704. * Is this sound currently played.
  107705. */
  107706. isPlaying: boolean;
  107707. /**
  107708. * Is this sound currently paused.
  107709. */
  107710. isPaused: boolean;
  107711. /**
  107712. * Does this sound enables spatial sound.
  107713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107714. */
  107715. spatialSound: boolean;
  107716. /**
  107717. * Define the reference distance the sound should be heard perfectly.
  107718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107719. */
  107720. refDistance: number;
  107721. /**
  107722. * Define the roll off factor of spatial sounds.
  107723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107724. */
  107725. rolloffFactor: number;
  107726. /**
  107727. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107729. */
  107730. maxDistance: number;
  107731. /**
  107732. * Define the distance attenuation model the sound will follow.
  107733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107734. */
  107735. distanceModel: string;
  107736. /**
  107737. * @hidden
  107738. * Back Compat
  107739. **/
  107740. onended: () => any;
  107741. /**
  107742. * Observable event when the current playing sound finishes.
  107743. */
  107744. onEndedObservable: Observable<Sound>;
  107745. private _panningModel;
  107746. private _playbackRate;
  107747. private _streaming;
  107748. private _startTime;
  107749. private _startOffset;
  107750. private _position;
  107751. /** @hidden */
  107752. _positionInEmitterSpace: boolean;
  107753. private _localDirection;
  107754. private _volume;
  107755. private _isReadyToPlay;
  107756. private _isDirectional;
  107757. private _readyToPlayCallback;
  107758. private _audioBuffer;
  107759. private _soundSource;
  107760. private _streamingSource;
  107761. private _soundPanner;
  107762. private _soundGain;
  107763. private _inputAudioNode;
  107764. private _outputAudioNode;
  107765. private _coneInnerAngle;
  107766. private _coneOuterAngle;
  107767. private _coneOuterGain;
  107768. private _scene;
  107769. private _connectedTransformNode;
  107770. private _customAttenuationFunction;
  107771. private _registerFunc;
  107772. private _isOutputConnected;
  107773. private _htmlAudioElement;
  107774. private _urlType;
  107775. private _length?;
  107776. private _offset?;
  107777. /** @hidden */
  107778. static _SceneComponentInitialization: (scene: Scene) => void;
  107779. /**
  107780. * Create a sound and attach it to a scene
  107781. * @param name Name of your sound
  107782. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107783. * @param scene defines the scene the sound belongs to
  107784. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107785. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107786. */
  107787. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107788. /**
  107789. * Release the sound and its associated resources
  107790. */
  107791. dispose(): void;
  107792. /**
  107793. * Gets if the sounds is ready to be played or not.
  107794. * @returns true if ready, otherwise false
  107795. */
  107796. isReady(): boolean;
  107797. private _soundLoaded;
  107798. /**
  107799. * Sets the data of the sound from an audiobuffer
  107800. * @param audioBuffer The audioBuffer containing the data
  107801. */
  107802. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107803. /**
  107804. * Updates the current sounds options such as maxdistance, loop...
  107805. * @param options A JSON object containing values named as the object properties
  107806. */
  107807. updateOptions(options: ISoundOptions): void;
  107808. private _createSpatialParameters;
  107809. private _updateSpatialParameters;
  107810. /**
  107811. * Switch the panning model to HRTF:
  107812. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107814. */
  107815. switchPanningModelToHRTF(): void;
  107816. /**
  107817. * Switch the panning model to Equal Power:
  107818. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107820. */
  107821. switchPanningModelToEqualPower(): void;
  107822. private _switchPanningModel;
  107823. /**
  107824. * Connect this sound to a sound track audio node like gain...
  107825. * @param soundTrackAudioNode the sound track audio node to connect to
  107826. */
  107827. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107828. /**
  107829. * Transform this sound into a directional source
  107830. * @param coneInnerAngle Size of the inner cone in degree
  107831. * @param coneOuterAngle Size of the outer cone in degree
  107832. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107833. */
  107834. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107835. /**
  107836. * Gets or sets the inner angle for the directional cone.
  107837. */
  107838. get directionalConeInnerAngle(): number;
  107839. /**
  107840. * Gets or sets the inner angle for the directional cone.
  107841. */
  107842. set directionalConeInnerAngle(value: number);
  107843. /**
  107844. * Gets or sets the outer angle for the directional cone.
  107845. */
  107846. get directionalConeOuterAngle(): number;
  107847. /**
  107848. * Gets or sets the outer angle for the directional cone.
  107849. */
  107850. set directionalConeOuterAngle(value: number);
  107851. /**
  107852. * Sets the position of the emitter if spatial sound is enabled
  107853. * @param newPosition Defines the new posisiton
  107854. */
  107855. setPosition(newPosition: Vector3): void;
  107856. /**
  107857. * Sets the local direction of the emitter if spatial sound is enabled
  107858. * @param newLocalDirection Defines the new local direction
  107859. */
  107860. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107861. private _updateDirection;
  107862. /** @hidden */
  107863. updateDistanceFromListener(): void;
  107864. /**
  107865. * Sets a new custom attenuation function for the sound.
  107866. * @param callback Defines the function used for the attenuation
  107867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107868. */
  107869. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107870. /**
  107871. * Play the sound
  107872. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107873. * @param offset (optional) Start the sound at a specific time in seconds
  107874. * @param length (optional) Sound duration (in seconds)
  107875. */
  107876. play(time?: number, offset?: number, length?: number): void;
  107877. private _onended;
  107878. /**
  107879. * Stop the sound
  107880. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107881. */
  107882. stop(time?: number): void;
  107883. /**
  107884. * Put the sound in pause
  107885. */
  107886. pause(): void;
  107887. /**
  107888. * Sets a dedicated volume for this sounds
  107889. * @param newVolume Define the new volume of the sound
  107890. * @param time Define time for gradual change to new volume
  107891. */
  107892. setVolume(newVolume: number, time?: number): void;
  107893. /**
  107894. * Set the sound play back rate
  107895. * @param newPlaybackRate Define the playback rate the sound should be played at
  107896. */
  107897. setPlaybackRate(newPlaybackRate: number): void;
  107898. /**
  107899. * Gets the volume of the sound.
  107900. * @returns the volume of the sound
  107901. */
  107902. getVolume(): number;
  107903. /**
  107904. * Attach the sound to a dedicated mesh
  107905. * @param transformNode The transform node to connect the sound with
  107906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107907. */
  107908. attachToMesh(transformNode: TransformNode): void;
  107909. /**
  107910. * Detach the sound from the previously attached mesh
  107911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107912. */
  107913. detachFromMesh(): void;
  107914. private _onRegisterAfterWorldMatrixUpdate;
  107915. /**
  107916. * Clone the current sound in the scene.
  107917. * @returns the new sound clone
  107918. */
  107919. clone(): Nullable<Sound>;
  107920. /**
  107921. * Gets the current underlying audio buffer containing the data
  107922. * @returns the audio buffer
  107923. */
  107924. getAudioBuffer(): Nullable<AudioBuffer>;
  107925. /**
  107926. * Serializes the Sound in a JSON representation
  107927. * @returns the JSON representation of the sound
  107928. */
  107929. serialize(): any;
  107930. /**
  107931. * Parse a JSON representation of a sound to innstantiate in a given scene
  107932. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107933. * @param scene Define the scene the new parsed sound should be created in
  107934. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107935. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107936. * @returns the newly parsed sound
  107937. */
  107938. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107939. }
  107940. }
  107941. declare module BABYLON {
  107942. /**
  107943. * This defines an action helpful to play a defined sound on a triggered action.
  107944. */
  107945. export class PlaySoundAction extends Action {
  107946. private _sound;
  107947. /**
  107948. * Instantiate the action
  107949. * @param triggerOptions defines the trigger options
  107950. * @param sound defines the sound to play
  107951. * @param condition defines the trigger related conditions
  107952. */
  107953. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107954. /** @hidden */
  107955. _prepare(): void;
  107956. /**
  107957. * Execute the action and play the sound.
  107958. */
  107959. execute(): void;
  107960. /**
  107961. * Serializes the actions and its related information.
  107962. * @param parent defines the object to serialize in
  107963. * @returns the serialized object
  107964. */
  107965. serialize(parent: any): any;
  107966. }
  107967. /**
  107968. * This defines an action helpful to stop a defined sound on a triggered action.
  107969. */
  107970. export class StopSoundAction extends Action {
  107971. private _sound;
  107972. /**
  107973. * Instantiate the action
  107974. * @param triggerOptions defines the trigger options
  107975. * @param sound defines the sound to stop
  107976. * @param condition defines the trigger related conditions
  107977. */
  107978. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107979. /** @hidden */
  107980. _prepare(): void;
  107981. /**
  107982. * Execute the action and stop the sound.
  107983. */
  107984. execute(): void;
  107985. /**
  107986. * Serializes the actions and its related information.
  107987. * @param parent defines the object to serialize in
  107988. * @returns the serialized object
  107989. */
  107990. serialize(parent: any): any;
  107991. }
  107992. }
  107993. declare module BABYLON {
  107994. /**
  107995. * This defines an action responsible to change the value of a property
  107996. * by interpolating between its current value and the newly set one once triggered.
  107997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107998. */
  107999. export class InterpolateValueAction extends Action {
  108000. /**
  108001. * Defines the path of the property where the value should be interpolated
  108002. */
  108003. propertyPath: string;
  108004. /**
  108005. * Defines the target value at the end of the interpolation.
  108006. */
  108007. value: any;
  108008. /**
  108009. * Defines the time it will take for the property to interpolate to the value.
  108010. */
  108011. duration: number;
  108012. /**
  108013. * Defines if the other scene animations should be stopped when the action has been triggered
  108014. */
  108015. stopOtherAnimations?: boolean;
  108016. /**
  108017. * Defines a callback raised once the interpolation animation has been done.
  108018. */
  108019. onInterpolationDone?: () => void;
  108020. /**
  108021. * Observable triggered once the interpolation animation has been done.
  108022. */
  108023. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  108024. private _target;
  108025. private _effectiveTarget;
  108026. private _property;
  108027. /**
  108028. * Instantiate the action
  108029. * @param triggerOptions defines the trigger options
  108030. * @param target defines the object containing the value to interpolate
  108031. * @param propertyPath defines the path to the property in the target object
  108032. * @param value defines the target value at the end of the interpolation
  108033. * @param duration deines the time it will take for the property to interpolate to the value.
  108034. * @param condition defines the trigger related conditions
  108035. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  108036. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  108037. */
  108038. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  108039. /** @hidden */
  108040. _prepare(): void;
  108041. /**
  108042. * Execute the action starts the value interpolation.
  108043. */
  108044. execute(): void;
  108045. /**
  108046. * Serializes the actions and its related information.
  108047. * @param parent defines the object to serialize in
  108048. * @returns the serialized object
  108049. */
  108050. serialize(parent: any): any;
  108051. }
  108052. }
  108053. declare module BABYLON {
  108054. /**
  108055. * Options allowed during the creation of a sound track.
  108056. */
  108057. export interface ISoundTrackOptions {
  108058. /**
  108059. * The volume the sound track should take during creation
  108060. */
  108061. volume?: number;
  108062. /**
  108063. * Define if the sound track is the main sound track of the scene
  108064. */
  108065. mainTrack?: boolean;
  108066. }
  108067. /**
  108068. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108069. * It will be also used in a future release to apply effects on a specific track.
  108070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108071. */
  108072. export class SoundTrack {
  108073. /**
  108074. * The unique identifier of the sound track in the scene.
  108075. */
  108076. id: number;
  108077. /**
  108078. * The list of sounds included in the sound track.
  108079. */
  108080. soundCollection: Array<Sound>;
  108081. private _outputAudioNode;
  108082. private _scene;
  108083. private _connectedAnalyser;
  108084. private _options;
  108085. private _isInitialized;
  108086. /**
  108087. * Creates a new sound track.
  108088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108089. * @param scene Define the scene the sound track belongs to
  108090. * @param options
  108091. */
  108092. constructor(scene: Scene, options?: ISoundTrackOptions);
  108093. private _initializeSoundTrackAudioGraph;
  108094. /**
  108095. * Release the sound track and its associated resources
  108096. */
  108097. dispose(): void;
  108098. /**
  108099. * Adds a sound to this sound track
  108100. * @param sound define the cound to add
  108101. * @ignoreNaming
  108102. */
  108103. AddSound(sound: Sound): void;
  108104. /**
  108105. * Removes a sound to this sound track
  108106. * @param sound define the cound to remove
  108107. * @ignoreNaming
  108108. */
  108109. RemoveSound(sound: Sound): void;
  108110. /**
  108111. * Set a global volume for the full sound track.
  108112. * @param newVolume Define the new volume of the sound track
  108113. */
  108114. setVolume(newVolume: number): void;
  108115. /**
  108116. * Switch the panning model to HRTF:
  108117. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108119. */
  108120. switchPanningModelToHRTF(): void;
  108121. /**
  108122. * Switch the panning model to Equal Power:
  108123. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108125. */
  108126. switchPanningModelToEqualPower(): void;
  108127. /**
  108128. * Connect the sound track to an audio analyser allowing some amazing
  108129. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108131. * @param analyser The analyser to connect to the engine
  108132. */
  108133. connectToAnalyser(analyser: Analyser): void;
  108134. }
  108135. }
  108136. declare module BABYLON {
  108137. interface AbstractScene {
  108138. /**
  108139. * The list of sounds used in the scene.
  108140. */
  108141. sounds: Nullable<Array<Sound>>;
  108142. }
  108143. interface Scene {
  108144. /**
  108145. * @hidden
  108146. * Backing field
  108147. */
  108148. _mainSoundTrack: SoundTrack;
  108149. /**
  108150. * The main sound track played by the scene.
  108151. * It cotains your primary collection of sounds.
  108152. */
  108153. mainSoundTrack: SoundTrack;
  108154. /**
  108155. * The list of sound tracks added to the scene
  108156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108157. */
  108158. soundTracks: Nullable<Array<SoundTrack>>;
  108159. /**
  108160. * Gets a sound using a given name
  108161. * @param name defines the name to search for
  108162. * @return the found sound or null if not found at all.
  108163. */
  108164. getSoundByName(name: string): Nullable<Sound>;
  108165. /**
  108166. * Gets or sets if audio support is enabled
  108167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108168. */
  108169. audioEnabled: boolean;
  108170. /**
  108171. * Gets or sets if audio will be output to headphones
  108172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108173. */
  108174. headphone: boolean;
  108175. /**
  108176. * Gets or sets custom audio listener position provider
  108177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108178. */
  108179. audioListenerPositionProvider: Nullable<() => Vector3>;
  108180. /**
  108181. * Gets or sets a refresh rate when using 3D audio positioning
  108182. */
  108183. audioPositioningRefreshRate: number;
  108184. }
  108185. /**
  108186. * Defines the sound scene component responsible to manage any sounds
  108187. * in a given scene.
  108188. */
  108189. export class AudioSceneComponent implements ISceneSerializableComponent {
  108190. /**
  108191. * The component name helpfull to identify the component in the list of scene components.
  108192. */
  108193. readonly name: string;
  108194. /**
  108195. * The scene the component belongs to.
  108196. */
  108197. scene: Scene;
  108198. private _audioEnabled;
  108199. /**
  108200. * Gets whether audio is enabled or not.
  108201. * Please use related enable/disable method to switch state.
  108202. */
  108203. get audioEnabled(): boolean;
  108204. private _headphone;
  108205. /**
  108206. * Gets whether audio is outputing to headphone or not.
  108207. * Please use the according Switch methods to change output.
  108208. */
  108209. get headphone(): boolean;
  108210. /**
  108211. * Gets or sets a refresh rate when using 3D audio positioning
  108212. */
  108213. audioPositioningRefreshRate: number;
  108214. private _audioListenerPositionProvider;
  108215. /**
  108216. * Gets the current audio listener position provider
  108217. */
  108218. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108219. /**
  108220. * Sets a custom listener position for all sounds in the scene
  108221. * By default, this is the position of the first active camera
  108222. */
  108223. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108224. /**
  108225. * Creates a new instance of the component for the given scene
  108226. * @param scene Defines the scene to register the component in
  108227. */
  108228. constructor(scene: Scene);
  108229. /**
  108230. * Registers the component in a given scene
  108231. */
  108232. register(): void;
  108233. /**
  108234. * Rebuilds the elements related to this component in case of
  108235. * context lost for instance.
  108236. */
  108237. rebuild(): void;
  108238. /**
  108239. * Serializes the component data to the specified json object
  108240. * @param serializationObject The object to serialize to
  108241. */
  108242. serialize(serializationObject: any): void;
  108243. /**
  108244. * Adds all the elements from the container to the scene
  108245. * @param container the container holding the elements
  108246. */
  108247. addFromContainer(container: AbstractScene): void;
  108248. /**
  108249. * Removes all the elements in the container from the scene
  108250. * @param container contains the elements to remove
  108251. * @param dispose if the removed element should be disposed (default: false)
  108252. */
  108253. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108254. /**
  108255. * Disposes the component and the associated ressources.
  108256. */
  108257. dispose(): void;
  108258. /**
  108259. * Disables audio in the associated scene.
  108260. */
  108261. disableAudio(): void;
  108262. /**
  108263. * Enables audio in the associated scene.
  108264. */
  108265. enableAudio(): void;
  108266. /**
  108267. * Switch audio to headphone output.
  108268. */
  108269. switchAudioModeForHeadphones(): void;
  108270. /**
  108271. * Switch audio to normal speakers.
  108272. */
  108273. switchAudioModeForNormalSpeakers(): void;
  108274. private _cachedCameraDirection;
  108275. private _cachedCameraPosition;
  108276. private _lastCheck;
  108277. private _afterRender;
  108278. }
  108279. }
  108280. declare module BABYLON {
  108281. /**
  108282. * Wraps one or more Sound objects and selects one with random weight for playback.
  108283. */
  108284. export class WeightedSound {
  108285. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108286. loop: boolean;
  108287. private _coneInnerAngle;
  108288. private _coneOuterAngle;
  108289. private _volume;
  108290. /** A Sound is currently playing. */
  108291. isPlaying: boolean;
  108292. /** A Sound is currently paused. */
  108293. isPaused: boolean;
  108294. private _sounds;
  108295. private _weights;
  108296. private _currentIndex?;
  108297. /**
  108298. * Creates a new WeightedSound from the list of sounds given.
  108299. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108300. * @param sounds Array of Sounds that will be selected from.
  108301. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108302. */
  108303. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108304. /**
  108305. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108306. */
  108307. get directionalConeInnerAngle(): number;
  108308. /**
  108309. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108310. */
  108311. set directionalConeInnerAngle(value: number);
  108312. /**
  108313. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108314. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108315. */
  108316. get directionalConeOuterAngle(): number;
  108317. /**
  108318. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108319. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108320. */
  108321. set directionalConeOuterAngle(value: number);
  108322. /**
  108323. * Playback volume.
  108324. */
  108325. get volume(): number;
  108326. /**
  108327. * Playback volume.
  108328. */
  108329. set volume(value: number);
  108330. private _onended;
  108331. /**
  108332. * Suspend playback
  108333. */
  108334. pause(): void;
  108335. /**
  108336. * Stop playback
  108337. */
  108338. stop(): void;
  108339. /**
  108340. * Start playback.
  108341. * @param startOffset Position the clip head at a specific time in seconds.
  108342. */
  108343. play(startOffset?: number): void;
  108344. }
  108345. }
  108346. declare module BABYLON {
  108347. /**
  108348. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108350. */
  108351. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108352. /**
  108353. * Gets the name of the behavior.
  108354. */
  108355. get name(): string;
  108356. /**
  108357. * The easing function used by animations
  108358. */
  108359. static EasingFunction: BackEase;
  108360. /**
  108361. * The easing mode used by animations
  108362. */
  108363. static EasingMode: number;
  108364. /**
  108365. * The duration of the animation, in milliseconds
  108366. */
  108367. transitionDuration: number;
  108368. /**
  108369. * Length of the distance animated by the transition when lower radius is reached
  108370. */
  108371. lowerRadiusTransitionRange: number;
  108372. /**
  108373. * Length of the distance animated by the transition when upper radius is reached
  108374. */
  108375. upperRadiusTransitionRange: number;
  108376. private _autoTransitionRange;
  108377. /**
  108378. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108379. */
  108380. get autoTransitionRange(): boolean;
  108381. /**
  108382. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108383. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108384. */
  108385. set autoTransitionRange(value: boolean);
  108386. private _attachedCamera;
  108387. private _onAfterCheckInputsObserver;
  108388. private _onMeshTargetChangedObserver;
  108389. /**
  108390. * Initializes the behavior.
  108391. */
  108392. init(): void;
  108393. /**
  108394. * Attaches the behavior to its arc rotate camera.
  108395. * @param camera Defines the camera to attach the behavior to
  108396. */
  108397. attach(camera: ArcRotateCamera): void;
  108398. /**
  108399. * Detaches the behavior from its current arc rotate camera.
  108400. */
  108401. detach(): void;
  108402. private _radiusIsAnimating;
  108403. private _radiusBounceTransition;
  108404. private _animatables;
  108405. private _cachedWheelPrecision;
  108406. /**
  108407. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108408. * @param radiusLimit The limit to check against.
  108409. * @return Bool to indicate if at limit.
  108410. */
  108411. private _isRadiusAtLimit;
  108412. /**
  108413. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108414. * @param radiusDelta The delta by which to animate to. Can be negative.
  108415. */
  108416. private _applyBoundRadiusAnimation;
  108417. /**
  108418. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108419. */
  108420. protected _clearAnimationLocks(): void;
  108421. /**
  108422. * Stops and removes all animations that have been applied to the camera
  108423. */
  108424. stopAllAnimations(): void;
  108425. }
  108426. }
  108427. declare module BABYLON {
  108428. /**
  108429. * 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.
  108430. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108431. */
  108432. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108433. /**
  108434. * Gets the name of the behavior.
  108435. */
  108436. get name(): string;
  108437. private _mode;
  108438. private _radiusScale;
  108439. private _positionScale;
  108440. private _defaultElevation;
  108441. private _elevationReturnTime;
  108442. private _elevationReturnWaitTime;
  108443. private _zoomStopsAnimation;
  108444. private _framingTime;
  108445. /**
  108446. * The easing function used by animations
  108447. */
  108448. static EasingFunction: ExponentialEase;
  108449. /**
  108450. * The easing mode used by animations
  108451. */
  108452. static EasingMode: number;
  108453. /**
  108454. * Sets the current mode used by the behavior
  108455. */
  108456. set mode(mode: number);
  108457. /**
  108458. * Gets current mode used by the behavior.
  108459. */
  108460. get mode(): number;
  108461. /**
  108462. * Sets the scale applied to the radius (1 by default)
  108463. */
  108464. set radiusScale(radius: number);
  108465. /**
  108466. * Gets the scale applied to the radius
  108467. */
  108468. get radiusScale(): number;
  108469. /**
  108470. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108471. */
  108472. set positionScale(scale: number);
  108473. /**
  108474. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108475. */
  108476. get positionScale(): number;
  108477. /**
  108478. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108479. * behaviour is triggered, in radians.
  108480. */
  108481. set defaultElevation(elevation: number);
  108482. /**
  108483. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108484. * behaviour is triggered, in radians.
  108485. */
  108486. get defaultElevation(): number;
  108487. /**
  108488. * Sets the time (in milliseconds) taken to return to the default beta position.
  108489. * Negative value indicates camera should not return to default.
  108490. */
  108491. set elevationReturnTime(speed: number);
  108492. /**
  108493. * Gets the time (in milliseconds) taken to return to the default beta position.
  108494. * Negative value indicates camera should not return to default.
  108495. */
  108496. get elevationReturnTime(): number;
  108497. /**
  108498. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108499. */
  108500. set elevationReturnWaitTime(time: number);
  108501. /**
  108502. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108503. */
  108504. get elevationReturnWaitTime(): number;
  108505. /**
  108506. * Sets the flag that indicates if user zooming should stop animation.
  108507. */
  108508. set zoomStopsAnimation(flag: boolean);
  108509. /**
  108510. * Gets the flag that indicates if user zooming should stop animation.
  108511. */
  108512. get zoomStopsAnimation(): boolean;
  108513. /**
  108514. * Sets the transition time when framing the mesh, in milliseconds
  108515. */
  108516. set framingTime(time: number);
  108517. /**
  108518. * Gets the transition time when framing the mesh, in milliseconds
  108519. */
  108520. get framingTime(): number;
  108521. /**
  108522. * Define if the behavior should automatically change the configured
  108523. * camera limits and sensibilities.
  108524. */
  108525. autoCorrectCameraLimitsAndSensibility: boolean;
  108526. private _onPrePointerObservableObserver;
  108527. private _onAfterCheckInputsObserver;
  108528. private _onMeshTargetChangedObserver;
  108529. private _attachedCamera;
  108530. private _isPointerDown;
  108531. private _lastInteractionTime;
  108532. /**
  108533. * Initializes the behavior.
  108534. */
  108535. init(): void;
  108536. /**
  108537. * Attaches the behavior to its arc rotate camera.
  108538. * @param camera Defines the camera to attach the behavior to
  108539. */
  108540. attach(camera: ArcRotateCamera): void;
  108541. /**
  108542. * Detaches the behavior from its current arc rotate camera.
  108543. */
  108544. detach(): void;
  108545. private _animatables;
  108546. private _betaIsAnimating;
  108547. private _betaTransition;
  108548. private _radiusTransition;
  108549. private _vectorTransition;
  108550. /**
  108551. * Targets the given mesh and updates zoom level accordingly.
  108552. * @param mesh The mesh to target.
  108553. * @param radius Optional. If a cached radius position already exists, overrides default.
  108554. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108555. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108556. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108557. */
  108558. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108559. /**
  108560. * Targets the given mesh with its children and updates zoom level accordingly.
  108561. * @param mesh The mesh to target.
  108562. * @param radius Optional. If a cached radius position already exists, overrides default.
  108563. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108564. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108565. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108566. */
  108567. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108568. /**
  108569. * Targets the given meshes with their children and updates zoom level accordingly.
  108570. * @param meshes The mesh to target.
  108571. * @param radius Optional. If a cached radius position already exists, overrides default.
  108572. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108575. */
  108576. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108577. /**
  108578. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108579. * @param minimumWorld Determines the smaller position of the bounding box extend
  108580. * @param maximumWorld Determines the bigger position of the bounding box extend
  108581. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108582. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108583. */
  108584. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108585. /**
  108586. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108587. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108588. * frustum width.
  108589. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108590. * to fully enclose the mesh in the viewing frustum.
  108591. */
  108592. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108593. /**
  108594. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108595. * is automatically returned to its default position (expected to be above ground plane).
  108596. */
  108597. private _maintainCameraAboveGround;
  108598. /**
  108599. * Returns the frustum slope based on the canvas ratio and camera FOV
  108600. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108601. */
  108602. private _getFrustumSlope;
  108603. /**
  108604. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108605. */
  108606. private _clearAnimationLocks;
  108607. /**
  108608. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108609. */
  108610. private _applyUserInteraction;
  108611. /**
  108612. * Stops and removes all animations that have been applied to the camera
  108613. */
  108614. stopAllAnimations(): void;
  108615. /**
  108616. * Gets a value indicating if the user is moving the camera
  108617. */
  108618. get isUserIsMoving(): boolean;
  108619. /**
  108620. * The camera can move all the way towards the mesh.
  108621. */
  108622. static IgnoreBoundsSizeMode: number;
  108623. /**
  108624. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108625. */
  108626. static FitFrustumSidesMode: number;
  108627. }
  108628. }
  108629. declare module BABYLON {
  108630. /**
  108631. * Base class for Camera Pointer Inputs.
  108632. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108633. * for example usage.
  108634. */
  108635. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108636. /**
  108637. * Defines the camera the input is attached to.
  108638. */
  108639. abstract camera: Camera;
  108640. /**
  108641. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108642. */
  108643. protected _altKey: boolean;
  108644. protected _ctrlKey: boolean;
  108645. protected _metaKey: boolean;
  108646. protected _shiftKey: boolean;
  108647. /**
  108648. * Which mouse buttons were pressed at time of last mouse event.
  108649. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108650. */
  108651. protected _buttonsPressed: number;
  108652. /**
  108653. * Defines the buttons associated with the input to handle camera move.
  108654. */
  108655. buttons: number[];
  108656. /**
  108657. * Attach the input controls to a specific dom element to get the input from.
  108658. * @param element Defines the element the controls should be listened from
  108659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108660. */
  108661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108662. /**
  108663. * Detach the current controls from the specified dom element.
  108664. * @param element Defines the element to stop listening the inputs from
  108665. */
  108666. detachControl(element: Nullable<HTMLElement>): void;
  108667. /**
  108668. * Gets the class name of the current input.
  108669. * @returns the class name
  108670. */
  108671. getClassName(): string;
  108672. /**
  108673. * Get the friendly name associated with the input class.
  108674. * @returns the input friendly name
  108675. */
  108676. getSimpleName(): string;
  108677. /**
  108678. * Called on pointer POINTERDOUBLETAP event.
  108679. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108680. */
  108681. protected onDoubleTap(type: string): void;
  108682. /**
  108683. * Called on pointer POINTERMOVE event if only a single touch is active.
  108684. * Override this method to provide functionality.
  108685. */
  108686. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108687. /**
  108688. * Called on pointer POINTERMOVE event if multiple touches are active.
  108689. * Override this method to provide functionality.
  108690. */
  108691. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108692. /**
  108693. * Called on JS contextmenu event.
  108694. * Override this method to provide functionality.
  108695. */
  108696. protected onContextMenu(evt: PointerEvent): void;
  108697. /**
  108698. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108699. * press.
  108700. * Override this method to provide functionality.
  108701. */
  108702. protected onButtonDown(evt: PointerEvent): void;
  108703. /**
  108704. * Called each time a new POINTERUP event occurs. Ie, for each button
  108705. * release.
  108706. * Override this method to provide functionality.
  108707. */
  108708. protected onButtonUp(evt: PointerEvent): void;
  108709. /**
  108710. * Called when window becomes inactive.
  108711. * Override this method to provide functionality.
  108712. */
  108713. protected onLostFocus(): void;
  108714. private _pointerInput;
  108715. private _observer;
  108716. private _onLostFocus;
  108717. private pointA;
  108718. private pointB;
  108719. }
  108720. }
  108721. declare module BABYLON {
  108722. /**
  108723. * Manage the pointers inputs to control an arc rotate camera.
  108724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108725. */
  108726. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108727. /**
  108728. * Defines the camera the input is attached to.
  108729. */
  108730. camera: ArcRotateCamera;
  108731. /**
  108732. * Gets the class name of the current input.
  108733. * @returns the class name
  108734. */
  108735. getClassName(): string;
  108736. /**
  108737. * Defines the buttons associated with the input to handle camera move.
  108738. */
  108739. buttons: number[];
  108740. /**
  108741. * Defines the pointer angular sensibility along the X axis or how fast is
  108742. * the camera rotating.
  108743. */
  108744. angularSensibilityX: number;
  108745. /**
  108746. * Defines the pointer angular sensibility along the Y axis or how fast is
  108747. * the camera rotating.
  108748. */
  108749. angularSensibilityY: number;
  108750. /**
  108751. * Defines the pointer pinch precision or how fast is the camera zooming.
  108752. */
  108753. pinchPrecision: number;
  108754. /**
  108755. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108756. * from 0.
  108757. * It defines the percentage of current camera.radius to use as delta when
  108758. * pinch zoom is used.
  108759. */
  108760. pinchDeltaPercentage: number;
  108761. /**
  108762. * Defines the pointer panning sensibility or how fast is the camera moving.
  108763. */
  108764. panningSensibility: number;
  108765. /**
  108766. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108767. */
  108768. multiTouchPanning: boolean;
  108769. /**
  108770. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108771. * zoom (pinch) through multitouch.
  108772. */
  108773. multiTouchPanAndZoom: boolean;
  108774. /**
  108775. * Revers pinch action direction.
  108776. */
  108777. pinchInwards: boolean;
  108778. private _isPanClick;
  108779. private _twoFingerActivityCount;
  108780. private _isPinching;
  108781. /**
  108782. * Called on pointer POINTERMOVE event if only a single touch is active.
  108783. */
  108784. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108785. /**
  108786. * Called on pointer POINTERDOUBLETAP event.
  108787. */
  108788. protected onDoubleTap(type: string): void;
  108789. /**
  108790. * Called on pointer POINTERMOVE event if multiple touches are active.
  108791. */
  108792. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108793. /**
  108794. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108795. * press.
  108796. */
  108797. protected onButtonDown(evt: PointerEvent): void;
  108798. /**
  108799. * Called each time a new POINTERUP event occurs. Ie, for each button
  108800. * release.
  108801. */
  108802. protected onButtonUp(evt: PointerEvent): void;
  108803. /**
  108804. * Called when window becomes inactive.
  108805. */
  108806. protected onLostFocus(): void;
  108807. }
  108808. }
  108809. declare module BABYLON {
  108810. /**
  108811. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108813. */
  108814. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108815. /**
  108816. * Defines the camera the input is attached to.
  108817. */
  108818. camera: ArcRotateCamera;
  108819. /**
  108820. * Defines the list of key codes associated with the up action (increase alpha)
  108821. */
  108822. keysUp: number[];
  108823. /**
  108824. * Defines the list of key codes associated with the down action (decrease alpha)
  108825. */
  108826. keysDown: number[];
  108827. /**
  108828. * Defines the list of key codes associated with the left action (increase beta)
  108829. */
  108830. keysLeft: number[];
  108831. /**
  108832. * Defines the list of key codes associated with the right action (decrease beta)
  108833. */
  108834. keysRight: number[];
  108835. /**
  108836. * Defines the list of key codes associated with the reset action.
  108837. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108838. */
  108839. keysReset: number[];
  108840. /**
  108841. * Defines the panning sensibility of the inputs.
  108842. * (How fast is the camera paning)
  108843. */
  108844. panningSensibility: number;
  108845. /**
  108846. * Defines the zooming sensibility of the inputs.
  108847. * (How fast is the camera zooming)
  108848. */
  108849. zoomingSensibility: number;
  108850. /**
  108851. * Defines wether maintaining the alt key down switch the movement mode from
  108852. * orientation to zoom.
  108853. */
  108854. useAltToZoom: boolean;
  108855. /**
  108856. * Rotation speed of the camera
  108857. */
  108858. angularSpeed: number;
  108859. private _keys;
  108860. private _ctrlPressed;
  108861. private _altPressed;
  108862. private _onCanvasBlurObserver;
  108863. private _onKeyboardObserver;
  108864. private _engine;
  108865. private _scene;
  108866. /**
  108867. * Attach the input controls to a specific dom element to get the input from.
  108868. * @param element Defines the element the controls should be listened from
  108869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108870. */
  108871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108872. /**
  108873. * Detach the current controls from the specified dom element.
  108874. * @param element Defines the element to stop listening the inputs from
  108875. */
  108876. detachControl(element: Nullable<HTMLElement>): void;
  108877. /**
  108878. * Update the current camera state depending on the inputs that have been used this frame.
  108879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108880. */
  108881. checkInputs(): void;
  108882. /**
  108883. * Gets the class name of the current intput.
  108884. * @returns the class name
  108885. */
  108886. getClassName(): string;
  108887. /**
  108888. * Get the friendly name associated with the input class.
  108889. * @returns the input friendly name
  108890. */
  108891. getSimpleName(): string;
  108892. }
  108893. }
  108894. declare module BABYLON {
  108895. /**
  108896. * Manage the mouse wheel inputs to control an arc rotate camera.
  108897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108898. */
  108899. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108900. /**
  108901. * Defines the camera the input is attached to.
  108902. */
  108903. camera: ArcRotateCamera;
  108904. /**
  108905. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108906. */
  108907. wheelPrecision: number;
  108908. /**
  108909. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108910. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108911. */
  108912. wheelDeltaPercentage: number;
  108913. private _wheel;
  108914. private _observer;
  108915. private computeDeltaFromMouseWheelLegacyEvent;
  108916. /**
  108917. * Attach the input controls to a specific dom element to get the input from.
  108918. * @param element Defines the element the controls should be listened from
  108919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108920. */
  108921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108922. /**
  108923. * Detach the current controls from the specified dom element.
  108924. * @param element Defines the element to stop listening the inputs from
  108925. */
  108926. detachControl(element: Nullable<HTMLElement>): void;
  108927. /**
  108928. * Gets the class name of the current intput.
  108929. * @returns the class name
  108930. */
  108931. getClassName(): string;
  108932. /**
  108933. * Get the friendly name associated with the input class.
  108934. * @returns the input friendly name
  108935. */
  108936. getSimpleName(): string;
  108937. }
  108938. }
  108939. declare module BABYLON {
  108940. /**
  108941. * Default Inputs manager for the ArcRotateCamera.
  108942. * It groups all the default supported inputs for ease of use.
  108943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108944. */
  108945. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108946. /**
  108947. * Instantiates a new ArcRotateCameraInputsManager.
  108948. * @param camera Defines the camera the inputs belong to
  108949. */
  108950. constructor(camera: ArcRotateCamera);
  108951. /**
  108952. * Add mouse wheel input support to the input manager.
  108953. * @returns the current input manager
  108954. */
  108955. addMouseWheel(): ArcRotateCameraInputsManager;
  108956. /**
  108957. * Add pointers input support to the input manager.
  108958. * @returns the current input manager
  108959. */
  108960. addPointers(): ArcRotateCameraInputsManager;
  108961. /**
  108962. * Add keyboard input support to the input manager.
  108963. * @returns the current input manager
  108964. */
  108965. addKeyboard(): ArcRotateCameraInputsManager;
  108966. }
  108967. }
  108968. declare module BABYLON {
  108969. /**
  108970. * This represents an orbital type of camera.
  108971. *
  108972. * 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.
  108973. * 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.
  108974. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108975. */
  108976. export class ArcRotateCamera extends TargetCamera {
  108977. /**
  108978. * Defines the rotation angle of the camera along the longitudinal axis.
  108979. */
  108980. alpha: number;
  108981. /**
  108982. * Defines the rotation angle of the camera along the latitudinal axis.
  108983. */
  108984. beta: number;
  108985. /**
  108986. * Defines the radius of the camera from it s target point.
  108987. */
  108988. radius: number;
  108989. protected _target: Vector3;
  108990. protected _targetHost: Nullable<AbstractMesh>;
  108991. /**
  108992. * Defines the target point of the camera.
  108993. * The camera looks towards it form the radius distance.
  108994. */
  108995. get target(): Vector3;
  108996. set target(value: Vector3);
  108997. /**
  108998. * Define the current local position of the camera in the scene
  108999. */
  109000. get position(): Vector3;
  109001. set position(newPosition: Vector3);
  109002. protected _upVector: Vector3;
  109003. protected _upToYMatrix: Matrix;
  109004. protected _YToUpMatrix: Matrix;
  109005. /**
  109006. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  109007. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  109008. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  109009. */
  109010. set upVector(vec: Vector3);
  109011. get upVector(): Vector3;
  109012. /**
  109013. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  109014. */
  109015. setMatUp(): void;
  109016. /**
  109017. * Current inertia value on the longitudinal axis.
  109018. * The bigger this number the longer it will take for the camera to stop.
  109019. */
  109020. inertialAlphaOffset: number;
  109021. /**
  109022. * Current inertia value on the latitudinal axis.
  109023. * The bigger this number the longer it will take for the camera to stop.
  109024. */
  109025. inertialBetaOffset: number;
  109026. /**
  109027. * Current inertia value on the radius axis.
  109028. * The bigger this number the longer it will take for the camera to stop.
  109029. */
  109030. inertialRadiusOffset: number;
  109031. /**
  109032. * Minimum allowed angle on the longitudinal axis.
  109033. * This can help limiting how the Camera is able to move in the scene.
  109034. */
  109035. lowerAlphaLimit: Nullable<number>;
  109036. /**
  109037. * Maximum allowed angle on the longitudinal axis.
  109038. * This can help limiting how the Camera is able to move in the scene.
  109039. */
  109040. upperAlphaLimit: Nullable<number>;
  109041. /**
  109042. * Minimum allowed angle on the latitudinal axis.
  109043. * This can help limiting how the Camera is able to move in the scene.
  109044. */
  109045. lowerBetaLimit: number;
  109046. /**
  109047. * Maximum allowed angle on the latitudinal axis.
  109048. * This can help limiting how the Camera is able to move in the scene.
  109049. */
  109050. upperBetaLimit: number;
  109051. /**
  109052. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  109053. * This can help limiting how the Camera is able to move in the scene.
  109054. */
  109055. lowerRadiusLimit: Nullable<number>;
  109056. /**
  109057. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109058. * This can help limiting how the Camera is able to move in the scene.
  109059. */
  109060. upperRadiusLimit: Nullable<number>;
  109061. /**
  109062. * Defines the current inertia value used during panning of the camera along the X axis.
  109063. */
  109064. inertialPanningX: number;
  109065. /**
  109066. * Defines the current inertia value used during panning of the camera along the Y axis.
  109067. */
  109068. inertialPanningY: number;
  109069. /**
  109070. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109071. * Basically if your fingers moves away from more than this distance you will be considered
  109072. * in pinch mode.
  109073. */
  109074. pinchToPanMaxDistance: number;
  109075. /**
  109076. * Defines the maximum distance the camera can pan.
  109077. * This could help keeping the cammera always in your scene.
  109078. */
  109079. panningDistanceLimit: Nullable<number>;
  109080. /**
  109081. * Defines the target of the camera before paning.
  109082. */
  109083. panningOriginTarget: Vector3;
  109084. /**
  109085. * Defines the value of the inertia used during panning.
  109086. * 0 would mean stop inertia and one would mean no decelleration at all.
  109087. */
  109088. panningInertia: number;
  109089. /**
  109090. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109091. */
  109092. get angularSensibilityX(): number;
  109093. set angularSensibilityX(value: number);
  109094. /**
  109095. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109096. */
  109097. get angularSensibilityY(): number;
  109098. set angularSensibilityY(value: number);
  109099. /**
  109100. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109101. */
  109102. get pinchPrecision(): number;
  109103. set pinchPrecision(value: number);
  109104. /**
  109105. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109106. * It will be used instead of pinchDeltaPrecision if different from 0.
  109107. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109108. */
  109109. get pinchDeltaPercentage(): number;
  109110. set pinchDeltaPercentage(value: number);
  109111. /**
  109112. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109113. */
  109114. get panningSensibility(): number;
  109115. set panningSensibility(value: number);
  109116. /**
  109117. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109118. */
  109119. get keysUp(): number[];
  109120. set keysUp(value: number[]);
  109121. /**
  109122. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109123. */
  109124. get keysDown(): number[];
  109125. set keysDown(value: number[]);
  109126. /**
  109127. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109128. */
  109129. get keysLeft(): number[];
  109130. set keysLeft(value: number[]);
  109131. /**
  109132. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109133. */
  109134. get keysRight(): number[];
  109135. set keysRight(value: number[]);
  109136. /**
  109137. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109138. */
  109139. get wheelPrecision(): number;
  109140. set wheelPrecision(value: number);
  109141. /**
  109142. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109143. * It will be used instead of pinchDeltaPrecision if different from 0.
  109144. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109145. */
  109146. get wheelDeltaPercentage(): number;
  109147. set wheelDeltaPercentage(value: number);
  109148. /**
  109149. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109150. */
  109151. zoomOnFactor: number;
  109152. /**
  109153. * Defines a screen offset for the camera position.
  109154. */
  109155. targetScreenOffset: Vector2;
  109156. /**
  109157. * Allows the camera to be completely reversed.
  109158. * If false the camera can not arrive upside down.
  109159. */
  109160. allowUpsideDown: boolean;
  109161. /**
  109162. * Define if double tap/click is used to restore the previously saved state of the camera.
  109163. */
  109164. useInputToRestoreState: boolean;
  109165. /** @hidden */
  109166. _viewMatrix: Matrix;
  109167. /** @hidden */
  109168. _useCtrlForPanning: boolean;
  109169. /** @hidden */
  109170. _panningMouseButton: number;
  109171. /**
  109172. * Defines the input associated to the camera.
  109173. */
  109174. inputs: ArcRotateCameraInputsManager;
  109175. /** @hidden */
  109176. _reset: () => void;
  109177. /**
  109178. * Defines the allowed panning axis.
  109179. */
  109180. panningAxis: Vector3;
  109181. protected _localDirection: Vector3;
  109182. protected _transformedDirection: Vector3;
  109183. private _bouncingBehavior;
  109184. /**
  109185. * Gets the bouncing behavior of the camera if it has been enabled.
  109186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109187. */
  109188. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109189. /**
  109190. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109191. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109192. */
  109193. get useBouncingBehavior(): boolean;
  109194. set useBouncingBehavior(value: boolean);
  109195. private _framingBehavior;
  109196. /**
  109197. * Gets the framing behavior of the camera if it has been enabled.
  109198. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109199. */
  109200. get framingBehavior(): Nullable<FramingBehavior>;
  109201. /**
  109202. * Defines if the framing behavior of the camera is enabled on the camera.
  109203. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109204. */
  109205. get useFramingBehavior(): boolean;
  109206. set useFramingBehavior(value: boolean);
  109207. private _autoRotationBehavior;
  109208. /**
  109209. * Gets the auto rotation behavior of the camera if it has been enabled.
  109210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109211. */
  109212. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109213. /**
  109214. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109216. */
  109217. get useAutoRotationBehavior(): boolean;
  109218. set useAutoRotationBehavior(value: boolean);
  109219. /**
  109220. * Observable triggered when the mesh target has been changed on the camera.
  109221. */
  109222. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109223. /**
  109224. * Event raised when the camera is colliding with a mesh.
  109225. */
  109226. onCollide: (collidedMesh: AbstractMesh) => void;
  109227. /**
  109228. * Defines whether the camera should check collision with the objects oh the scene.
  109229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109230. */
  109231. checkCollisions: boolean;
  109232. /**
  109233. * Defines the collision radius of the camera.
  109234. * This simulates a sphere around the camera.
  109235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109236. */
  109237. collisionRadius: Vector3;
  109238. protected _collider: Collider;
  109239. protected _previousPosition: Vector3;
  109240. protected _collisionVelocity: Vector3;
  109241. protected _newPosition: Vector3;
  109242. protected _previousAlpha: number;
  109243. protected _previousBeta: number;
  109244. protected _previousRadius: number;
  109245. protected _collisionTriggered: boolean;
  109246. protected _targetBoundingCenter: Nullable<Vector3>;
  109247. private _computationVector;
  109248. /**
  109249. * Instantiates a new ArcRotateCamera in a given scene
  109250. * @param name Defines the name of the camera
  109251. * @param alpha Defines the camera rotation along the logitudinal axis
  109252. * @param beta Defines the camera rotation along the latitudinal axis
  109253. * @param radius Defines the camera distance from its target
  109254. * @param target Defines the camera target
  109255. * @param scene Defines the scene the camera belongs to
  109256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109257. */
  109258. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109259. /** @hidden */
  109260. _initCache(): void;
  109261. /** @hidden */
  109262. _updateCache(ignoreParentClass?: boolean): void;
  109263. protected _getTargetPosition(): Vector3;
  109264. private _storedAlpha;
  109265. private _storedBeta;
  109266. private _storedRadius;
  109267. private _storedTarget;
  109268. private _storedTargetScreenOffset;
  109269. /**
  109270. * Stores the current state of the camera (alpha, beta, radius and target)
  109271. * @returns the camera itself
  109272. */
  109273. storeState(): Camera;
  109274. /**
  109275. * @hidden
  109276. * Restored camera state. You must call storeState() first
  109277. */
  109278. _restoreStateValues(): boolean;
  109279. /** @hidden */
  109280. _isSynchronizedViewMatrix(): boolean;
  109281. /**
  109282. * Attached controls to the current camera.
  109283. * @param element Defines the element the controls should be listened from
  109284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109285. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109286. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109287. */
  109288. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109289. /**
  109290. * Detach the current controls from the camera.
  109291. * The camera will stop reacting to inputs.
  109292. * @param element Defines the element to stop listening the inputs from
  109293. */
  109294. detachControl(element: HTMLElement): void;
  109295. /** @hidden */
  109296. _checkInputs(): void;
  109297. protected _checkLimits(): void;
  109298. /**
  109299. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109300. */
  109301. rebuildAnglesAndRadius(): void;
  109302. /**
  109303. * Use a position to define the current camera related information like alpha, beta and radius
  109304. * @param position Defines the position to set the camera at
  109305. */
  109306. setPosition(position: Vector3): void;
  109307. /**
  109308. * Defines the target the camera should look at.
  109309. * This will automatically adapt alpha beta and radius to fit within the new target.
  109310. * @param target Defines the new target as a Vector or a mesh
  109311. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109312. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109313. */
  109314. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109315. /** @hidden */
  109316. _getViewMatrix(): Matrix;
  109317. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109318. /**
  109319. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109320. * @param meshes Defines the mesh to zoom on
  109321. * @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)
  109322. */
  109323. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109324. /**
  109325. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109326. * The target will be changed but the radius
  109327. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109328. * @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)
  109329. */
  109330. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109331. min: Vector3;
  109332. max: Vector3;
  109333. distance: number;
  109334. }, doNotUpdateMaxZ?: boolean): void;
  109335. /**
  109336. * @override
  109337. * Override Camera.createRigCamera
  109338. */
  109339. createRigCamera(name: string, cameraIndex: number): Camera;
  109340. /**
  109341. * @hidden
  109342. * @override
  109343. * Override Camera._updateRigCameras
  109344. */
  109345. _updateRigCameras(): void;
  109346. /**
  109347. * Destroy the camera and release the current resources hold by it.
  109348. */
  109349. dispose(): void;
  109350. /**
  109351. * Gets the current object class name.
  109352. * @return the class name
  109353. */
  109354. getClassName(): string;
  109355. }
  109356. }
  109357. declare module BABYLON {
  109358. /**
  109359. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109360. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109361. */
  109362. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109363. /**
  109364. * Gets the name of the behavior.
  109365. */
  109366. get name(): string;
  109367. private _zoomStopsAnimation;
  109368. private _idleRotationSpeed;
  109369. private _idleRotationWaitTime;
  109370. private _idleRotationSpinupTime;
  109371. /**
  109372. * Sets the flag that indicates if user zooming should stop animation.
  109373. */
  109374. set zoomStopsAnimation(flag: boolean);
  109375. /**
  109376. * Gets the flag that indicates if user zooming should stop animation.
  109377. */
  109378. get zoomStopsAnimation(): boolean;
  109379. /**
  109380. * Sets the default speed at which the camera rotates around the model.
  109381. */
  109382. set idleRotationSpeed(speed: number);
  109383. /**
  109384. * Gets the default speed at which the camera rotates around the model.
  109385. */
  109386. get idleRotationSpeed(): number;
  109387. /**
  109388. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109389. */
  109390. set idleRotationWaitTime(time: number);
  109391. /**
  109392. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109393. */
  109394. get idleRotationWaitTime(): number;
  109395. /**
  109396. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109397. */
  109398. set idleRotationSpinupTime(time: number);
  109399. /**
  109400. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109401. */
  109402. get idleRotationSpinupTime(): number;
  109403. /**
  109404. * Gets a value indicating if the camera is currently rotating because of this behavior
  109405. */
  109406. get rotationInProgress(): boolean;
  109407. private _onPrePointerObservableObserver;
  109408. private _onAfterCheckInputsObserver;
  109409. private _attachedCamera;
  109410. private _isPointerDown;
  109411. private _lastFrameTime;
  109412. private _lastInteractionTime;
  109413. private _cameraRotationSpeed;
  109414. /**
  109415. * Initializes the behavior.
  109416. */
  109417. init(): void;
  109418. /**
  109419. * Attaches the behavior to its arc rotate camera.
  109420. * @param camera Defines the camera to attach the behavior to
  109421. */
  109422. attach(camera: ArcRotateCamera): void;
  109423. /**
  109424. * Detaches the behavior from its current arc rotate camera.
  109425. */
  109426. detach(): void;
  109427. /**
  109428. * Returns true if user is scrolling.
  109429. * @return true if user is scrolling.
  109430. */
  109431. private _userIsZooming;
  109432. private _lastFrameRadius;
  109433. private _shouldAnimationStopForInteraction;
  109434. /**
  109435. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109436. */
  109437. private _applyUserInteraction;
  109438. private _userIsMoving;
  109439. }
  109440. }
  109441. declare module BABYLON {
  109442. /**
  109443. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109444. */
  109445. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109446. private ui;
  109447. /**
  109448. * The name of the behavior
  109449. */
  109450. name: string;
  109451. /**
  109452. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109453. */
  109454. distanceAwayFromFace: number;
  109455. /**
  109456. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109457. */
  109458. distanceAwayFromBottomOfFace: number;
  109459. private _faceVectors;
  109460. private _target;
  109461. private _scene;
  109462. private _onRenderObserver;
  109463. private _tmpMatrix;
  109464. private _tmpVector;
  109465. /**
  109466. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109467. * @param ui The transform node that should be attched to the mesh
  109468. */
  109469. constructor(ui: TransformNode);
  109470. /**
  109471. * Initializes the behavior
  109472. */
  109473. init(): void;
  109474. private _closestFace;
  109475. private _zeroVector;
  109476. private _lookAtTmpMatrix;
  109477. private _lookAtToRef;
  109478. /**
  109479. * Attaches the AttachToBoxBehavior to the passed in mesh
  109480. * @param target The mesh that the specified node will be attached to
  109481. */
  109482. attach(target: Mesh): void;
  109483. /**
  109484. * Detaches the behavior from the mesh
  109485. */
  109486. detach(): void;
  109487. }
  109488. }
  109489. declare module BABYLON {
  109490. /**
  109491. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109492. */
  109493. export class FadeInOutBehavior implements Behavior<Mesh> {
  109494. /**
  109495. * Time in milliseconds to delay before fading in (Default: 0)
  109496. */
  109497. delay: number;
  109498. /**
  109499. * Time in milliseconds for the mesh to fade in (Default: 300)
  109500. */
  109501. fadeInTime: number;
  109502. private _millisecondsPerFrame;
  109503. private _hovered;
  109504. private _hoverValue;
  109505. private _ownerNode;
  109506. /**
  109507. * Instatiates the FadeInOutBehavior
  109508. */
  109509. constructor();
  109510. /**
  109511. * The name of the behavior
  109512. */
  109513. get name(): string;
  109514. /**
  109515. * Initializes the behavior
  109516. */
  109517. init(): void;
  109518. /**
  109519. * Attaches the fade behavior on the passed in mesh
  109520. * @param ownerNode The mesh that will be faded in/out once attached
  109521. */
  109522. attach(ownerNode: Mesh): void;
  109523. /**
  109524. * Detaches the behavior from the mesh
  109525. */
  109526. detach(): void;
  109527. /**
  109528. * Triggers the mesh to begin fading in or out
  109529. * @param value if the object should fade in or out (true to fade in)
  109530. */
  109531. fadeIn(value: boolean): void;
  109532. private _update;
  109533. private _setAllVisibility;
  109534. }
  109535. }
  109536. declare module BABYLON {
  109537. /**
  109538. * Class containing a set of static utilities functions for managing Pivots
  109539. * @hidden
  109540. */
  109541. export class PivotTools {
  109542. private static _PivotCached;
  109543. private static _OldPivotPoint;
  109544. private static _PivotTranslation;
  109545. private static _PivotTmpVector;
  109546. /** @hidden */
  109547. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109548. /** @hidden */
  109549. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109550. }
  109551. }
  109552. declare module BABYLON {
  109553. /**
  109554. * Class containing static functions to help procedurally build meshes
  109555. */
  109556. export class PlaneBuilder {
  109557. /**
  109558. * Creates a plane mesh
  109559. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109560. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109561. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109565. * @param name defines the name of the mesh
  109566. * @param options defines the options used to create the mesh
  109567. * @param scene defines the hosting scene
  109568. * @returns the plane mesh
  109569. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109570. */
  109571. static CreatePlane(name: string, options: {
  109572. size?: number;
  109573. width?: number;
  109574. height?: number;
  109575. sideOrientation?: number;
  109576. frontUVs?: Vector4;
  109577. backUVs?: Vector4;
  109578. updatable?: boolean;
  109579. sourcePlane?: Plane;
  109580. }, scene?: Nullable<Scene>): Mesh;
  109581. }
  109582. }
  109583. declare module BABYLON {
  109584. /**
  109585. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109586. */
  109587. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109588. private static _AnyMouseID;
  109589. /**
  109590. * Abstract mesh the behavior is set on
  109591. */
  109592. attachedNode: AbstractMesh;
  109593. private _dragPlane;
  109594. private _scene;
  109595. private _pointerObserver;
  109596. private _beforeRenderObserver;
  109597. private static _planeScene;
  109598. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109599. /**
  109600. * 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)
  109601. */
  109602. maxDragAngle: number;
  109603. /**
  109604. * @hidden
  109605. */
  109606. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109607. /**
  109608. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109609. */
  109610. currentDraggingPointerID: number;
  109611. /**
  109612. * The last position where the pointer hit the drag plane in world space
  109613. */
  109614. lastDragPosition: Vector3;
  109615. /**
  109616. * If the behavior is currently in a dragging state
  109617. */
  109618. dragging: boolean;
  109619. /**
  109620. * 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)
  109621. */
  109622. dragDeltaRatio: number;
  109623. /**
  109624. * If the drag plane orientation should be updated during the dragging (Default: true)
  109625. */
  109626. updateDragPlane: boolean;
  109627. private _debugMode;
  109628. private _moving;
  109629. /**
  109630. * Fires each time the attached mesh is dragged with the pointer
  109631. * * delta between last drag position and current drag position in world space
  109632. * * dragDistance along the drag axis
  109633. * * dragPlaneNormal normal of the current drag plane used during the drag
  109634. * * dragPlanePoint in world space where the drag intersects the drag plane
  109635. */
  109636. onDragObservable: Observable<{
  109637. delta: Vector3;
  109638. dragPlanePoint: Vector3;
  109639. dragPlaneNormal: Vector3;
  109640. dragDistance: number;
  109641. pointerId: number;
  109642. }>;
  109643. /**
  109644. * Fires each time a drag begins (eg. mouse down on mesh)
  109645. */
  109646. onDragStartObservable: Observable<{
  109647. dragPlanePoint: Vector3;
  109648. pointerId: number;
  109649. }>;
  109650. /**
  109651. * Fires each time a drag ends (eg. mouse release after drag)
  109652. */
  109653. onDragEndObservable: Observable<{
  109654. dragPlanePoint: Vector3;
  109655. pointerId: number;
  109656. }>;
  109657. /**
  109658. * If the attached mesh should be moved when dragged
  109659. */
  109660. moveAttached: boolean;
  109661. /**
  109662. * If the drag behavior will react to drag events (Default: true)
  109663. */
  109664. enabled: boolean;
  109665. /**
  109666. * If pointer events should start and release the drag (Default: true)
  109667. */
  109668. startAndReleaseDragOnPointerEvents: boolean;
  109669. /**
  109670. * If camera controls should be detached during the drag
  109671. */
  109672. detachCameraControls: boolean;
  109673. /**
  109674. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109675. */
  109676. useObjectOrientationForDragging: boolean;
  109677. private _options;
  109678. /**
  109679. * Gets the options used by the behavior
  109680. */
  109681. get options(): {
  109682. dragAxis?: Vector3;
  109683. dragPlaneNormal?: Vector3;
  109684. };
  109685. /**
  109686. * Sets the options used by the behavior
  109687. */
  109688. set options(options: {
  109689. dragAxis?: Vector3;
  109690. dragPlaneNormal?: Vector3;
  109691. });
  109692. /**
  109693. * Creates a pointer drag behavior that can be attached to a mesh
  109694. * @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)
  109695. */
  109696. constructor(options?: {
  109697. dragAxis?: Vector3;
  109698. dragPlaneNormal?: Vector3;
  109699. });
  109700. /**
  109701. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109702. */
  109703. validateDrag: (targetPosition: Vector3) => boolean;
  109704. /**
  109705. * The name of the behavior
  109706. */
  109707. get name(): string;
  109708. /**
  109709. * Initializes the behavior
  109710. */
  109711. init(): void;
  109712. private _tmpVector;
  109713. private _alternatePickedPoint;
  109714. private _worldDragAxis;
  109715. private _targetPosition;
  109716. private _attachedElement;
  109717. /**
  109718. * Attaches the drag behavior the passed in mesh
  109719. * @param ownerNode The mesh that will be dragged around once attached
  109720. * @param predicate Predicate to use for pick filtering
  109721. */
  109722. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109723. /**
  109724. * Force relase the drag action by code.
  109725. */
  109726. releaseDrag(): void;
  109727. private _startDragRay;
  109728. private _lastPointerRay;
  109729. /**
  109730. * Simulates the start of a pointer drag event on the behavior
  109731. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109732. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109733. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109734. */
  109735. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109736. private _startDrag;
  109737. private _dragDelta;
  109738. private _moveDrag;
  109739. private _pickWithRayOnDragPlane;
  109740. private _pointA;
  109741. private _pointB;
  109742. private _pointC;
  109743. private _lineA;
  109744. private _lineB;
  109745. private _localAxis;
  109746. private _lookAt;
  109747. private _updateDragPlanePosition;
  109748. /**
  109749. * Detaches the behavior from the mesh
  109750. */
  109751. detach(): void;
  109752. }
  109753. }
  109754. declare module BABYLON {
  109755. /**
  109756. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109757. */
  109758. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109759. private _dragBehaviorA;
  109760. private _dragBehaviorB;
  109761. private _startDistance;
  109762. private _initialScale;
  109763. private _targetScale;
  109764. private _ownerNode;
  109765. private _sceneRenderObserver;
  109766. /**
  109767. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109768. */
  109769. constructor();
  109770. /**
  109771. * The name of the behavior
  109772. */
  109773. get name(): string;
  109774. /**
  109775. * Initializes the behavior
  109776. */
  109777. init(): void;
  109778. private _getCurrentDistance;
  109779. /**
  109780. * Attaches the scale behavior the passed in mesh
  109781. * @param ownerNode The mesh that will be scaled around once attached
  109782. */
  109783. attach(ownerNode: Mesh): void;
  109784. /**
  109785. * Detaches the behavior from the mesh
  109786. */
  109787. detach(): void;
  109788. }
  109789. }
  109790. declare module BABYLON {
  109791. /**
  109792. * 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
  109793. */
  109794. export class SixDofDragBehavior implements Behavior<Mesh> {
  109795. private static _virtualScene;
  109796. private _ownerNode;
  109797. private _sceneRenderObserver;
  109798. private _scene;
  109799. private _targetPosition;
  109800. private _virtualOriginMesh;
  109801. private _virtualDragMesh;
  109802. private _pointerObserver;
  109803. private _moving;
  109804. private _startingOrientation;
  109805. /**
  109806. * 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)
  109807. */
  109808. private zDragFactor;
  109809. /**
  109810. * If the object should rotate to face the drag origin
  109811. */
  109812. rotateDraggedObject: boolean;
  109813. /**
  109814. * If the behavior is currently in a dragging state
  109815. */
  109816. dragging: boolean;
  109817. /**
  109818. * 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)
  109819. */
  109820. dragDeltaRatio: number;
  109821. /**
  109822. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109823. */
  109824. currentDraggingPointerID: number;
  109825. /**
  109826. * If camera controls should be detached during the drag
  109827. */
  109828. detachCameraControls: boolean;
  109829. /**
  109830. * Fires each time a drag starts
  109831. */
  109832. onDragStartObservable: Observable<{}>;
  109833. /**
  109834. * Fires each time a drag ends (eg. mouse release after drag)
  109835. */
  109836. onDragEndObservable: Observable<{}>;
  109837. /**
  109838. * 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
  109839. */
  109840. constructor();
  109841. /**
  109842. * The name of the behavior
  109843. */
  109844. get name(): string;
  109845. /**
  109846. * Initializes the behavior
  109847. */
  109848. init(): void;
  109849. /**
  109850. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109851. */
  109852. private get _pointerCamera();
  109853. /**
  109854. * Attaches the scale behavior the passed in mesh
  109855. * @param ownerNode The mesh that will be scaled around once attached
  109856. */
  109857. attach(ownerNode: Mesh): void;
  109858. /**
  109859. * Detaches the behavior from the mesh
  109860. */
  109861. detach(): void;
  109862. }
  109863. }
  109864. declare module BABYLON {
  109865. /**
  109866. * Class used to apply inverse kinematics to bones
  109867. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109868. */
  109869. export class BoneIKController {
  109870. private static _tmpVecs;
  109871. private static _tmpQuat;
  109872. private static _tmpMats;
  109873. /**
  109874. * Gets or sets the target mesh
  109875. */
  109876. targetMesh: AbstractMesh;
  109877. /** Gets or sets the mesh used as pole */
  109878. poleTargetMesh: AbstractMesh;
  109879. /**
  109880. * Gets or sets the bone used as pole
  109881. */
  109882. poleTargetBone: Nullable<Bone>;
  109883. /**
  109884. * Gets or sets the target position
  109885. */
  109886. targetPosition: Vector3;
  109887. /**
  109888. * Gets or sets the pole target position
  109889. */
  109890. poleTargetPosition: Vector3;
  109891. /**
  109892. * Gets or sets the pole target local offset
  109893. */
  109894. poleTargetLocalOffset: Vector3;
  109895. /**
  109896. * Gets or sets the pole angle
  109897. */
  109898. poleAngle: number;
  109899. /**
  109900. * Gets or sets the mesh associated with the controller
  109901. */
  109902. mesh: AbstractMesh;
  109903. /**
  109904. * 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)
  109905. */
  109906. slerpAmount: number;
  109907. private _bone1Quat;
  109908. private _bone1Mat;
  109909. private _bone2Ang;
  109910. private _bone1;
  109911. private _bone2;
  109912. private _bone1Length;
  109913. private _bone2Length;
  109914. private _maxAngle;
  109915. private _maxReach;
  109916. private _rightHandedSystem;
  109917. private _bendAxis;
  109918. private _slerping;
  109919. private _adjustRoll;
  109920. /**
  109921. * Gets or sets maximum allowed angle
  109922. */
  109923. get maxAngle(): number;
  109924. set maxAngle(value: number);
  109925. /**
  109926. * Creates a new BoneIKController
  109927. * @param mesh defines the mesh to control
  109928. * @param bone defines the bone to control
  109929. * @param options defines options to set up the controller
  109930. */
  109931. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109932. targetMesh?: AbstractMesh;
  109933. poleTargetMesh?: AbstractMesh;
  109934. poleTargetBone?: Bone;
  109935. poleTargetLocalOffset?: Vector3;
  109936. poleAngle?: number;
  109937. bendAxis?: Vector3;
  109938. maxAngle?: number;
  109939. slerpAmount?: number;
  109940. });
  109941. private _setMaxAngle;
  109942. /**
  109943. * Force the controller to update the bones
  109944. */
  109945. update(): void;
  109946. }
  109947. }
  109948. declare module BABYLON {
  109949. /**
  109950. * Class used to make a bone look toward a point in space
  109951. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109952. */
  109953. export class BoneLookController {
  109954. private static _tmpVecs;
  109955. private static _tmpQuat;
  109956. private static _tmpMats;
  109957. /**
  109958. * The target Vector3 that the bone will look at
  109959. */
  109960. target: Vector3;
  109961. /**
  109962. * The mesh that the bone is attached to
  109963. */
  109964. mesh: AbstractMesh;
  109965. /**
  109966. * The bone that will be looking to the target
  109967. */
  109968. bone: Bone;
  109969. /**
  109970. * The up axis of the coordinate system that is used when the bone is rotated
  109971. */
  109972. upAxis: Vector3;
  109973. /**
  109974. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109975. */
  109976. upAxisSpace: Space;
  109977. /**
  109978. * Used to make an adjustment to the yaw of the bone
  109979. */
  109980. adjustYaw: number;
  109981. /**
  109982. * Used to make an adjustment to the pitch of the bone
  109983. */
  109984. adjustPitch: number;
  109985. /**
  109986. * Used to make an adjustment to the roll of the bone
  109987. */
  109988. adjustRoll: number;
  109989. /**
  109990. * 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)
  109991. */
  109992. slerpAmount: number;
  109993. private _minYaw;
  109994. private _maxYaw;
  109995. private _minPitch;
  109996. private _maxPitch;
  109997. private _minYawSin;
  109998. private _minYawCos;
  109999. private _maxYawSin;
  110000. private _maxYawCos;
  110001. private _midYawConstraint;
  110002. private _minPitchTan;
  110003. private _maxPitchTan;
  110004. private _boneQuat;
  110005. private _slerping;
  110006. private _transformYawPitch;
  110007. private _transformYawPitchInv;
  110008. private _firstFrameSkipped;
  110009. private _yawRange;
  110010. private _fowardAxis;
  110011. /**
  110012. * Gets or sets the minimum yaw angle that the bone can look to
  110013. */
  110014. get minYaw(): number;
  110015. set minYaw(value: number);
  110016. /**
  110017. * Gets or sets the maximum yaw angle that the bone can look to
  110018. */
  110019. get maxYaw(): number;
  110020. set maxYaw(value: number);
  110021. /**
  110022. * Gets or sets the minimum pitch angle that the bone can look to
  110023. */
  110024. get minPitch(): number;
  110025. set minPitch(value: number);
  110026. /**
  110027. * Gets or sets the maximum pitch angle that the bone can look to
  110028. */
  110029. get maxPitch(): number;
  110030. set maxPitch(value: number);
  110031. /**
  110032. * Create a BoneLookController
  110033. * @param mesh the mesh that the bone belongs to
  110034. * @param bone the bone that will be looking to the target
  110035. * @param target the target Vector3 to look at
  110036. * @param options optional settings:
  110037. * * maxYaw: the maximum angle the bone will yaw to
  110038. * * minYaw: the minimum angle the bone will yaw to
  110039. * * maxPitch: the maximum angle the bone will pitch to
  110040. * * minPitch: the minimum angle the bone will yaw to
  110041. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  110042. * * upAxis: the up axis of the coordinate system
  110043. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  110044. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  110045. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  110046. * * adjustYaw: used to make an adjustment to the yaw of the bone
  110047. * * adjustPitch: used to make an adjustment to the pitch of the bone
  110048. * * adjustRoll: used to make an adjustment to the roll of the bone
  110049. **/
  110050. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  110051. maxYaw?: number;
  110052. minYaw?: number;
  110053. maxPitch?: number;
  110054. minPitch?: number;
  110055. slerpAmount?: number;
  110056. upAxis?: Vector3;
  110057. upAxisSpace?: Space;
  110058. yawAxis?: Vector3;
  110059. pitchAxis?: Vector3;
  110060. adjustYaw?: number;
  110061. adjustPitch?: number;
  110062. adjustRoll?: number;
  110063. });
  110064. /**
  110065. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110066. */
  110067. update(): void;
  110068. private _getAngleDiff;
  110069. private _getAngleBetween;
  110070. private _isAngleBetween;
  110071. }
  110072. }
  110073. declare module BABYLON {
  110074. /**
  110075. * Manage the gamepad inputs to control an arc rotate camera.
  110076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110077. */
  110078. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110079. /**
  110080. * Defines the camera the input is attached to.
  110081. */
  110082. camera: ArcRotateCamera;
  110083. /**
  110084. * Defines the gamepad the input is gathering event from.
  110085. */
  110086. gamepad: Nullable<Gamepad>;
  110087. /**
  110088. * Defines the gamepad rotation sensiblity.
  110089. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110090. */
  110091. gamepadRotationSensibility: number;
  110092. /**
  110093. * Defines the gamepad move sensiblity.
  110094. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110095. */
  110096. gamepadMoveSensibility: number;
  110097. private _yAxisScale;
  110098. /**
  110099. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110100. */
  110101. get invertYAxis(): boolean;
  110102. set invertYAxis(value: boolean);
  110103. private _onGamepadConnectedObserver;
  110104. private _onGamepadDisconnectedObserver;
  110105. /**
  110106. * Attach the input controls to a specific dom element to get the input from.
  110107. * @param element Defines the element the controls should be listened from
  110108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110109. */
  110110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110111. /**
  110112. * Detach the current controls from the specified dom element.
  110113. * @param element Defines the element to stop listening the inputs from
  110114. */
  110115. detachControl(element: Nullable<HTMLElement>): void;
  110116. /**
  110117. * Update the current camera state depending on the inputs that have been used this frame.
  110118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110119. */
  110120. checkInputs(): void;
  110121. /**
  110122. * Gets the class name of the current intput.
  110123. * @returns the class name
  110124. */
  110125. getClassName(): string;
  110126. /**
  110127. * Get the friendly name associated with the input class.
  110128. * @returns the input friendly name
  110129. */
  110130. getSimpleName(): string;
  110131. }
  110132. }
  110133. declare module BABYLON {
  110134. interface ArcRotateCameraInputsManager {
  110135. /**
  110136. * Add orientation input support to the input manager.
  110137. * @returns the current input manager
  110138. */
  110139. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110140. }
  110141. /**
  110142. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110144. */
  110145. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110146. /**
  110147. * Defines the camera the input is attached to.
  110148. */
  110149. camera: ArcRotateCamera;
  110150. /**
  110151. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110152. */
  110153. alphaCorrection: number;
  110154. /**
  110155. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110156. */
  110157. gammaCorrection: number;
  110158. private _alpha;
  110159. private _gamma;
  110160. private _dirty;
  110161. private _deviceOrientationHandler;
  110162. /**
  110163. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110164. */
  110165. constructor();
  110166. /**
  110167. * Attach the input controls to a specific dom element to get the input from.
  110168. * @param element Defines the element the controls should be listened from
  110169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110170. */
  110171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110172. /** @hidden */
  110173. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110174. /**
  110175. * Update the current camera state depending on the inputs that have been used this frame.
  110176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110177. */
  110178. checkInputs(): void;
  110179. /**
  110180. * Detach the current controls from the specified dom element.
  110181. * @param element Defines the element to stop listening the inputs from
  110182. */
  110183. detachControl(element: Nullable<HTMLElement>): void;
  110184. /**
  110185. * Gets the class name of the current intput.
  110186. * @returns the class name
  110187. */
  110188. getClassName(): string;
  110189. /**
  110190. * Get the friendly name associated with the input class.
  110191. * @returns the input friendly name
  110192. */
  110193. getSimpleName(): string;
  110194. }
  110195. }
  110196. declare module BABYLON {
  110197. /**
  110198. * Listen to mouse events to control the camera.
  110199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110200. */
  110201. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110202. /**
  110203. * Defines the camera the input is attached to.
  110204. */
  110205. camera: FlyCamera;
  110206. /**
  110207. * Defines if touch is enabled. (Default is true.)
  110208. */
  110209. touchEnabled: boolean;
  110210. /**
  110211. * Defines the buttons associated with the input to handle camera rotation.
  110212. */
  110213. buttons: number[];
  110214. /**
  110215. * Assign buttons for Yaw control.
  110216. */
  110217. buttonsYaw: number[];
  110218. /**
  110219. * Assign buttons for Pitch control.
  110220. */
  110221. buttonsPitch: number[];
  110222. /**
  110223. * Assign buttons for Roll control.
  110224. */
  110225. buttonsRoll: number[];
  110226. /**
  110227. * Detect if any button is being pressed while mouse is moved.
  110228. * -1 = Mouse locked.
  110229. * 0 = Left button.
  110230. * 1 = Middle Button.
  110231. * 2 = Right Button.
  110232. */
  110233. activeButton: number;
  110234. /**
  110235. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110236. * Higher values reduce its sensitivity.
  110237. */
  110238. angularSensibility: number;
  110239. private _mousemoveCallback;
  110240. private _observer;
  110241. private _rollObserver;
  110242. private previousPosition;
  110243. private noPreventDefault;
  110244. private element;
  110245. /**
  110246. * Listen to mouse events to control the camera.
  110247. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110249. */
  110250. constructor(touchEnabled?: boolean);
  110251. /**
  110252. * Attach the mouse control to the HTML DOM element.
  110253. * @param element Defines the element that listens to the input events.
  110254. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110255. */
  110256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110257. /**
  110258. * Detach the current controls from the specified dom element.
  110259. * @param element Defines the element to stop listening the inputs from
  110260. */
  110261. detachControl(element: Nullable<HTMLElement>): void;
  110262. /**
  110263. * Gets the class name of the current input.
  110264. * @returns the class name.
  110265. */
  110266. getClassName(): string;
  110267. /**
  110268. * Get the friendly name associated with the input class.
  110269. * @returns the input's friendly name.
  110270. */
  110271. getSimpleName(): string;
  110272. private _pointerInput;
  110273. private _onMouseMove;
  110274. /**
  110275. * Rotate camera by mouse offset.
  110276. */
  110277. private rotateCamera;
  110278. }
  110279. }
  110280. declare module BABYLON {
  110281. /**
  110282. * Default Inputs manager for the FlyCamera.
  110283. * It groups all the default supported inputs for ease of use.
  110284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110285. */
  110286. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110287. /**
  110288. * Instantiates a new FlyCameraInputsManager.
  110289. * @param camera Defines the camera the inputs belong to.
  110290. */
  110291. constructor(camera: FlyCamera);
  110292. /**
  110293. * Add keyboard input support to the input manager.
  110294. * @returns the new FlyCameraKeyboardMoveInput().
  110295. */
  110296. addKeyboard(): FlyCameraInputsManager;
  110297. /**
  110298. * Add mouse input support to the input manager.
  110299. * @param touchEnabled Enable touch screen support.
  110300. * @returns the new FlyCameraMouseInput().
  110301. */
  110302. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110303. }
  110304. }
  110305. declare module BABYLON {
  110306. /**
  110307. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110308. * such as in a 3D Space Shooter or a Flight Simulator.
  110309. */
  110310. export class FlyCamera extends TargetCamera {
  110311. /**
  110312. * Define the collision ellipsoid of the camera.
  110313. * This is helpful for simulating a camera body, like a player's body.
  110314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110315. */
  110316. ellipsoid: Vector3;
  110317. /**
  110318. * Define an offset for the position of the ellipsoid around the camera.
  110319. * This can be helpful if the camera is attached away from the player's body center,
  110320. * such as at its head.
  110321. */
  110322. ellipsoidOffset: Vector3;
  110323. /**
  110324. * Enable or disable collisions of the camera with the rest of the scene objects.
  110325. */
  110326. checkCollisions: boolean;
  110327. /**
  110328. * Enable or disable gravity on the camera.
  110329. */
  110330. applyGravity: boolean;
  110331. /**
  110332. * Define the current direction the camera is moving to.
  110333. */
  110334. cameraDirection: Vector3;
  110335. /**
  110336. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110337. * This overrides and empties cameraRotation.
  110338. */
  110339. rotationQuaternion: Quaternion;
  110340. /**
  110341. * Track Roll to maintain the wanted Rolling when looking around.
  110342. */
  110343. _trackRoll: number;
  110344. /**
  110345. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110346. */
  110347. rollCorrect: number;
  110348. /**
  110349. * Mimic a banked turn, Rolling the camera when Yawing.
  110350. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110351. */
  110352. bankedTurn: boolean;
  110353. /**
  110354. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110355. */
  110356. bankedTurnLimit: number;
  110357. /**
  110358. * Value of 0 disables the banked Roll.
  110359. * Value of 1 is equal to the Yaw angle in radians.
  110360. */
  110361. bankedTurnMultiplier: number;
  110362. /**
  110363. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110364. */
  110365. inputs: FlyCameraInputsManager;
  110366. /**
  110367. * Gets the input sensibility for mouse input.
  110368. * Higher values reduce sensitivity.
  110369. */
  110370. get angularSensibility(): number;
  110371. /**
  110372. * Sets the input sensibility for a mouse input.
  110373. * Higher values reduce sensitivity.
  110374. */
  110375. set angularSensibility(value: number);
  110376. /**
  110377. * Get the keys for camera movement forward.
  110378. */
  110379. get keysForward(): number[];
  110380. /**
  110381. * Set the keys for camera movement forward.
  110382. */
  110383. set keysForward(value: number[]);
  110384. /**
  110385. * Get the keys for camera movement backward.
  110386. */
  110387. get keysBackward(): number[];
  110388. set keysBackward(value: number[]);
  110389. /**
  110390. * Get the keys for camera movement up.
  110391. */
  110392. get keysUp(): number[];
  110393. /**
  110394. * Set the keys for camera movement up.
  110395. */
  110396. set keysUp(value: number[]);
  110397. /**
  110398. * Get the keys for camera movement down.
  110399. */
  110400. get keysDown(): number[];
  110401. /**
  110402. * Set the keys for camera movement down.
  110403. */
  110404. set keysDown(value: number[]);
  110405. /**
  110406. * Get the keys for camera movement left.
  110407. */
  110408. get keysLeft(): number[];
  110409. /**
  110410. * Set the keys for camera movement left.
  110411. */
  110412. set keysLeft(value: number[]);
  110413. /**
  110414. * Set the keys for camera movement right.
  110415. */
  110416. get keysRight(): number[];
  110417. /**
  110418. * Set the keys for camera movement right.
  110419. */
  110420. set keysRight(value: number[]);
  110421. /**
  110422. * Event raised when the camera collides with a mesh in the scene.
  110423. */
  110424. onCollide: (collidedMesh: AbstractMesh) => void;
  110425. private _collider;
  110426. private _needMoveForGravity;
  110427. private _oldPosition;
  110428. private _diffPosition;
  110429. private _newPosition;
  110430. /** @hidden */
  110431. _localDirection: Vector3;
  110432. /** @hidden */
  110433. _transformedDirection: Vector3;
  110434. /**
  110435. * Instantiates a FlyCamera.
  110436. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110437. * such as in a 3D Space Shooter or a Flight Simulator.
  110438. * @param name Define the name of the camera in the scene.
  110439. * @param position Define the starting position of the camera in the scene.
  110440. * @param scene Define the scene the camera belongs to.
  110441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110442. */
  110443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110444. /**
  110445. * Attach a control to the HTML DOM element.
  110446. * @param element Defines the element that listens to the input events.
  110447. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110448. */
  110449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110450. /**
  110451. * Detach a control from the HTML DOM element.
  110452. * The camera will stop reacting to that input.
  110453. * @param element Defines the element that listens to the input events.
  110454. */
  110455. detachControl(element: HTMLElement): void;
  110456. private _collisionMask;
  110457. /**
  110458. * Get the mask that the camera ignores in collision events.
  110459. */
  110460. get collisionMask(): number;
  110461. /**
  110462. * Set the mask that the camera ignores in collision events.
  110463. */
  110464. set collisionMask(mask: number);
  110465. /** @hidden */
  110466. _collideWithWorld(displacement: Vector3): void;
  110467. /** @hidden */
  110468. private _onCollisionPositionChange;
  110469. /** @hidden */
  110470. _checkInputs(): void;
  110471. /** @hidden */
  110472. _decideIfNeedsToMove(): boolean;
  110473. /** @hidden */
  110474. _updatePosition(): void;
  110475. /**
  110476. * Restore the Roll to its target value at the rate specified.
  110477. * @param rate - Higher means slower restoring.
  110478. * @hidden
  110479. */
  110480. restoreRoll(rate: number): void;
  110481. /**
  110482. * Destroy the camera and release the current resources held by it.
  110483. */
  110484. dispose(): void;
  110485. /**
  110486. * Get the current object class name.
  110487. * @returns the class name.
  110488. */
  110489. getClassName(): string;
  110490. }
  110491. }
  110492. declare module BABYLON {
  110493. /**
  110494. * Listen to keyboard events to control the camera.
  110495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110496. */
  110497. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110498. /**
  110499. * Defines the camera the input is attached to.
  110500. */
  110501. camera: FlyCamera;
  110502. /**
  110503. * The list of keyboard keys used to control the forward move of the camera.
  110504. */
  110505. keysForward: number[];
  110506. /**
  110507. * The list of keyboard keys used to control the backward move of the camera.
  110508. */
  110509. keysBackward: number[];
  110510. /**
  110511. * The list of keyboard keys used to control the forward move of the camera.
  110512. */
  110513. keysUp: number[];
  110514. /**
  110515. * The list of keyboard keys used to control the backward move of the camera.
  110516. */
  110517. keysDown: number[];
  110518. /**
  110519. * The list of keyboard keys used to control the right strafe move of the camera.
  110520. */
  110521. keysRight: number[];
  110522. /**
  110523. * The list of keyboard keys used to control the left strafe move of the camera.
  110524. */
  110525. keysLeft: number[];
  110526. private _keys;
  110527. private _onCanvasBlurObserver;
  110528. private _onKeyboardObserver;
  110529. private _engine;
  110530. private _scene;
  110531. /**
  110532. * Attach the input controls to a specific dom element to get the input from.
  110533. * @param element Defines the element the controls should be listened from
  110534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110535. */
  110536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110537. /**
  110538. * Detach the current controls from the specified dom element.
  110539. * @param element Defines the element to stop listening the inputs from
  110540. */
  110541. detachControl(element: Nullable<HTMLElement>): void;
  110542. /**
  110543. * Gets the class name of the current intput.
  110544. * @returns the class name
  110545. */
  110546. getClassName(): string;
  110547. /** @hidden */
  110548. _onLostFocus(e: FocusEvent): void;
  110549. /**
  110550. * Get the friendly name associated with the input class.
  110551. * @returns the input friendly name
  110552. */
  110553. getSimpleName(): string;
  110554. /**
  110555. * Update the current camera state depending on the inputs that have been used this frame.
  110556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110557. */
  110558. checkInputs(): void;
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. /**
  110563. * Manage the mouse wheel inputs to control a follow camera.
  110564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110565. */
  110566. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110567. /**
  110568. * Defines the camera the input is attached to.
  110569. */
  110570. camera: FollowCamera;
  110571. /**
  110572. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110573. */
  110574. axisControlRadius: boolean;
  110575. /**
  110576. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110577. */
  110578. axisControlHeight: boolean;
  110579. /**
  110580. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110581. */
  110582. axisControlRotation: boolean;
  110583. /**
  110584. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110585. * relation to mouseWheel events.
  110586. */
  110587. wheelPrecision: number;
  110588. /**
  110589. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110590. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110591. */
  110592. wheelDeltaPercentage: number;
  110593. private _wheel;
  110594. private _observer;
  110595. /**
  110596. * Attach the input controls to a specific dom element to get the input from.
  110597. * @param element Defines the element the controls should be listened from
  110598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110599. */
  110600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110601. /**
  110602. * Detach the current controls from the specified dom element.
  110603. * @param element Defines the element to stop listening the inputs from
  110604. */
  110605. detachControl(element: Nullable<HTMLElement>): void;
  110606. /**
  110607. * Gets the class name of the current intput.
  110608. * @returns the class name
  110609. */
  110610. getClassName(): string;
  110611. /**
  110612. * Get the friendly name associated with the input class.
  110613. * @returns the input friendly name
  110614. */
  110615. getSimpleName(): string;
  110616. }
  110617. }
  110618. declare module BABYLON {
  110619. /**
  110620. * Manage the pointers inputs to control an follow camera.
  110621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110622. */
  110623. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110624. /**
  110625. * Defines the camera the input is attached to.
  110626. */
  110627. camera: FollowCamera;
  110628. /**
  110629. * Gets the class name of the current input.
  110630. * @returns the class name
  110631. */
  110632. getClassName(): string;
  110633. /**
  110634. * Defines the pointer angular sensibility along the X axis or how fast is
  110635. * the camera rotating.
  110636. * A negative number will reverse the axis direction.
  110637. */
  110638. angularSensibilityX: number;
  110639. /**
  110640. * Defines the pointer angular sensibility along the Y axis or how fast is
  110641. * the camera rotating.
  110642. * A negative number will reverse the axis direction.
  110643. */
  110644. angularSensibilityY: number;
  110645. /**
  110646. * Defines the pointer pinch precision or how fast is the camera zooming.
  110647. * A negative number will reverse the axis direction.
  110648. */
  110649. pinchPrecision: number;
  110650. /**
  110651. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110652. * from 0.
  110653. * It defines the percentage of current camera.radius to use as delta when
  110654. * pinch zoom is used.
  110655. */
  110656. pinchDeltaPercentage: number;
  110657. /**
  110658. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110659. */
  110660. axisXControlRadius: boolean;
  110661. /**
  110662. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110663. */
  110664. axisXControlHeight: boolean;
  110665. /**
  110666. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110667. */
  110668. axisXControlRotation: boolean;
  110669. /**
  110670. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110671. */
  110672. axisYControlRadius: boolean;
  110673. /**
  110674. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110675. */
  110676. axisYControlHeight: boolean;
  110677. /**
  110678. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110679. */
  110680. axisYControlRotation: boolean;
  110681. /**
  110682. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110683. */
  110684. axisPinchControlRadius: boolean;
  110685. /**
  110686. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110687. */
  110688. axisPinchControlHeight: boolean;
  110689. /**
  110690. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110691. */
  110692. axisPinchControlRotation: boolean;
  110693. /**
  110694. * Log error messages if basic misconfiguration has occurred.
  110695. */
  110696. warningEnable: boolean;
  110697. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110698. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110699. private _warningCounter;
  110700. private _warning;
  110701. }
  110702. }
  110703. declare module BABYLON {
  110704. /**
  110705. * Default Inputs manager for the FollowCamera.
  110706. * It groups all the default supported inputs for ease of use.
  110707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110708. */
  110709. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110710. /**
  110711. * Instantiates a new FollowCameraInputsManager.
  110712. * @param camera Defines the camera the inputs belong to
  110713. */
  110714. constructor(camera: FollowCamera);
  110715. /**
  110716. * Add keyboard input support to the input manager.
  110717. * @returns the current input manager
  110718. */
  110719. addKeyboard(): FollowCameraInputsManager;
  110720. /**
  110721. * Add mouse wheel input support to the input manager.
  110722. * @returns the current input manager
  110723. */
  110724. addMouseWheel(): FollowCameraInputsManager;
  110725. /**
  110726. * Add pointers input support to the input manager.
  110727. * @returns the current input manager
  110728. */
  110729. addPointers(): FollowCameraInputsManager;
  110730. /**
  110731. * Add orientation input support to the input manager.
  110732. * @returns the current input manager
  110733. */
  110734. addVRDeviceOrientation(): FollowCameraInputsManager;
  110735. }
  110736. }
  110737. declare module BABYLON {
  110738. /**
  110739. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110740. * an arc rotate version arcFollowCamera are available.
  110741. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110742. */
  110743. export class FollowCamera extends TargetCamera {
  110744. /**
  110745. * Distance the follow camera should follow an object at
  110746. */
  110747. radius: number;
  110748. /**
  110749. * Minimum allowed distance of the camera to the axis of rotation
  110750. * (The camera can not get closer).
  110751. * This can help limiting how the Camera is able to move in the scene.
  110752. */
  110753. lowerRadiusLimit: Nullable<number>;
  110754. /**
  110755. * Maximum allowed distance of the camera to the axis of rotation
  110756. * (The camera can not get further).
  110757. * This can help limiting how the Camera is able to move in the scene.
  110758. */
  110759. upperRadiusLimit: Nullable<number>;
  110760. /**
  110761. * Define a rotation offset between the camera and the object it follows
  110762. */
  110763. rotationOffset: number;
  110764. /**
  110765. * Minimum allowed angle to camera position relative to target object.
  110766. * This can help limiting how the Camera is able to move in the scene.
  110767. */
  110768. lowerRotationOffsetLimit: Nullable<number>;
  110769. /**
  110770. * Maximum allowed angle to camera position relative to target object.
  110771. * This can help limiting how the Camera is able to move in the scene.
  110772. */
  110773. upperRotationOffsetLimit: Nullable<number>;
  110774. /**
  110775. * Define a height offset between the camera and the object it follows.
  110776. * It can help following an object from the top (like a car chaing a plane)
  110777. */
  110778. heightOffset: number;
  110779. /**
  110780. * Minimum allowed height of camera position relative to target object.
  110781. * This can help limiting how the Camera is able to move in the scene.
  110782. */
  110783. lowerHeightOffsetLimit: Nullable<number>;
  110784. /**
  110785. * Maximum allowed height of camera position relative to target object.
  110786. * This can help limiting how the Camera is able to move in the scene.
  110787. */
  110788. upperHeightOffsetLimit: Nullable<number>;
  110789. /**
  110790. * Define how fast the camera can accelerate to follow it s target.
  110791. */
  110792. cameraAcceleration: number;
  110793. /**
  110794. * Define the speed limit of the camera following an object.
  110795. */
  110796. maxCameraSpeed: number;
  110797. /**
  110798. * Define the target of the camera.
  110799. */
  110800. lockedTarget: Nullable<AbstractMesh>;
  110801. /**
  110802. * Defines the input associated with the camera.
  110803. */
  110804. inputs: FollowCameraInputsManager;
  110805. /**
  110806. * Instantiates the follow camera.
  110807. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110808. * @param name Define the name of the camera in the scene
  110809. * @param position Define the position of the camera
  110810. * @param scene Define the scene the camera belong to
  110811. * @param lockedTarget Define the target of the camera
  110812. */
  110813. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110814. private _follow;
  110815. /**
  110816. * Attached controls to the current camera.
  110817. * @param element Defines the element the controls should be listened from
  110818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110819. */
  110820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110821. /**
  110822. * Detach the current controls from the camera.
  110823. * The camera will stop reacting to inputs.
  110824. * @param element Defines the element to stop listening the inputs from
  110825. */
  110826. detachControl(element: HTMLElement): void;
  110827. /** @hidden */
  110828. _checkInputs(): void;
  110829. private _checkLimits;
  110830. /**
  110831. * Gets the camera class name.
  110832. * @returns the class name
  110833. */
  110834. getClassName(): string;
  110835. }
  110836. /**
  110837. * Arc Rotate version of the follow camera.
  110838. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110839. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110840. */
  110841. export class ArcFollowCamera extends TargetCamera {
  110842. /** The longitudinal angle of the camera */
  110843. alpha: number;
  110844. /** The latitudinal angle of the camera */
  110845. beta: number;
  110846. /** The radius of the camera from its target */
  110847. radius: number;
  110848. /** Define the camera target (the messh it should follow) */
  110849. target: Nullable<AbstractMesh>;
  110850. private _cartesianCoordinates;
  110851. /**
  110852. * Instantiates a new ArcFollowCamera
  110853. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110854. * @param name Define the name of the camera
  110855. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110856. * @param beta Define the rotation angle of the camera around the elevation axis
  110857. * @param radius Define the radius of the camera from its target point
  110858. * @param target Define the target of the camera
  110859. * @param scene Define the scene the camera belongs to
  110860. */
  110861. constructor(name: string,
  110862. /** The longitudinal angle of the camera */
  110863. alpha: number,
  110864. /** The latitudinal angle of the camera */
  110865. beta: number,
  110866. /** The radius of the camera from its target */
  110867. radius: number,
  110868. /** Define the camera target (the messh it should follow) */
  110869. target: Nullable<AbstractMesh>, scene: Scene);
  110870. private _follow;
  110871. /** @hidden */
  110872. _checkInputs(): void;
  110873. /**
  110874. * Returns the class name of the object.
  110875. * It is mostly used internally for serialization purposes.
  110876. */
  110877. getClassName(): string;
  110878. }
  110879. }
  110880. declare module BABYLON {
  110881. /**
  110882. * Manage the keyboard inputs to control the movement of a follow camera.
  110883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110884. */
  110885. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110886. /**
  110887. * Defines the camera the input is attached to.
  110888. */
  110889. camera: FollowCamera;
  110890. /**
  110891. * Defines the list of key codes associated with the up action (increase heightOffset)
  110892. */
  110893. keysHeightOffsetIncr: number[];
  110894. /**
  110895. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110896. */
  110897. keysHeightOffsetDecr: number[];
  110898. /**
  110899. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110900. */
  110901. keysHeightOffsetModifierAlt: boolean;
  110902. /**
  110903. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110904. */
  110905. keysHeightOffsetModifierCtrl: boolean;
  110906. /**
  110907. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110908. */
  110909. keysHeightOffsetModifierShift: boolean;
  110910. /**
  110911. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110912. */
  110913. keysRotationOffsetIncr: number[];
  110914. /**
  110915. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110916. */
  110917. keysRotationOffsetDecr: number[];
  110918. /**
  110919. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110920. */
  110921. keysRotationOffsetModifierAlt: boolean;
  110922. /**
  110923. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110924. */
  110925. keysRotationOffsetModifierCtrl: boolean;
  110926. /**
  110927. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110928. */
  110929. keysRotationOffsetModifierShift: boolean;
  110930. /**
  110931. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110932. */
  110933. keysRadiusIncr: number[];
  110934. /**
  110935. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110936. */
  110937. keysRadiusDecr: number[];
  110938. /**
  110939. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110940. */
  110941. keysRadiusModifierAlt: boolean;
  110942. /**
  110943. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110944. */
  110945. keysRadiusModifierCtrl: boolean;
  110946. /**
  110947. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110948. */
  110949. keysRadiusModifierShift: boolean;
  110950. /**
  110951. * Defines the rate of change of heightOffset.
  110952. */
  110953. heightSensibility: number;
  110954. /**
  110955. * Defines the rate of change of rotationOffset.
  110956. */
  110957. rotationSensibility: number;
  110958. /**
  110959. * Defines the rate of change of radius.
  110960. */
  110961. radiusSensibility: number;
  110962. private _keys;
  110963. private _ctrlPressed;
  110964. private _altPressed;
  110965. private _shiftPressed;
  110966. private _onCanvasBlurObserver;
  110967. private _onKeyboardObserver;
  110968. private _engine;
  110969. private _scene;
  110970. /**
  110971. * Attach the input controls to a specific dom element to get the input from.
  110972. * @param element Defines the element the controls should be listened from
  110973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110974. */
  110975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110976. /**
  110977. * Detach the current controls from the specified dom element.
  110978. * @param element Defines the element to stop listening the inputs from
  110979. */
  110980. detachControl(element: Nullable<HTMLElement>): void;
  110981. /**
  110982. * Update the current camera state depending on the inputs that have been used this frame.
  110983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110984. */
  110985. checkInputs(): void;
  110986. /**
  110987. * Gets the class name of the current input.
  110988. * @returns the class name
  110989. */
  110990. getClassName(): string;
  110991. /**
  110992. * Get the friendly name associated with the input class.
  110993. * @returns the input friendly name
  110994. */
  110995. getSimpleName(): string;
  110996. /**
  110997. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110998. * allow modification of the heightOffset value.
  110999. */
  111000. private _modifierHeightOffset;
  111001. /**
  111002. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111003. * allow modification of the rotationOffset value.
  111004. */
  111005. private _modifierRotationOffset;
  111006. /**
  111007. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111008. * allow modification of the radius value.
  111009. */
  111010. private _modifierRadius;
  111011. }
  111012. }
  111013. declare module BABYLON {
  111014. interface FreeCameraInputsManager {
  111015. /**
  111016. * @hidden
  111017. */
  111018. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  111019. /**
  111020. * Add orientation input support to the input manager.
  111021. * @returns the current input manager
  111022. */
  111023. addDeviceOrientation(): FreeCameraInputsManager;
  111024. }
  111025. /**
  111026. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  111027. * Screen rotation is taken into account.
  111028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111029. */
  111030. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  111031. private _camera;
  111032. private _screenOrientationAngle;
  111033. private _constantTranform;
  111034. private _screenQuaternion;
  111035. private _alpha;
  111036. private _beta;
  111037. private _gamma;
  111038. /**
  111039. * Can be used to detect if a device orientation sensor is available on a device
  111040. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  111041. * @returns a promise that will resolve on orientation change
  111042. */
  111043. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  111044. /**
  111045. * @hidden
  111046. */
  111047. _onDeviceOrientationChangedObservable: Observable<void>;
  111048. /**
  111049. * Instantiates a new input
  111050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111051. */
  111052. constructor();
  111053. /**
  111054. * Define the camera controlled by the input.
  111055. */
  111056. get camera(): FreeCamera;
  111057. set camera(camera: FreeCamera);
  111058. /**
  111059. * Attach the input controls to a specific dom element to get the input from.
  111060. * @param element Defines the element the controls should be listened from
  111061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111062. */
  111063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111064. private _orientationChanged;
  111065. private _deviceOrientation;
  111066. /**
  111067. * Detach the current controls from the specified dom element.
  111068. * @param element Defines the element to stop listening the inputs from
  111069. */
  111070. detachControl(element: Nullable<HTMLElement>): void;
  111071. /**
  111072. * Update the current camera state depending on the inputs that have been used this frame.
  111073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111074. */
  111075. checkInputs(): void;
  111076. /**
  111077. * Gets the class name of the current intput.
  111078. * @returns the class name
  111079. */
  111080. getClassName(): string;
  111081. /**
  111082. * Get the friendly name associated with the input class.
  111083. * @returns the input friendly name
  111084. */
  111085. getSimpleName(): string;
  111086. }
  111087. }
  111088. declare module BABYLON {
  111089. /**
  111090. * Manage the gamepad inputs to control a free camera.
  111091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111092. */
  111093. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111094. /**
  111095. * Define the camera the input is attached to.
  111096. */
  111097. camera: FreeCamera;
  111098. /**
  111099. * Define the Gamepad controlling the input
  111100. */
  111101. gamepad: Nullable<Gamepad>;
  111102. /**
  111103. * Defines the gamepad rotation sensiblity.
  111104. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111105. */
  111106. gamepadAngularSensibility: number;
  111107. /**
  111108. * Defines the gamepad move sensiblity.
  111109. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111110. */
  111111. gamepadMoveSensibility: number;
  111112. private _yAxisScale;
  111113. /**
  111114. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111115. */
  111116. get invertYAxis(): boolean;
  111117. set invertYAxis(value: boolean);
  111118. private _onGamepadConnectedObserver;
  111119. private _onGamepadDisconnectedObserver;
  111120. private _cameraTransform;
  111121. private _deltaTransform;
  111122. private _vector3;
  111123. private _vector2;
  111124. /**
  111125. * Attach the input controls to a specific dom element to get the input from.
  111126. * @param element Defines the element the controls should be listened from
  111127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111128. */
  111129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111130. /**
  111131. * Detach the current controls from the specified dom element.
  111132. * @param element Defines the element to stop listening the inputs from
  111133. */
  111134. detachControl(element: Nullable<HTMLElement>): void;
  111135. /**
  111136. * Update the current camera state depending on the inputs that have been used this frame.
  111137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111138. */
  111139. checkInputs(): void;
  111140. /**
  111141. * Gets the class name of the current intput.
  111142. * @returns the class name
  111143. */
  111144. getClassName(): string;
  111145. /**
  111146. * Get the friendly name associated with the input class.
  111147. * @returns the input friendly name
  111148. */
  111149. getSimpleName(): string;
  111150. }
  111151. }
  111152. declare module BABYLON {
  111153. /**
  111154. * Defines the potential axis of a Joystick
  111155. */
  111156. export enum JoystickAxis {
  111157. /** X axis */
  111158. X = 0,
  111159. /** Y axis */
  111160. Y = 1,
  111161. /** Z axis */
  111162. Z = 2
  111163. }
  111164. /**
  111165. * Class used to define virtual joystick (used in touch mode)
  111166. */
  111167. export class VirtualJoystick {
  111168. /**
  111169. * Gets or sets a boolean indicating that left and right values must be inverted
  111170. */
  111171. reverseLeftRight: boolean;
  111172. /**
  111173. * Gets or sets a boolean indicating that up and down values must be inverted
  111174. */
  111175. reverseUpDown: boolean;
  111176. /**
  111177. * Gets the offset value for the position (ie. the change of the position value)
  111178. */
  111179. deltaPosition: Vector3;
  111180. /**
  111181. * Gets a boolean indicating if the virtual joystick was pressed
  111182. */
  111183. pressed: boolean;
  111184. /**
  111185. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111186. */
  111187. static Canvas: Nullable<HTMLCanvasElement>;
  111188. private static _globalJoystickIndex;
  111189. private static vjCanvasContext;
  111190. private static vjCanvasWidth;
  111191. private static vjCanvasHeight;
  111192. private static halfWidth;
  111193. private _action;
  111194. private _axisTargetedByLeftAndRight;
  111195. private _axisTargetedByUpAndDown;
  111196. private _joystickSensibility;
  111197. private _inversedSensibility;
  111198. private _joystickPointerID;
  111199. private _joystickColor;
  111200. private _joystickPointerPos;
  111201. private _joystickPreviousPointerPos;
  111202. private _joystickPointerStartPos;
  111203. private _deltaJoystickVector;
  111204. private _leftJoystick;
  111205. private _touches;
  111206. private _onPointerDownHandlerRef;
  111207. private _onPointerMoveHandlerRef;
  111208. private _onPointerUpHandlerRef;
  111209. private _onResize;
  111210. /**
  111211. * Creates a new virtual joystick
  111212. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111213. */
  111214. constructor(leftJoystick?: boolean);
  111215. /**
  111216. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111217. * @param newJoystickSensibility defines the new sensibility
  111218. */
  111219. setJoystickSensibility(newJoystickSensibility: number): void;
  111220. private _onPointerDown;
  111221. private _onPointerMove;
  111222. private _onPointerUp;
  111223. /**
  111224. * Change the color of the virtual joystick
  111225. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111226. */
  111227. setJoystickColor(newColor: string): void;
  111228. /**
  111229. * Defines a callback to call when the joystick is touched
  111230. * @param action defines the callback
  111231. */
  111232. setActionOnTouch(action: () => any): void;
  111233. /**
  111234. * Defines which axis you'd like to control for left & right
  111235. * @param axis defines the axis to use
  111236. */
  111237. setAxisForLeftRight(axis: JoystickAxis): void;
  111238. /**
  111239. * Defines which axis you'd like to control for up & down
  111240. * @param axis defines the axis to use
  111241. */
  111242. setAxisForUpDown(axis: JoystickAxis): void;
  111243. private _drawVirtualJoystick;
  111244. /**
  111245. * Release internal HTML canvas
  111246. */
  111247. releaseCanvas(): void;
  111248. }
  111249. }
  111250. declare module BABYLON {
  111251. interface FreeCameraInputsManager {
  111252. /**
  111253. * Add virtual joystick input support to the input manager.
  111254. * @returns the current input manager
  111255. */
  111256. addVirtualJoystick(): FreeCameraInputsManager;
  111257. }
  111258. /**
  111259. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111261. */
  111262. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111263. /**
  111264. * Defines the camera the input is attached to.
  111265. */
  111266. camera: FreeCamera;
  111267. private _leftjoystick;
  111268. private _rightjoystick;
  111269. /**
  111270. * Gets the left stick of the virtual joystick.
  111271. * @returns The virtual Joystick
  111272. */
  111273. getLeftJoystick(): VirtualJoystick;
  111274. /**
  111275. * Gets the right stick of the virtual joystick.
  111276. * @returns The virtual Joystick
  111277. */
  111278. getRightJoystick(): VirtualJoystick;
  111279. /**
  111280. * Update the current camera state depending on the inputs that have been used this frame.
  111281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111282. */
  111283. checkInputs(): void;
  111284. /**
  111285. * Attach the input controls to a specific dom element to get the input from.
  111286. * @param element Defines the element the controls should be listened from
  111287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111288. */
  111289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111290. /**
  111291. * Detach the current controls from the specified dom element.
  111292. * @param element Defines the element to stop listening the inputs from
  111293. */
  111294. detachControl(element: Nullable<HTMLElement>): void;
  111295. /**
  111296. * Gets the class name of the current intput.
  111297. * @returns the class name
  111298. */
  111299. getClassName(): string;
  111300. /**
  111301. * Get the friendly name associated with the input class.
  111302. * @returns the input friendly name
  111303. */
  111304. getSimpleName(): string;
  111305. }
  111306. }
  111307. declare module BABYLON {
  111308. /**
  111309. * This represents a FPS type of camera controlled by touch.
  111310. * This is like a universal camera minus the Gamepad controls.
  111311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111312. */
  111313. export class TouchCamera extends FreeCamera {
  111314. /**
  111315. * Defines the touch sensibility for rotation.
  111316. * The higher the faster.
  111317. */
  111318. get touchAngularSensibility(): number;
  111319. set touchAngularSensibility(value: number);
  111320. /**
  111321. * Defines the touch sensibility for move.
  111322. * The higher the faster.
  111323. */
  111324. get touchMoveSensibility(): number;
  111325. set touchMoveSensibility(value: number);
  111326. /**
  111327. * Instantiates a new touch camera.
  111328. * This represents a FPS type of camera controlled by touch.
  111329. * This is like a universal camera minus the Gamepad controls.
  111330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111331. * @param name Define the name of the camera in the scene
  111332. * @param position Define the start position of the camera in the scene
  111333. * @param scene Define the scene the camera belongs to
  111334. */
  111335. constructor(name: string, position: Vector3, scene: Scene);
  111336. /**
  111337. * Gets the current object class name.
  111338. * @return the class name
  111339. */
  111340. getClassName(): string;
  111341. /** @hidden */
  111342. _setupInputs(): void;
  111343. }
  111344. }
  111345. declare module BABYLON {
  111346. /**
  111347. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111348. * being tilted forward or back and left or right.
  111349. */
  111350. export class DeviceOrientationCamera extends FreeCamera {
  111351. private _initialQuaternion;
  111352. private _quaternionCache;
  111353. private _tmpDragQuaternion;
  111354. private _disablePointerInputWhenUsingDeviceOrientation;
  111355. /**
  111356. * Creates a new device orientation camera
  111357. * @param name The name of the camera
  111358. * @param position The start position camera
  111359. * @param scene The scene the camera belongs to
  111360. */
  111361. constructor(name: string, position: Vector3, scene: Scene);
  111362. /**
  111363. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111364. */
  111365. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111366. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111367. private _dragFactor;
  111368. /**
  111369. * Enabled turning on the y axis when the orientation sensor is active
  111370. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111371. */
  111372. enableHorizontalDragging(dragFactor?: number): void;
  111373. /**
  111374. * Gets the current instance class name ("DeviceOrientationCamera").
  111375. * This helps avoiding instanceof at run time.
  111376. * @returns the class name
  111377. */
  111378. getClassName(): string;
  111379. /**
  111380. * @hidden
  111381. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111382. */
  111383. _checkInputs(): void;
  111384. /**
  111385. * Reset the camera to its default orientation on the specified axis only.
  111386. * @param axis The axis to reset
  111387. */
  111388. resetToCurrentRotation(axis?: Axis): void;
  111389. }
  111390. }
  111391. declare module BABYLON {
  111392. /**
  111393. * Defines supported buttons for XBox360 compatible gamepads
  111394. */
  111395. export enum Xbox360Button {
  111396. /** A */
  111397. A = 0,
  111398. /** B */
  111399. B = 1,
  111400. /** X */
  111401. X = 2,
  111402. /** Y */
  111403. Y = 3,
  111404. /** Start */
  111405. Start = 4,
  111406. /** Back */
  111407. Back = 5,
  111408. /** Left button */
  111409. LB = 6,
  111410. /** Right button */
  111411. RB = 7,
  111412. /** Left stick */
  111413. LeftStick = 8,
  111414. /** Right stick */
  111415. RightStick = 9
  111416. }
  111417. /** Defines values for XBox360 DPad */
  111418. export enum Xbox360Dpad {
  111419. /** Up */
  111420. Up = 0,
  111421. /** Down */
  111422. Down = 1,
  111423. /** Left */
  111424. Left = 2,
  111425. /** Right */
  111426. Right = 3
  111427. }
  111428. /**
  111429. * Defines a XBox360 gamepad
  111430. */
  111431. export class Xbox360Pad extends Gamepad {
  111432. private _leftTrigger;
  111433. private _rightTrigger;
  111434. private _onlefttriggerchanged;
  111435. private _onrighttriggerchanged;
  111436. private _onbuttondown;
  111437. private _onbuttonup;
  111438. private _ondpaddown;
  111439. private _ondpadup;
  111440. /** Observable raised when a button is pressed */
  111441. onButtonDownObservable: Observable<Xbox360Button>;
  111442. /** Observable raised when a button is released */
  111443. onButtonUpObservable: Observable<Xbox360Button>;
  111444. /** Observable raised when a pad is pressed */
  111445. onPadDownObservable: Observable<Xbox360Dpad>;
  111446. /** Observable raised when a pad is released */
  111447. onPadUpObservable: Observable<Xbox360Dpad>;
  111448. private _buttonA;
  111449. private _buttonB;
  111450. private _buttonX;
  111451. private _buttonY;
  111452. private _buttonBack;
  111453. private _buttonStart;
  111454. private _buttonLB;
  111455. private _buttonRB;
  111456. private _buttonLeftStick;
  111457. private _buttonRightStick;
  111458. private _dPadUp;
  111459. private _dPadDown;
  111460. private _dPadLeft;
  111461. private _dPadRight;
  111462. private _isXboxOnePad;
  111463. /**
  111464. * Creates a new XBox360 gamepad object
  111465. * @param id defines the id of this gamepad
  111466. * @param index defines its index
  111467. * @param gamepad defines the internal HTML gamepad object
  111468. * @param xboxOne defines if it is a XBox One gamepad
  111469. */
  111470. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111471. /**
  111472. * Defines the callback to call when left trigger is pressed
  111473. * @param callback defines the callback to use
  111474. */
  111475. onlefttriggerchanged(callback: (value: number) => void): void;
  111476. /**
  111477. * Defines the callback to call when right trigger is pressed
  111478. * @param callback defines the callback to use
  111479. */
  111480. onrighttriggerchanged(callback: (value: number) => void): void;
  111481. /**
  111482. * Gets the left trigger value
  111483. */
  111484. get leftTrigger(): number;
  111485. /**
  111486. * Sets the left trigger value
  111487. */
  111488. set leftTrigger(newValue: number);
  111489. /**
  111490. * Gets the right trigger value
  111491. */
  111492. get rightTrigger(): number;
  111493. /**
  111494. * Sets the right trigger value
  111495. */
  111496. set rightTrigger(newValue: number);
  111497. /**
  111498. * Defines the callback to call when a button is pressed
  111499. * @param callback defines the callback to use
  111500. */
  111501. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111502. /**
  111503. * Defines the callback to call when a button is released
  111504. * @param callback defines the callback to use
  111505. */
  111506. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111507. /**
  111508. * Defines the callback to call when a pad is pressed
  111509. * @param callback defines the callback to use
  111510. */
  111511. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111512. /**
  111513. * Defines the callback to call when a pad is released
  111514. * @param callback defines the callback to use
  111515. */
  111516. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111517. private _setButtonValue;
  111518. private _setDPadValue;
  111519. /**
  111520. * Gets the value of the `A` button
  111521. */
  111522. get buttonA(): number;
  111523. /**
  111524. * Sets the value of the `A` button
  111525. */
  111526. set buttonA(value: number);
  111527. /**
  111528. * Gets the value of the `B` button
  111529. */
  111530. get buttonB(): number;
  111531. /**
  111532. * Sets the value of the `B` button
  111533. */
  111534. set buttonB(value: number);
  111535. /**
  111536. * Gets the value of the `X` button
  111537. */
  111538. get buttonX(): number;
  111539. /**
  111540. * Sets the value of the `X` button
  111541. */
  111542. set buttonX(value: number);
  111543. /**
  111544. * Gets the value of the `Y` button
  111545. */
  111546. get buttonY(): number;
  111547. /**
  111548. * Sets the value of the `Y` button
  111549. */
  111550. set buttonY(value: number);
  111551. /**
  111552. * Gets the value of the `Start` button
  111553. */
  111554. get buttonStart(): number;
  111555. /**
  111556. * Sets the value of the `Start` button
  111557. */
  111558. set buttonStart(value: number);
  111559. /**
  111560. * Gets the value of the `Back` button
  111561. */
  111562. get buttonBack(): number;
  111563. /**
  111564. * Sets the value of the `Back` button
  111565. */
  111566. set buttonBack(value: number);
  111567. /**
  111568. * Gets the value of the `Left` button
  111569. */
  111570. get buttonLB(): number;
  111571. /**
  111572. * Sets the value of the `Left` button
  111573. */
  111574. set buttonLB(value: number);
  111575. /**
  111576. * Gets the value of the `Right` button
  111577. */
  111578. get buttonRB(): number;
  111579. /**
  111580. * Sets the value of the `Right` button
  111581. */
  111582. set buttonRB(value: number);
  111583. /**
  111584. * Gets the value of the Left joystick
  111585. */
  111586. get buttonLeftStick(): number;
  111587. /**
  111588. * Sets the value of the Left joystick
  111589. */
  111590. set buttonLeftStick(value: number);
  111591. /**
  111592. * Gets the value of the Right joystick
  111593. */
  111594. get buttonRightStick(): number;
  111595. /**
  111596. * Sets the value of the Right joystick
  111597. */
  111598. set buttonRightStick(value: number);
  111599. /**
  111600. * Gets the value of D-pad up
  111601. */
  111602. get dPadUp(): number;
  111603. /**
  111604. * Sets the value of D-pad up
  111605. */
  111606. set dPadUp(value: number);
  111607. /**
  111608. * Gets the value of D-pad down
  111609. */
  111610. get dPadDown(): number;
  111611. /**
  111612. * Sets the value of D-pad down
  111613. */
  111614. set dPadDown(value: number);
  111615. /**
  111616. * Gets the value of D-pad left
  111617. */
  111618. get dPadLeft(): number;
  111619. /**
  111620. * Sets the value of D-pad left
  111621. */
  111622. set dPadLeft(value: number);
  111623. /**
  111624. * Gets the value of D-pad right
  111625. */
  111626. get dPadRight(): number;
  111627. /**
  111628. * Sets the value of D-pad right
  111629. */
  111630. set dPadRight(value: number);
  111631. /**
  111632. * Force the gamepad to synchronize with device values
  111633. */
  111634. update(): void;
  111635. /**
  111636. * Disposes the gamepad
  111637. */
  111638. dispose(): void;
  111639. }
  111640. }
  111641. declare module BABYLON {
  111642. /**
  111643. * Defines supported buttons for DualShock compatible gamepads
  111644. */
  111645. export enum DualShockButton {
  111646. /** Cross */
  111647. Cross = 0,
  111648. /** Circle */
  111649. Circle = 1,
  111650. /** Square */
  111651. Square = 2,
  111652. /** Triangle */
  111653. Triangle = 3,
  111654. /** Options */
  111655. Options = 4,
  111656. /** Share */
  111657. Share = 5,
  111658. /** L1 */
  111659. L1 = 6,
  111660. /** R1 */
  111661. R1 = 7,
  111662. /** Left stick */
  111663. LeftStick = 8,
  111664. /** Right stick */
  111665. RightStick = 9
  111666. }
  111667. /** Defines values for DualShock DPad */
  111668. export enum DualShockDpad {
  111669. /** Up */
  111670. Up = 0,
  111671. /** Down */
  111672. Down = 1,
  111673. /** Left */
  111674. Left = 2,
  111675. /** Right */
  111676. Right = 3
  111677. }
  111678. /**
  111679. * Defines a DualShock gamepad
  111680. */
  111681. export class DualShockPad extends Gamepad {
  111682. private _leftTrigger;
  111683. private _rightTrigger;
  111684. private _onlefttriggerchanged;
  111685. private _onrighttriggerchanged;
  111686. private _onbuttondown;
  111687. private _onbuttonup;
  111688. private _ondpaddown;
  111689. private _ondpadup;
  111690. /** Observable raised when a button is pressed */
  111691. onButtonDownObservable: Observable<DualShockButton>;
  111692. /** Observable raised when a button is released */
  111693. onButtonUpObservable: Observable<DualShockButton>;
  111694. /** Observable raised when a pad is pressed */
  111695. onPadDownObservable: Observable<DualShockDpad>;
  111696. /** Observable raised when a pad is released */
  111697. onPadUpObservable: Observable<DualShockDpad>;
  111698. private _buttonCross;
  111699. private _buttonCircle;
  111700. private _buttonSquare;
  111701. private _buttonTriangle;
  111702. private _buttonShare;
  111703. private _buttonOptions;
  111704. private _buttonL1;
  111705. private _buttonR1;
  111706. private _buttonLeftStick;
  111707. private _buttonRightStick;
  111708. private _dPadUp;
  111709. private _dPadDown;
  111710. private _dPadLeft;
  111711. private _dPadRight;
  111712. /**
  111713. * Creates a new DualShock gamepad object
  111714. * @param id defines the id of this gamepad
  111715. * @param index defines its index
  111716. * @param gamepad defines the internal HTML gamepad object
  111717. */
  111718. constructor(id: string, index: number, gamepad: any);
  111719. /**
  111720. * Defines the callback to call when left trigger is pressed
  111721. * @param callback defines the callback to use
  111722. */
  111723. onlefttriggerchanged(callback: (value: number) => void): void;
  111724. /**
  111725. * Defines the callback to call when right trigger is pressed
  111726. * @param callback defines the callback to use
  111727. */
  111728. onrighttriggerchanged(callback: (value: number) => void): void;
  111729. /**
  111730. * Gets the left trigger value
  111731. */
  111732. get leftTrigger(): number;
  111733. /**
  111734. * Sets the left trigger value
  111735. */
  111736. set leftTrigger(newValue: number);
  111737. /**
  111738. * Gets the right trigger value
  111739. */
  111740. get rightTrigger(): number;
  111741. /**
  111742. * Sets the right trigger value
  111743. */
  111744. set rightTrigger(newValue: number);
  111745. /**
  111746. * Defines the callback to call when a button is pressed
  111747. * @param callback defines the callback to use
  111748. */
  111749. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111750. /**
  111751. * Defines the callback to call when a button is released
  111752. * @param callback defines the callback to use
  111753. */
  111754. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111755. /**
  111756. * Defines the callback to call when a pad is pressed
  111757. * @param callback defines the callback to use
  111758. */
  111759. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111760. /**
  111761. * Defines the callback to call when a pad is released
  111762. * @param callback defines the callback to use
  111763. */
  111764. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111765. private _setButtonValue;
  111766. private _setDPadValue;
  111767. /**
  111768. * Gets the value of the `Cross` button
  111769. */
  111770. get buttonCross(): number;
  111771. /**
  111772. * Sets the value of the `Cross` button
  111773. */
  111774. set buttonCross(value: number);
  111775. /**
  111776. * Gets the value of the `Circle` button
  111777. */
  111778. get buttonCircle(): number;
  111779. /**
  111780. * Sets the value of the `Circle` button
  111781. */
  111782. set buttonCircle(value: number);
  111783. /**
  111784. * Gets the value of the `Square` button
  111785. */
  111786. get buttonSquare(): number;
  111787. /**
  111788. * Sets the value of the `Square` button
  111789. */
  111790. set buttonSquare(value: number);
  111791. /**
  111792. * Gets the value of the `Triangle` button
  111793. */
  111794. get buttonTriangle(): number;
  111795. /**
  111796. * Sets the value of the `Triangle` button
  111797. */
  111798. set buttonTriangle(value: number);
  111799. /**
  111800. * Gets the value of the `Options` button
  111801. */
  111802. get buttonOptions(): number;
  111803. /**
  111804. * Sets the value of the `Options` button
  111805. */
  111806. set buttonOptions(value: number);
  111807. /**
  111808. * Gets the value of the `Share` button
  111809. */
  111810. get buttonShare(): number;
  111811. /**
  111812. * Sets the value of the `Share` button
  111813. */
  111814. set buttonShare(value: number);
  111815. /**
  111816. * Gets the value of the `L1` button
  111817. */
  111818. get buttonL1(): number;
  111819. /**
  111820. * Sets the value of the `L1` button
  111821. */
  111822. set buttonL1(value: number);
  111823. /**
  111824. * Gets the value of the `R1` button
  111825. */
  111826. get buttonR1(): number;
  111827. /**
  111828. * Sets the value of the `R1` button
  111829. */
  111830. set buttonR1(value: number);
  111831. /**
  111832. * Gets the value of the Left joystick
  111833. */
  111834. get buttonLeftStick(): number;
  111835. /**
  111836. * Sets the value of the Left joystick
  111837. */
  111838. set buttonLeftStick(value: number);
  111839. /**
  111840. * Gets the value of the Right joystick
  111841. */
  111842. get buttonRightStick(): number;
  111843. /**
  111844. * Sets the value of the Right joystick
  111845. */
  111846. set buttonRightStick(value: number);
  111847. /**
  111848. * Gets the value of D-pad up
  111849. */
  111850. get dPadUp(): number;
  111851. /**
  111852. * Sets the value of D-pad up
  111853. */
  111854. set dPadUp(value: number);
  111855. /**
  111856. * Gets the value of D-pad down
  111857. */
  111858. get dPadDown(): number;
  111859. /**
  111860. * Sets the value of D-pad down
  111861. */
  111862. set dPadDown(value: number);
  111863. /**
  111864. * Gets the value of D-pad left
  111865. */
  111866. get dPadLeft(): number;
  111867. /**
  111868. * Sets the value of D-pad left
  111869. */
  111870. set dPadLeft(value: number);
  111871. /**
  111872. * Gets the value of D-pad right
  111873. */
  111874. get dPadRight(): number;
  111875. /**
  111876. * Sets the value of D-pad right
  111877. */
  111878. set dPadRight(value: number);
  111879. /**
  111880. * Force the gamepad to synchronize with device values
  111881. */
  111882. update(): void;
  111883. /**
  111884. * Disposes the gamepad
  111885. */
  111886. dispose(): void;
  111887. }
  111888. }
  111889. declare module BABYLON {
  111890. /**
  111891. * Manager for handling gamepads
  111892. */
  111893. export class GamepadManager {
  111894. private _scene?;
  111895. private _babylonGamepads;
  111896. private _oneGamepadConnected;
  111897. /** @hidden */
  111898. _isMonitoring: boolean;
  111899. private _gamepadEventSupported;
  111900. private _gamepadSupport?;
  111901. /**
  111902. * observable to be triggered when the gamepad controller has been connected
  111903. */
  111904. onGamepadConnectedObservable: Observable<Gamepad>;
  111905. /**
  111906. * observable to be triggered when the gamepad controller has been disconnected
  111907. */
  111908. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111909. private _onGamepadConnectedEvent;
  111910. private _onGamepadDisconnectedEvent;
  111911. /**
  111912. * Initializes the gamepad manager
  111913. * @param _scene BabylonJS scene
  111914. */
  111915. constructor(_scene?: Scene | undefined);
  111916. /**
  111917. * The gamepads in the game pad manager
  111918. */
  111919. get gamepads(): Gamepad[];
  111920. /**
  111921. * Get the gamepad controllers based on type
  111922. * @param type The type of gamepad controller
  111923. * @returns Nullable gamepad
  111924. */
  111925. getGamepadByType(type?: number): Nullable<Gamepad>;
  111926. /**
  111927. * Disposes the gamepad manager
  111928. */
  111929. dispose(): void;
  111930. private _addNewGamepad;
  111931. private _startMonitoringGamepads;
  111932. private _stopMonitoringGamepads;
  111933. /** @hidden */
  111934. _checkGamepadsStatus(): void;
  111935. private _updateGamepadObjects;
  111936. }
  111937. }
  111938. declare module BABYLON {
  111939. interface Scene {
  111940. /** @hidden */
  111941. _gamepadManager: Nullable<GamepadManager>;
  111942. /**
  111943. * Gets the gamepad manager associated with the scene
  111944. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111945. */
  111946. gamepadManager: GamepadManager;
  111947. }
  111948. /**
  111949. * Interface representing a free camera inputs manager
  111950. */
  111951. interface FreeCameraInputsManager {
  111952. /**
  111953. * Adds gamepad input support to the FreeCameraInputsManager.
  111954. * @returns the FreeCameraInputsManager
  111955. */
  111956. addGamepad(): FreeCameraInputsManager;
  111957. }
  111958. /**
  111959. * Interface representing an arc rotate camera inputs manager
  111960. */
  111961. interface ArcRotateCameraInputsManager {
  111962. /**
  111963. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111964. * @returns the camera inputs manager
  111965. */
  111966. addGamepad(): ArcRotateCameraInputsManager;
  111967. }
  111968. /**
  111969. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111970. */
  111971. export class GamepadSystemSceneComponent implements ISceneComponent {
  111972. /**
  111973. * The component name helpfull to identify the component in the list of scene components.
  111974. */
  111975. readonly name: string;
  111976. /**
  111977. * The scene the component belongs to.
  111978. */
  111979. scene: Scene;
  111980. /**
  111981. * Creates a new instance of the component for the given scene
  111982. * @param scene Defines the scene to register the component in
  111983. */
  111984. constructor(scene: Scene);
  111985. /**
  111986. * Registers the component in a given scene
  111987. */
  111988. register(): void;
  111989. /**
  111990. * Rebuilds the elements related to this component in case of
  111991. * context lost for instance.
  111992. */
  111993. rebuild(): void;
  111994. /**
  111995. * Disposes the component and the associated ressources
  111996. */
  111997. dispose(): void;
  111998. private _beforeCameraUpdate;
  111999. }
  112000. }
  112001. declare module BABYLON {
  112002. /**
  112003. * 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,
  112004. * which still works and will still be found in many Playgrounds.
  112005. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112006. */
  112007. export class UniversalCamera extends TouchCamera {
  112008. /**
  112009. * Defines the gamepad rotation sensiblity.
  112010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112011. */
  112012. get gamepadAngularSensibility(): number;
  112013. set gamepadAngularSensibility(value: number);
  112014. /**
  112015. * Defines the gamepad move sensiblity.
  112016. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112017. */
  112018. get gamepadMoveSensibility(): number;
  112019. set gamepadMoveSensibility(value: number);
  112020. /**
  112021. * 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,
  112022. * which still works and will still be found in many Playgrounds.
  112023. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112024. * @param name Define the name of the camera in the scene
  112025. * @param position Define the start position of the camera in the scene
  112026. * @param scene Define the scene the camera belongs to
  112027. */
  112028. constructor(name: string, position: Vector3, scene: Scene);
  112029. /**
  112030. * Gets the current object class name.
  112031. * @return the class name
  112032. */
  112033. getClassName(): string;
  112034. }
  112035. }
  112036. declare module BABYLON {
  112037. /**
  112038. * This represents a FPS type of camera. This is only here for back compat purpose.
  112039. * Please use the UniversalCamera instead as both are identical.
  112040. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112041. */
  112042. export class GamepadCamera extends UniversalCamera {
  112043. /**
  112044. * Instantiates a new Gamepad Camera
  112045. * This represents a FPS type of camera. This is only here for back compat purpose.
  112046. * Please use the UniversalCamera instead as both are identical.
  112047. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112048. * @param name Define the name of the camera in the scene
  112049. * @param position Define the start position of the camera in the scene
  112050. * @param scene Define the scene the camera belongs to
  112051. */
  112052. constructor(name: string, position: Vector3, scene: Scene);
  112053. /**
  112054. * Gets the current object class name.
  112055. * @return the class name
  112056. */
  112057. getClassName(): string;
  112058. }
  112059. }
  112060. declare module BABYLON {
  112061. /** @hidden */
  112062. export var passPixelShader: {
  112063. name: string;
  112064. shader: string;
  112065. };
  112066. }
  112067. declare module BABYLON {
  112068. /** @hidden */
  112069. export var passCubePixelShader: {
  112070. name: string;
  112071. shader: string;
  112072. };
  112073. }
  112074. declare module BABYLON {
  112075. /**
  112076. * PassPostProcess which produces an output the same as it's input
  112077. */
  112078. export class PassPostProcess extends PostProcess {
  112079. /**
  112080. * Creates the PassPostProcess
  112081. * @param name The name of the effect.
  112082. * @param options The required width/height ratio to downsize to before computing the render pass.
  112083. * @param camera The camera to apply the render pass to.
  112084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112085. * @param engine The engine which the post process will be applied. (default: current engine)
  112086. * @param reusable If the post process can be reused on the same frame. (default: false)
  112087. * @param textureType The type of texture to be used when performing the post processing.
  112088. * @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)
  112089. */
  112090. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112091. }
  112092. /**
  112093. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112094. */
  112095. export class PassCubePostProcess extends PostProcess {
  112096. private _face;
  112097. /**
  112098. * Gets or sets the cube face to display.
  112099. * * 0 is +X
  112100. * * 1 is -X
  112101. * * 2 is +Y
  112102. * * 3 is -Y
  112103. * * 4 is +Z
  112104. * * 5 is -Z
  112105. */
  112106. get face(): number;
  112107. set face(value: number);
  112108. /**
  112109. * Creates the PassCubePostProcess
  112110. * @param name The name of the effect.
  112111. * @param options The required width/height ratio to downsize to before computing the render pass.
  112112. * @param camera The camera to apply the render pass to.
  112113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112114. * @param engine The engine which the post process will be applied. (default: current engine)
  112115. * @param reusable If the post process can be reused on the same frame. (default: false)
  112116. * @param textureType The type of texture to be used when performing the post processing.
  112117. * @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)
  112118. */
  112119. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112120. }
  112121. }
  112122. declare module BABYLON {
  112123. /** @hidden */
  112124. export var anaglyphPixelShader: {
  112125. name: string;
  112126. shader: string;
  112127. };
  112128. }
  112129. declare module BABYLON {
  112130. /**
  112131. * Postprocess used to generate anaglyphic rendering
  112132. */
  112133. export class AnaglyphPostProcess extends PostProcess {
  112134. private _passedProcess;
  112135. /**
  112136. * Creates a new AnaglyphPostProcess
  112137. * @param name defines postprocess name
  112138. * @param options defines creation options or target ratio scale
  112139. * @param rigCameras defines cameras using this postprocess
  112140. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112141. * @param engine defines hosting engine
  112142. * @param reusable defines if the postprocess will be reused multiple times per frame
  112143. */
  112144. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112145. }
  112146. }
  112147. declare module BABYLON {
  112148. /**
  112149. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112150. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112151. */
  112152. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112153. /**
  112154. * Creates a new AnaglyphArcRotateCamera
  112155. * @param name defines camera name
  112156. * @param alpha defines alpha angle (in radians)
  112157. * @param beta defines beta angle (in radians)
  112158. * @param radius defines radius
  112159. * @param target defines camera target
  112160. * @param interaxialDistance defines distance between each color axis
  112161. * @param scene defines the hosting scene
  112162. */
  112163. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112164. /**
  112165. * Gets camera class name
  112166. * @returns AnaglyphArcRotateCamera
  112167. */
  112168. getClassName(): string;
  112169. }
  112170. }
  112171. declare module BABYLON {
  112172. /**
  112173. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112174. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112175. */
  112176. export class AnaglyphFreeCamera extends FreeCamera {
  112177. /**
  112178. * Creates a new AnaglyphFreeCamera
  112179. * @param name defines camera name
  112180. * @param position defines initial position
  112181. * @param interaxialDistance defines distance between each color axis
  112182. * @param scene defines the hosting scene
  112183. */
  112184. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112185. /**
  112186. * Gets camera class name
  112187. * @returns AnaglyphFreeCamera
  112188. */
  112189. getClassName(): string;
  112190. }
  112191. }
  112192. declare module BABYLON {
  112193. /**
  112194. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112196. */
  112197. export class AnaglyphGamepadCamera extends GamepadCamera {
  112198. /**
  112199. * Creates a new AnaglyphGamepadCamera
  112200. * @param name defines camera name
  112201. * @param position defines initial position
  112202. * @param interaxialDistance defines distance between each color axis
  112203. * @param scene defines the hosting scene
  112204. */
  112205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112206. /**
  112207. * Gets camera class name
  112208. * @returns AnaglyphGamepadCamera
  112209. */
  112210. getClassName(): string;
  112211. }
  112212. }
  112213. declare module BABYLON {
  112214. /**
  112215. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112216. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112217. */
  112218. export class AnaglyphUniversalCamera extends UniversalCamera {
  112219. /**
  112220. * Creates a new AnaglyphUniversalCamera
  112221. * @param name defines camera name
  112222. * @param position defines initial position
  112223. * @param interaxialDistance defines distance between each color axis
  112224. * @param scene defines the hosting scene
  112225. */
  112226. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112227. /**
  112228. * Gets camera class name
  112229. * @returns AnaglyphUniversalCamera
  112230. */
  112231. getClassName(): string;
  112232. }
  112233. }
  112234. declare module BABYLON {
  112235. /** @hidden */
  112236. export var stereoscopicInterlacePixelShader: {
  112237. name: string;
  112238. shader: string;
  112239. };
  112240. }
  112241. declare module BABYLON {
  112242. /**
  112243. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112244. */
  112245. export class StereoscopicInterlacePostProcess extends PostProcess {
  112246. private _stepSize;
  112247. private _passedProcess;
  112248. /**
  112249. * Initializes a StereoscopicInterlacePostProcess
  112250. * @param name The name of the effect.
  112251. * @param rigCameras The rig cameras to be appled to the post process
  112252. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112254. * @param engine The engine which the post process will be applied. (default: current engine)
  112255. * @param reusable If the post process can be reused on the same frame. (default: false)
  112256. */
  112257. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112258. }
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112263. * @see http://doc.babylonjs.com/features/cameras
  112264. */
  112265. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112266. /**
  112267. * Creates a new StereoscopicArcRotateCamera
  112268. * @param name defines camera name
  112269. * @param alpha defines alpha angle (in radians)
  112270. * @param beta defines beta angle (in radians)
  112271. * @param radius defines radius
  112272. * @param target defines camera target
  112273. * @param interaxialDistance defines distance between each color axis
  112274. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112275. * @param scene defines the hosting scene
  112276. */
  112277. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112278. /**
  112279. * Gets camera class name
  112280. * @returns StereoscopicArcRotateCamera
  112281. */
  112282. getClassName(): string;
  112283. }
  112284. }
  112285. declare module BABYLON {
  112286. /**
  112287. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112288. * @see http://doc.babylonjs.com/features/cameras
  112289. */
  112290. export class StereoscopicFreeCamera extends FreeCamera {
  112291. /**
  112292. * Creates a new StereoscopicFreeCamera
  112293. * @param name defines camera name
  112294. * @param position defines initial position
  112295. * @param interaxialDistance defines distance between each color axis
  112296. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112297. * @param scene defines the hosting scene
  112298. */
  112299. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112300. /**
  112301. * Gets camera class name
  112302. * @returns StereoscopicFreeCamera
  112303. */
  112304. getClassName(): string;
  112305. }
  112306. }
  112307. declare module BABYLON {
  112308. /**
  112309. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112310. * @see http://doc.babylonjs.com/features/cameras
  112311. */
  112312. export class StereoscopicGamepadCamera extends GamepadCamera {
  112313. /**
  112314. * Creates a new StereoscopicGamepadCamera
  112315. * @param name defines camera name
  112316. * @param position defines initial position
  112317. * @param interaxialDistance defines distance between each color axis
  112318. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112319. * @param scene defines the hosting scene
  112320. */
  112321. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112322. /**
  112323. * Gets camera class name
  112324. * @returns StereoscopicGamepadCamera
  112325. */
  112326. getClassName(): string;
  112327. }
  112328. }
  112329. declare module BABYLON {
  112330. /**
  112331. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112332. * @see http://doc.babylonjs.com/features/cameras
  112333. */
  112334. export class StereoscopicUniversalCamera extends UniversalCamera {
  112335. /**
  112336. * Creates a new StereoscopicUniversalCamera
  112337. * @param name defines camera name
  112338. * @param position defines initial position
  112339. * @param interaxialDistance defines distance between each color axis
  112340. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112341. * @param scene defines the hosting scene
  112342. */
  112343. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112344. /**
  112345. * Gets camera class name
  112346. * @returns StereoscopicUniversalCamera
  112347. */
  112348. getClassName(): string;
  112349. }
  112350. }
  112351. declare module BABYLON {
  112352. /**
  112353. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112354. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112355. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112356. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112357. */
  112358. export class VirtualJoysticksCamera extends FreeCamera {
  112359. /**
  112360. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112363. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112364. * @param name Define the name of the camera in the scene
  112365. * @param position Define the start position of the camera in the scene
  112366. * @param scene Define the scene the camera belongs to
  112367. */
  112368. constructor(name: string, position: Vector3, scene: Scene);
  112369. /**
  112370. * Gets the current object class name.
  112371. * @return the class name
  112372. */
  112373. getClassName(): string;
  112374. }
  112375. }
  112376. declare module BABYLON {
  112377. /**
  112378. * This represents all the required metrics to create a VR camera.
  112379. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112380. */
  112381. export class VRCameraMetrics {
  112382. /**
  112383. * Define the horizontal resolution off the screen.
  112384. */
  112385. hResolution: number;
  112386. /**
  112387. * Define the vertical resolution off the screen.
  112388. */
  112389. vResolution: number;
  112390. /**
  112391. * Define the horizontal screen size.
  112392. */
  112393. hScreenSize: number;
  112394. /**
  112395. * Define the vertical screen size.
  112396. */
  112397. vScreenSize: number;
  112398. /**
  112399. * Define the vertical screen center position.
  112400. */
  112401. vScreenCenter: number;
  112402. /**
  112403. * Define the distance of the eyes to the screen.
  112404. */
  112405. eyeToScreenDistance: number;
  112406. /**
  112407. * Define the distance between both lenses
  112408. */
  112409. lensSeparationDistance: number;
  112410. /**
  112411. * Define the distance between both viewer's eyes.
  112412. */
  112413. interpupillaryDistance: number;
  112414. /**
  112415. * Define the distortion factor of the VR postprocess.
  112416. * Please, touch with care.
  112417. */
  112418. distortionK: number[];
  112419. /**
  112420. * Define the chromatic aberration correction factors for the VR post process.
  112421. */
  112422. chromaAbCorrection: number[];
  112423. /**
  112424. * Define the scale factor of the post process.
  112425. * The smaller the better but the slower.
  112426. */
  112427. postProcessScaleFactor: number;
  112428. /**
  112429. * Define an offset for the lens center.
  112430. */
  112431. lensCenterOffset: number;
  112432. /**
  112433. * Define if the current vr camera should compensate the distortion of the lense or not.
  112434. */
  112435. compensateDistortion: boolean;
  112436. /**
  112437. * Defines if multiview should be enabled when rendering (Default: false)
  112438. */
  112439. multiviewEnabled: boolean;
  112440. /**
  112441. * Gets the rendering aspect ratio based on the provided resolutions.
  112442. */
  112443. get aspectRatio(): number;
  112444. /**
  112445. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112446. */
  112447. get aspectRatioFov(): number;
  112448. /**
  112449. * @hidden
  112450. */
  112451. get leftHMatrix(): Matrix;
  112452. /**
  112453. * @hidden
  112454. */
  112455. get rightHMatrix(): Matrix;
  112456. /**
  112457. * @hidden
  112458. */
  112459. get leftPreViewMatrix(): Matrix;
  112460. /**
  112461. * @hidden
  112462. */
  112463. get rightPreViewMatrix(): Matrix;
  112464. /**
  112465. * Get the default VRMetrics based on the most generic setup.
  112466. * @returns the default vr metrics
  112467. */
  112468. static GetDefault(): VRCameraMetrics;
  112469. }
  112470. }
  112471. declare module BABYLON {
  112472. /** @hidden */
  112473. export var vrDistortionCorrectionPixelShader: {
  112474. name: string;
  112475. shader: string;
  112476. };
  112477. }
  112478. declare module BABYLON {
  112479. /**
  112480. * VRDistortionCorrectionPostProcess used for mobile VR
  112481. */
  112482. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112483. private _isRightEye;
  112484. private _distortionFactors;
  112485. private _postProcessScaleFactor;
  112486. private _lensCenterOffset;
  112487. private _scaleIn;
  112488. private _scaleFactor;
  112489. private _lensCenter;
  112490. /**
  112491. * Initializes the VRDistortionCorrectionPostProcess
  112492. * @param name The name of the effect.
  112493. * @param camera The camera to apply the render pass to.
  112494. * @param isRightEye If this is for the right eye distortion
  112495. * @param vrMetrics All the required metrics for the VR camera
  112496. */
  112497. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112498. }
  112499. }
  112500. declare module BABYLON {
  112501. /**
  112502. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112504. */
  112505. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112506. /**
  112507. * Creates a new VRDeviceOrientationArcRotateCamera
  112508. * @param name defines camera name
  112509. * @param alpha defines the camera rotation along the logitudinal axis
  112510. * @param beta defines the camera rotation along the latitudinal axis
  112511. * @param radius defines the camera distance from its target
  112512. * @param target defines the camera target
  112513. * @param scene defines the scene the camera belongs to
  112514. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112515. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112516. */
  112517. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112518. /**
  112519. * Gets camera class name
  112520. * @returns VRDeviceOrientationArcRotateCamera
  112521. */
  112522. getClassName(): string;
  112523. }
  112524. }
  112525. declare module BABYLON {
  112526. /**
  112527. * Camera used to simulate VR rendering (based on FreeCamera)
  112528. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112529. */
  112530. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112531. /**
  112532. * Creates a new VRDeviceOrientationFreeCamera
  112533. * @param name defines camera name
  112534. * @param position defines the start position of the camera
  112535. * @param scene defines the scene the camera belongs to
  112536. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112537. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112538. */
  112539. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112540. /**
  112541. * Gets camera class name
  112542. * @returns VRDeviceOrientationFreeCamera
  112543. */
  112544. getClassName(): string;
  112545. }
  112546. }
  112547. declare module BABYLON {
  112548. /**
  112549. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112550. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112551. */
  112552. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112553. /**
  112554. * Creates a new VRDeviceOrientationGamepadCamera
  112555. * @param name defines camera name
  112556. * @param position defines the start position of the camera
  112557. * @param scene defines the scene the camera belongs to
  112558. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112559. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112560. */
  112561. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112562. /**
  112563. * Gets camera class name
  112564. * @returns VRDeviceOrientationGamepadCamera
  112565. */
  112566. getClassName(): string;
  112567. }
  112568. }
  112569. declare module BABYLON {
  112570. /** @hidden */
  112571. export var imageProcessingPixelShader: {
  112572. name: string;
  112573. shader: string;
  112574. };
  112575. }
  112576. declare module BABYLON {
  112577. /**
  112578. * ImageProcessingPostProcess
  112579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112580. */
  112581. export class ImageProcessingPostProcess extends PostProcess {
  112582. /**
  112583. * Default configuration related to image processing available in the PBR Material.
  112584. */
  112585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112586. /**
  112587. * Gets the image processing configuration used either in this material.
  112588. */
  112589. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112590. /**
  112591. * Sets the Default image processing configuration used either in the this material.
  112592. *
  112593. * If sets to null, the scene one is in use.
  112594. */
  112595. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112596. /**
  112597. * Keep track of the image processing observer to allow dispose and replace.
  112598. */
  112599. private _imageProcessingObserver;
  112600. /**
  112601. * Attaches a new image processing configuration to the PBR Material.
  112602. * @param configuration
  112603. */
  112604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112605. /**
  112606. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112607. */
  112608. get colorCurves(): Nullable<ColorCurves>;
  112609. /**
  112610. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112611. */
  112612. set colorCurves(value: Nullable<ColorCurves>);
  112613. /**
  112614. * Gets wether the color curves effect is enabled.
  112615. */
  112616. get colorCurvesEnabled(): boolean;
  112617. /**
  112618. * Sets wether the color curves effect is enabled.
  112619. */
  112620. set colorCurvesEnabled(value: boolean);
  112621. /**
  112622. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112623. */
  112624. get colorGradingTexture(): Nullable<BaseTexture>;
  112625. /**
  112626. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112627. */
  112628. set colorGradingTexture(value: Nullable<BaseTexture>);
  112629. /**
  112630. * Gets wether the color grading effect is enabled.
  112631. */
  112632. get colorGradingEnabled(): boolean;
  112633. /**
  112634. * Gets wether the color grading effect is enabled.
  112635. */
  112636. set colorGradingEnabled(value: boolean);
  112637. /**
  112638. * Gets exposure used in the effect.
  112639. */
  112640. get exposure(): number;
  112641. /**
  112642. * Sets exposure used in the effect.
  112643. */
  112644. set exposure(value: number);
  112645. /**
  112646. * Gets wether tonemapping is enabled or not.
  112647. */
  112648. get toneMappingEnabled(): boolean;
  112649. /**
  112650. * Sets wether tonemapping is enabled or not
  112651. */
  112652. set toneMappingEnabled(value: boolean);
  112653. /**
  112654. * Gets the type of tone mapping effect.
  112655. */
  112656. get toneMappingType(): number;
  112657. /**
  112658. * Sets the type of tone mapping effect.
  112659. */
  112660. set toneMappingType(value: number);
  112661. /**
  112662. * Gets contrast used in the effect.
  112663. */
  112664. get contrast(): number;
  112665. /**
  112666. * Sets contrast used in the effect.
  112667. */
  112668. set contrast(value: number);
  112669. /**
  112670. * Gets Vignette stretch size.
  112671. */
  112672. get vignetteStretch(): number;
  112673. /**
  112674. * Sets Vignette stretch size.
  112675. */
  112676. set vignetteStretch(value: number);
  112677. /**
  112678. * Gets Vignette centre X Offset.
  112679. */
  112680. get vignetteCentreX(): number;
  112681. /**
  112682. * Sets Vignette centre X Offset.
  112683. */
  112684. set vignetteCentreX(value: number);
  112685. /**
  112686. * Gets Vignette centre Y Offset.
  112687. */
  112688. get vignetteCentreY(): number;
  112689. /**
  112690. * Sets Vignette centre Y Offset.
  112691. */
  112692. set vignetteCentreY(value: number);
  112693. /**
  112694. * Gets Vignette weight or intensity of the vignette effect.
  112695. */
  112696. get vignetteWeight(): number;
  112697. /**
  112698. * Sets Vignette weight or intensity of the vignette effect.
  112699. */
  112700. set vignetteWeight(value: number);
  112701. /**
  112702. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112703. * if vignetteEnabled is set to true.
  112704. */
  112705. get vignetteColor(): Color4;
  112706. /**
  112707. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112708. * if vignetteEnabled is set to true.
  112709. */
  112710. set vignetteColor(value: Color4);
  112711. /**
  112712. * Gets Camera field of view used by the Vignette effect.
  112713. */
  112714. get vignetteCameraFov(): number;
  112715. /**
  112716. * Sets Camera field of view used by the Vignette effect.
  112717. */
  112718. set vignetteCameraFov(value: number);
  112719. /**
  112720. * Gets the vignette blend mode allowing different kind of effect.
  112721. */
  112722. get vignetteBlendMode(): number;
  112723. /**
  112724. * Sets the vignette blend mode allowing different kind of effect.
  112725. */
  112726. set vignetteBlendMode(value: number);
  112727. /**
  112728. * Gets wether the vignette effect is enabled.
  112729. */
  112730. get vignetteEnabled(): boolean;
  112731. /**
  112732. * Sets wether the vignette effect is enabled.
  112733. */
  112734. set vignetteEnabled(value: boolean);
  112735. private _fromLinearSpace;
  112736. /**
  112737. * Gets wether the input of the processing is in Gamma or Linear Space.
  112738. */
  112739. get fromLinearSpace(): boolean;
  112740. /**
  112741. * Sets wether the input of the processing is in Gamma or Linear Space.
  112742. */
  112743. set fromLinearSpace(value: boolean);
  112744. /**
  112745. * Defines cache preventing GC.
  112746. */
  112747. private _defines;
  112748. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112749. /**
  112750. * "ImageProcessingPostProcess"
  112751. * @returns "ImageProcessingPostProcess"
  112752. */
  112753. getClassName(): string;
  112754. protected _updateParameters(): void;
  112755. dispose(camera?: Camera): void;
  112756. }
  112757. }
  112758. declare module BABYLON {
  112759. /**
  112760. * Class containing static functions to help procedurally build meshes
  112761. */
  112762. export class GroundBuilder {
  112763. /**
  112764. * Creates a ground mesh
  112765. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112766. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112768. * @param name defines the name of the mesh
  112769. * @param options defines the options used to create the mesh
  112770. * @param scene defines the hosting scene
  112771. * @returns the ground mesh
  112772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112773. */
  112774. static CreateGround(name: string, options: {
  112775. width?: number;
  112776. height?: number;
  112777. subdivisions?: number;
  112778. subdivisionsX?: number;
  112779. subdivisionsY?: number;
  112780. updatable?: boolean;
  112781. }, scene: any): Mesh;
  112782. /**
  112783. * Creates a tiled ground mesh
  112784. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112785. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112786. * * 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
  112787. * * 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
  112788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112789. * @param name defines the name of the mesh
  112790. * @param options defines the options used to create the mesh
  112791. * @param scene defines the hosting scene
  112792. * @returns the tiled ground mesh
  112793. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112794. */
  112795. static CreateTiledGround(name: string, options: {
  112796. xmin: number;
  112797. zmin: number;
  112798. xmax: number;
  112799. zmax: number;
  112800. subdivisions?: {
  112801. w: number;
  112802. h: number;
  112803. };
  112804. precision?: {
  112805. w: number;
  112806. h: number;
  112807. };
  112808. updatable?: boolean;
  112809. }, scene?: Nullable<Scene>): Mesh;
  112810. /**
  112811. * Creates a ground mesh from a height map
  112812. * * The parameter `url` sets the URL of the height map image resource.
  112813. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112814. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112815. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112816. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112817. * * 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.
  112818. * * 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).
  112819. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112821. * @param name defines the name of the mesh
  112822. * @param url defines the url to the height map
  112823. * @param options defines the options used to create the mesh
  112824. * @param scene defines the hosting scene
  112825. * @returns the ground mesh
  112826. * @see https://doc.babylonjs.com/babylon101/height_map
  112827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112828. */
  112829. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112830. width?: number;
  112831. height?: number;
  112832. subdivisions?: number;
  112833. minHeight?: number;
  112834. maxHeight?: number;
  112835. colorFilter?: Color3;
  112836. alphaFilter?: number;
  112837. updatable?: boolean;
  112838. onReady?: (mesh: GroundMesh) => void;
  112839. }, scene?: Nullable<Scene>): GroundMesh;
  112840. }
  112841. }
  112842. declare module BABYLON {
  112843. /**
  112844. * Class containing static functions to help procedurally build meshes
  112845. */
  112846. export class TorusBuilder {
  112847. /**
  112848. * Creates a torus mesh
  112849. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112850. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112851. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112855. * @param name defines the name of the mesh
  112856. * @param options defines the options used to create the mesh
  112857. * @param scene defines the hosting scene
  112858. * @returns the torus mesh
  112859. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112860. */
  112861. static CreateTorus(name: string, options: {
  112862. diameter?: number;
  112863. thickness?: number;
  112864. tessellation?: number;
  112865. updatable?: boolean;
  112866. sideOrientation?: number;
  112867. frontUVs?: Vector4;
  112868. backUVs?: Vector4;
  112869. }, scene: any): Mesh;
  112870. }
  112871. }
  112872. declare module BABYLON {
  112873. /**
  112874. * Class containing static functions to help procedurally build meshes
  112875. */
  112876. export class CylinderBuilder {
  112877. /**
  112878. * Creates a cylinder or a cone mesh
  112879. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112880. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112881. * * 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.
  112882. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112883. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112884. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112885. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112886. * * 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).
  112887. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112888. * * 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).
  112889. * * 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
  112890. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112891. * * 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
  112892. * * 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.
  112893. * * If `enclose` is false, a ring surface is one element.
  112894. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112895. * * 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
  112896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112899. * @param name defines the name of the mesh
  112900. * @param options defines the options used to create the mesh
  112901. * @param scene defines the hosting scene
  112902. * @returns the cylinder mesh
  112903. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112904. */
  112905. static CreateCylinder(name: string, options: {
  112906. height?: number;
  112907. diameterTop?: number;
  112908. diameterBottom?: number;
  112909. diameter?: number;
  112910. tessellation?: number;
  112911. subdivisions?: number;
  112912. arc?: number;
  112913. faceColors?: Color4[];
  112914. faceUV?: Vector4[];
  112915. updatable?: boolean;
  112916. hasRings?: boolean;
  112917. enclose?: boolean;
  112918. cap?: number;
  112919. sideOrientation?: number;
  112920. frontUVs?: Vector4;
  112921. backUVs?: Vector4;
  112922. }, scene: any): Mesh;
  112923. }
  112924. }
  112925. declare module BABYLON {
  112926. /**
  112927. * States of the webXR experience
  112928. */
  112929. export enum WebXRState {
  112930. /**
  112931. * Transitioning to being in XR mode
  112932. */
  112933. ENTERING_XR = 0,
  112934. /**
  112935. * Transitioning to non XR mode
  112936. */
  112937. EXITING_XR = 1,
  112938. /**
  112939. * In XR mode and presenting
  112940. */
  112941. IN_XR = 2,
  112942. /**
  112943. * Not entered XR mode
  112944. */
  112945. NOT_IN_XR = 3
  112946. }
  112947. /**
  112948. * Abstraction of the XR render target
  112949. */
  112950. export interface WebXRRenderTarget extends IDisposable {
  112951. /**
  112952. * xrpresent context of the canvas which can be used to display/mirror xr content
  112953. */
  112954. canvasContext: WebGLRenderingContext;
  112955. /**
  112956. * xr layer for the canvas
  112957. */
  112958. xrLayer: Nullable<XRWebGLLayer>;
  112959. /**
  112960. * Initializes the xr layer for the session
  112961. * @param xrSession xr session
  112962. * @returns a promise that will resolve once the XR Layer has been created
  112963. */
  112964. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112965. }
  112966. }
  112967. declare module BABYLON {
  112968. /**
  112969. * COnfiguration object for WebXR output canvas
  112970. */
  112971. export class WebXRManagedOutputCanvasOptions {
  112972. /**
  112973. * Options for this XR Layer output
  112974. */
  112975. canvasOptions: XRWebGLLayerOptions;
  112976. /**
  112977. * CSS styling for a newly created canvas (if not provided)
  112978. */
  112979. newCanvasCssStyle?: string;
  112980. /**
  112981. * Get the default values of the configuration object
  112982. * @returns default values of this configuration object
  112983. */
  112984. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112985. }
  112986. /**
  112987. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112988. */
  112989. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112990. private configuration;
  112991. private _engine;
  112992. private _canvas;
  112993. /**
  112994. * xrpresent context of the canvas which can be used to display/mirror xr content
  112995. */
  112996. canvasContext: WebGLRenderingContext;
  112997. /**
  112998. * xr layer for the canvas
  112999. */
  113000. xrLayer: Nullable<XRWebGLLayer>;
  113001. /**
  113002. * Initializes the xr layer for the session
  113003. * @param xrSession xr session
  113004. * @returns a promise that will resolve once the XR Layer has been created
  113005. */
  113006. initializeXRLayerAsync(xrSession: any): any;
  113007. /**
  113008. * Initializes the canvas to be added/removed upon entering/exiting xr
  113009. * @param engine the Babylon engine
  113010. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  113011. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  113012. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  113013. */
  113014. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  113015. /**
  113016. * Disposes of the object
  113017. */
  113018. dispose(): void;
  113019. private _setManagedOutputCanvas;
  113020. private _addCanvas;
  113021. private _removeCanvas;
  113022. }
  113023. }
  113024. declare module BABYLON {
  113025. /**
  113026. * Manages an XRSession to work with Babylon's engine
  113027. * @see https://doc.babylonjs.com/how_to/webxr
  113028. */
  113029. export class WebXRSessionManager implements IDisposable {
  113030. /** The scene which the session should be created for */
  113031. scene: Scene;
  113032. /**
  113033. * Fires every time a new xrFrame arrives which can be used to update the camera
  113034. */
  113035. onXRFrameObservable: Observable<XRFrame>;
  113036. /**
  113037. * Fires when the xr session is ended either by the device or manually done
  113038. */
  113039. onXRSessionEnded: Observable<any>;
  113040. /**
  113041. * Fires when the xr session is ended either by the device or manually done
  113042. */
  113043. onXRSessionInit: Observable<XRSession>;
  113044. /**
  113045. * Underlying xr session
  113046. */
  113047. session: XRSession;
  113048. /**
  113049. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  113050. * or get the offset the player is currently at.
  113051. */
  113052. viewerReferenceSpace: XRReferenceSpace;
  113053. /**
  113054. * The current reference space used in this session. This reference space can constantly change!
  113055. * It is mainly used to offset the camera's position.
  113056. */
  113057. referenceSpace: XRReferenceSpace;
  113058. /**
  113059. * The base reference space from which the session started. good if you want to reset your
  113060. * reference space
  113061. */
  113062. baseReferenceSpace: XRReferenceSpace;
  113063. /**
  113064. * Used just in case of a failure to initialize an immersive session.
  113065. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  113066. */
  113067. defaultHeightCompensation: number;
  113068. /**
  113069. * Current XR frame
  113070. */
  113071. currentFrame: Nullable<XRFrame>;
  113072. /** WebXR timestamp updated every frame */
  113073. currentTimestamp: number;
  113074. private _xrNavigator;
  113075. private baseLayer;
  113076. private _rttProvider;
  113077. private _sessionEnded;
  113078. /**
  113079. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113080. * @param scene The scene which the session should be created for
  113081. */
  113082. constructor(
  113083. /** The scene which the session should be created for */
  113084. scene: Scene);
  113085. /**
  113086. * Initializes the manager
  113087. * After initialization enterXR can be called to start an XR session
  113088. * @returns Promise which resolves after it is initialized
  113089. */
  113090. initializeAsync(): Promise<void>;
  113091. /**
  113092. * Initializes an xr session
  113093. * @param xrSessionMode mode to initialize
  113094. * @param optionalFeatures defines optional values to pass to the session builder
  113095. * @returns a promise which will resolve once the session has been initialized
  113096. */
  113097. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113098. /**
  113099. * Sets the reference space on the xr session
  113100. * @param referenceSpace space to set
  113101. * @returns a promise that will resolve once the reference space has been set
  113102. */
  113103. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113104. /**
  113105. * Updates the render state of the session
  113106. * @param state state to set
  113107. * @returns a promise that resolves once the render state has been updated
  113108. */
  113109. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113110. /**
  113111. * Starts rendering to the xr layer
  113112. * @returns a promise that will resolve once rendering has started
  113113. */
  113114. startRenderingToXRAsync(): Promise<void>;
  113115. /**
  113116. * Gets the correct render target texture to be rendered this frame for this eye
  113117. * @param eye the eye for which to get the render target
  113118. * @returns the render target for the specified eye
  113119. */
  113120. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113121. /**
  113122. * Stops the xrSession and restores the renderloop
  113123. * @returns Promise which resolves after it exits XR
  113124. */
  113125. exitXRAsync(): Promise<void>;
  113126. /**
  113127. * Checks if a session would be supported for the creation options specified
  113128. * @param sessionMode session mode to check if supported eg. immersive-vr
  113129. * @returns true if supported
  113130. */
  113131. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113132. /**
  113133. * Creates a WebXRRenderTarget object for the XR session
  113134. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113135. * @param options optional options to provide when creating a new render target
  113136. * @returns a WebXR render target to which the session can render
  113137. */
  113138. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113139. /**
  113140. * @hidden
  113141. * Converts the render layer of xrSession to a render target
  113142. * @param session session to create render target for
  113143. * @param scene scene the new render target should be created for
  113144. * @param baseLayer the webgl layer to create the render target for
  113145. */
  113146. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113147. /**
  113148. * Disposes of the session manager
  113149. */
  113150. dispose(): void;
  113151. /**
  113152. * Gets a promise returning true when fullfiled if the given session mode is supported
  113153. * @param sessionMode defines the session to test
  113154. * @returns a promise
  113155. */
  113156. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113157. }
  113158. }
  113159. declare module BABYLON {
  113160. /**
  113161. * WebXR Camera which holds the views for the xrSession
  113162. * @see https://doc.babylonjs.com/how_to/webxr
  113163. */
  113164. export class WebXRCamera extends FreeCamera {
  113165. private _xrSessionManager;
  113166. /**
  113167. * Is the camera in debug mode. Used when using an emulator
  113168. */
  113169. debugMode: boolean;
  113170. private _firstFrame;
  113171. private _referencedPosition;
  113172. private _referenceQuaternion;
  113173. private _xrInvPositionCache;
  113174. private _xrInvQuaternionCache;
  113175. /**
  113176. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113177. * @param name the name of the camera
  113178. * @param scene the scene to add the camera to
  113179. */
  113180. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  113181. private _updateNumberOfRigCameras;
  113182. /** @hidden */
  113183. _updateForDualEyeDebugging(): void;
  113184. /**
  113185. * Updates the cameras position from the current pose information of the XR session
  113186. * @param xrSessionManager the session containing pose information
  113187. */
  113188. update(): void;
  113189. private _updateReferenceSpace;
  113190. private _updateReferenceSpaceOffset;
  113191. private _updateFromXRSession;
  113192. }
  113193. }
  113194. declare module BABYLON {
  113195. /**
  113196. * Defining the interface required for a (webxr) feature
  113197. */
  113198. export interface IWebXRFeature extends IDisposable {
  113199. /**
  113200. * Attach the feature to the session
  113201. * Will usually be called by the features manager
  113202. *
  113203. * @returns true if successful.
  113204. */
  113205. attach(): boolean;
  113206. /**
  113207. * Detach the feature from the session
  113208. * Will usually be called by the features manager
  113209. *
  113210. * @returns true if successful.
  113211. */
  113212. detach(): boolean;
  113213. }
  113214. /**
  113215. * Defining the constructor of a feature. Used to register the modules.
  113216. */
  113217. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113218. /**
  113219. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113220. * It is mainly used in AR sessions.
  113221. *
  113222. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113223. */
  113224. export class WebXRFeaturesManager implements IDisposable {
  113225. private _xrSessionManager;
  113226. private static readonly _AvailableFeatures;
  113227. /**
  113228. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113229. * Mainly used internally.
  113230. *
  113231. * @param featureName the name of the feature to register
  113232. * @param constructorFunction the function used to construct the module
  113233. * @param version the (babylon) version of the module
  113234. * @param stable is that a stable version of this module
  113235. */
  113236. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113237. /**
  113238. * Returns a constructor of a specific feature.
  113239. *
  113240. * @param featureName the name of the feature to construct
  113241. * @param version the version of the feature to load
  113242. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113243. * @param options optional options provided to the module.
  113244. * @returns a function that, when called, will return a new instance of this feature
  113245. */
  113246. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113247. /**
  113248. * Return the latest unstable version of this feature
  113249. * @param featureName the name of the feature to search
  113250. * @returns the version number. if not found will return -1
  113251. */
  113252. static GetLatestVersionOfFeature(featureName: string): number;
  113253. /**
  113254. * Return the latest stable version of this feature
  113255. * @param featureName the name of the feature to search
  113256. * @returns the version number. if not found will return -1
  113257. */
  113258. static GetStableVersionOfFeature(featureName: string): number;
  113259. /**
  113260. * Can be used to return the list of features currently registered
  113261. *
  113262. * @returns an Array of available features
  113263. */
  113264. static GetAvailableFeatures(): string[];
  113265. /**
  113266. * Gets the versions available for a specific feature
  113267. * @param featureName the name of the feature
  113268. * @returns an array with the available versions
  113269. */
  113270. static GetAvailableVersions(featureName: string): string[];
  113271. private _features;
  113272. /**
  113273. * constructs a new features manages.
  113274. *
  113275. * @param _xrSessionManager an instance of WebXRSessionManager
  113276. */
  113277. constructor(_xrSessionManager: WebXRSessionManager);
  113278. /**
  113279. * 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.
  113280. *
  113281. * @param featureName the name of the feature to load or the class of the feature
  113282. * @param version optional version to load. if not provided the latest version will be enabled
  113283. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113284. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113285. * @returns a new constructed feature or throws an error if feature not found.
  113286. */
  113287. enableFeature(featureName: string | {
  113288. Name: string;
  113289. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113290. /**
  113291. * Used to disable an already-enabled feature
  113292. * @param featureName the feature to disable
  113293. * @returns true if disable was successful
  113294. */
  113295. disableFeature(featureName: string | {
  113296. Name: string;
  113297. }): boolean;
  113298. /**
  113299. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113300. * Can be used during a session to start a feature
  113301. * @param featureName the name of feature to attach
  113302. */
  113303. attachFeature(featureName: string): void;
  113304. /**
  113305. * Can be used inside a session or when the session ends to detach a specific feature
  113306. * @param featureName the name of the feature to detach
  113307. */
  113308. detachFeature(featureName: string): void;
  113309. /**
  113310. * Get the list of enabled features
  113311. * @returns an array of enabled features
  113312. */
  113313. getEnabledFeatures(): string[];
  113314. /**
  113315. * get the implementation of an enabled feature.
  113316. * @param featureName the name of the feature to load
  113317. * @returns the feature class, if found
  113318. */
  113319. getEnabledFeature(featureName: string): IWebXRFeature;
  113320. /**
  113321. * dispose this features manager
  113322. */
  113323. dispose(): void;
  113324. }
  113325. }
  113326. declare module BABYLON {
  113327. /**
  113328. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113329. * @see https://doc.babylonjs.com/how_to/webxr
  113330. */
  113331. export class WebXRExperienceHelper implements IDisposable {
  113332. private scene;
  113333. /**
  113334. * Camera used to render xr content
  113335. */
  113336. camera: WebXRCamera;
  113337. /**
  113338. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113339. */
  113340. state: WebXRState;
  113341. private _setState;
  113342. /**
  113343. * Fires when the state of the experience helper has changed
  113344. */
  113345. onStateChangedObservable: Observable<WebXRState>;
  113346. /**
  113347. * Observers registered here will be triggered after the camera's initial transformation is set
  113348. * This can be used to set a different ground level or an extra rotation.
  113349. *
  113350. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  113351. * to the position set after this observable is done executing.
  113352. */
  113353. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  113354. /** Session manager used to keep track of xr session */
  113355. sessionManager: WebXRSessionManager;
  113356. /** A features manager for this xr session */
  113357. featuresManager: WebXRFeaturesManager;
  113358. private _nonVRCamera;
  113359. private _originalSceneAutoClear;
  113360. private _supported;
  113361. /**
  113362. * Creates the experience helper
  113363. * @param scene the scene to attach the experience helper to
  113364. * @returns a promise for the experience helper
  113365. */
  113366. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113367. /**
  113368. * Creates a WebXRExperienceHelper
  113369. * @param scene The scene the helper should be created in
  113370. */
  113371. private constructor();
  113372. /**
  113373. * Exits XR mode and returns the scene to its original state
  113374. * @returns promise that resolves after xr mode has exited
  113375. */
  113376. exitXRAsync(): Promise<void>;
  113377. /**
  113378. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113379. * @param sessionMode options for the XR session
  113380. * @param referenceSpaceType frame of reference of the XR session
  113381. * @param renderTarget the output canvas that will be used to enter XR mode
  113382. * @returns promise that resolves after xr mode has entered
  113383. */
  113384. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113385. /**
  113386. * Disposes of the experience helper
  113387. */
  113388. dispose(): void;
  113389. private _nonXRToXRCamera;
  113390. }
  113391. }
  113392. declare module BABYLON {
  113393. /**
  113394. * Represents an XR input
  113395. */
  113396. export class WebXRController {
  113397. private scene;
  113398. /** The underlying input source for the controller */
  113399. inputSource: XRInputSource;
  113400. private parentContainer;
  113401. /**
  113402. * 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
  113403. */
  113404. grip?: AbstractMesh;
  113405. /**
  113406. * Pointer which can be used to select objects or attach a visible laser to
  113407. */
  113408. pointer: AbstractMesh;
  113409. private _gamepadMode;
  113410. /**
  113411. * If available, this is the gamepad object related to this controller.
  113412. * Using this object it is possible to get click events and trackpad changes of the
  113413. * webxr controller that is currently being used.
  113414. */
  113415. gamepadController?: WebVRController;
  113416. /**
  113417. * Event that fires when the controller is removed/disposed
  113418. */
  113419. onDisposeObservable: Observable<{}>;
  113420. private _tmpQuaternion;
  113421. private _tmpVector;
  113422. /**
  113423. * Creates the controller
  113424. * @see https://doc.babylonjs.com/how_to/webxr
  113425. * @param scene the scene which the controller should be associated to
  113426. * @param inputSource the underlying input source for the controller
  113427. * @param parentContainer parent that the controller meshes should be children of
  113428. */
  113429. constructor(scene: Scene,
  113430. /** The underlying input source for the controller */
  113431. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113432. /**
  113433. * Updates the controller pose based on the given XRFrame
  113434. * @param xrFrame xr frame to update the pose with
  113435. * @param referenceSpace reference space to use
  113436. */
  113437. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113438. /**
  113439. * Gets a world space ray coming from the controller
  113440. * @param result the resulting ray
  113441. */
  113442. getWorldPointerRayToRef(result: Ray): void;
  113443. /**
  113444. * Get the scene associated with this controller
  113445. * @returns the scene object
  113446. */
  113447. getScene(): Scene;
  113448. /**
  113449. * Disposes of the object
  113450. */
  113451. dispose(): void;
  113452. }
  113453. }
  113454. declare module BABYLON {
  113455. /**
  113456. * XR input used to track XR inputs such as controllers/rays
  113457. */
  113458. export class WebXRInput implements IDisposable {
  113459. /**
  113460. * Base experience the input listens to
  113461. */
  113462. baseExperience: WebXRExperienceHelper;
  113463. /**
  113464. * XR controllers being tracked
  113465. */
  113466. controllers: Array<WebXRController>;
  113467. private _frameObserver;
  113468. private _stateObserver;
  113469. /**
  113470. * Event when a controller has been connected/added
  113471. */
  113472. onControllerAddedObservable: Observable<WebXRController>;
  113473. /**
  113474. * Event when a controller has been removed/disconnected
  113475. */
  113476. onControllerRemovedObservable: Observable<WebXRController>;
  113477. /**
  113478. * Initializes the WebXRInput
  113479. * @param baseExperience experience helper which the input should be created for
  113480. */
  113481. constructor(
  113482. /**
  113483. * Base experience the input listens to
  113484. */
  113485. baseExperience: WebXRExperienceHelper);
  113486. private _onInputSourcesChange;
  113487. private _addAndRemoveControllers;
  113488. /**
  113489. * Disposes of the object
  113490. */
  113491. dispose(): void;
  113492. }
  113493. }
  113494. declare module BABYLON {
  113495. /**
  113496. * Class used to represent data loading progression
  113497. */
  113498. export class SceneLoaderProgressEvent {
  113499. /** defines if data length to load can be evaluated */
  113500. readonly lengthComputable: boolean;
  113501. /** defines the loaded data length */
  113502. readonly loaded: number;
  113503. /** defines the data length to load */
  113504. readonly total: number;
  113505. /**
  113506. * Create a new progress event
  113507. * @param lengthComputable defines if data length to load can be evaluated
  113508. * @param loaded defines the loaded data length
  113509. * @param total defines the data length to load
  113510. */
  113511. constructor(
  113512. /** defines if data length to load can be evaluated */
  113513. lengthComputable: boolean,
  113514. /** defines the loaded data length */
  113515. loaded: number,
  113516. /** defines the data length to load */
  113517. total: number);
  113518. /**
  113519. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113520. * @param event defines the source event
  113521. * @returns a new SceneLoaderProgressEvent
  113522. */
  113523. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113524. }
  113525. /**
  113526. * Interface used by SceneLoader plugins to define supported file extensions
  113527. */
  113528. export interface ISceneLoaderPluginExtensions {
  113529. /**
  113530. * Defines the list of supported extensions
  113531. */
  113532. [extension: string]: {
  113533. isBinary: boolean;
  113534. };
  113535. }
  113536. /**
  113537. * Interface used by SceneLoader plugin factory
  113538. */
  113539. export interface ISceneLoaderPluginFactory {
  113540. /**
  113541. * Defines the name of the factory
  113542. */
  113543. name: string;
  113544. /**
  113545. * Function called to create a new plugin
  113546. * @return the new plugin
  113547. */
  113548. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113549. /**
  113550. * The callback that returns true if the data can be directly loaded.
  113551. * @param data string containing the file data
  113552. * @returns if the data can be loaded directly
  113553. */
  113554. canDirectLoad?(data: string): boolean;
  113555. }
  113556. /**
  113557. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113558. */
  113559. export interface ISceneLoaderPluginBase {
  113560. /**
  113561. * The friendly name of this plugin.
  113562. */
  113563. name: string;
  113564. /**
  113565. * The file extensions supported by this plugin.
  113566. */
  113567. extensions: string | ISceneLoaderPluginExtensions;
  113568. /**
  113569. * The callback called when loading from a url.
  113570. * @param scene scene loading this url
  113571. * @param url url to load
  113572. * @param onSuccess callback called when the file successfully loads
  113573. * @param onProgress callback called while file is loading (if the server supports this mode)
  113574. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113575. * @param onError callback called when the file fails to load
  113576. * @returns a file request object
  113577. */
  113578. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113579. /**
  113580. * The callback called when loading from a file object.
  113581. * @param scene scene loading this file
  113582. * @param file defines the file to load
  113583. * @param onSuccess defines the callback to call when data is loaded
  113584. * @param onProgress defines the callback to call during loading process
  113585. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113586. * @param onError defines the callback to call when an error occurs
  113587. * @returns a file request object
  113588. */
  113589. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113590. /**
  113591. * The callback that returns true if the data can be directly loaded.
  113592. * @param data string containing the file data
  113593. * @returns if the data can be loaded directly
  113594. */
  113595. canDirectLoad?(data: string): boolean;
  113596. /**
  113597. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113598. * @param scene scene loading this data
  113599. * @param data string containing the data
  113600. * @returns data to pass to the plugin
  113601. */
  113602. directLoad?(scene: Scene, data: string): any;
  113603. /**
  113604. * The callback that allows custom handling of the root url based on the response url.
  113605. * @param rootUrl the original root url
  113606. * @param responseURL the response url if available
  113607. * @returns the new root url
  113608. */
  113609. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113610. }
  113611. /**
  113612. * Interface used to define a SceneLoader plugin
  113613. */
  113614. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113615. /**
  113616. * Import meshes into a scene.
  113617. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113618. * @param scene The scene to import into
  113619. * @param data The data to import
  113620. * @param rootUrl The root url for scene and resources
  113621. * @param meshes The meshes array to import into
  113622. * @param particleSystems The particle systems array to import into
  113623. * @param skeletons The skeletons array to import into
  113624. * @param onError The callback when import fails
  113625. * @returns True if successful or false otherwise
  113626. */
  113627. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113628. /**
  113629. * Load into a scene.
  113630. * @param scene The scene to load into
  113631. * @param data The data to import
  113632. * @param rootUrl The root url for scene and resources
  113633. * @param onError The callback when import fails
  113634. * @returns True if successful or false otherwise
  113635. */
  113636. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113637. /**
  113638. * Load into an asset container.
  113639. * @param scene The scene to load into
  113640. * @param data The data to import
  113641. * @param rootUrl The root url for scene and resources
  113642. * @param onError The callback when import fails
  113643. * @returns The loaded asset container
  113644. */
  113645. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113646. }
  113647. /**
  113648. * Interface used to define an async SceneLoader plugin
  113649. */
  113650. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113651. /**
  113652. * Import meshes into a scene.
  113653. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113654. * @param scene The scene to import into
  113655. * @param data The data to import
  113656. * @param rootUrl The root url for scene and resources
  113657. * @param onProgress The callback when the load progresses
  113658. * @param fileName Defines the name of the file to load
  113659. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113660. */
  113661. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113662. meshes: AbstractMesh[];
  113663. particleSystems: IParticleSystem[];
  113664. skeletons: Skeleton[];
  113665. animationGroups: AnimationGroup[];
  113666. }>;
  113667. /**
  113668. * Load into a scene.
  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 Nothing
  113675. */
  113676. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113677. /**
  113678. * Load into an asset container.
  113679. * @param scene The scene to load into
  113680. * @param data The data to import
  113681. * @param rootUrl The root url for scene and resources
  113682. * @param onProgress The callback when the load progresses
  113683. * @param fileName Defines the name of the file to load
  113684. * @returns The loaded asset container
  113685. */
  113686. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113687. }
  113688. /**
  113689. * Mode that determines how to handle old animation groups before loading new ones.
  113690. */
  113691. export enum SceneLoaderAnimationGroupLoadingMode {
  113692. /**
  113693. * Reset all old animations to initial state then dispose them.
  113694. */
  113695. Clean = 0,
  113696. /**
  113697. * Stop all old animations.
  113698. */
  113699. Stop = 1,
  113700. /**
  113701. * Restart old animations from first frame.
  113702. */
  113703. Sync = 2,
  113704. /**
  113705. * Old animations remains untouched.
  113706. */
  113707. NoSync = 3
  113708. }
  113709. /**
  113710. * Class used to load scene from various file formats using registered plugins
  113711. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113712. */
  113713. export class SceneLoader {
  113714. /**
  113715. * No logging while loading
  113716. */
  113717. static readonly NO_LOGGING: number;
  113718. /**
  113719. * Minimal logging while loading
  113720. */
  113721. static readonly MINIMAL_LOGGING: number;
  113722. /**
  113723. * Summary logging while loading
  113724. */
  113725. static readonly SUMMARY_LOGGING: number;
  113726. /**
  113727. * Detailled logging while loading
  113728. */
  113729. static readonly DETAILED_LOGGING: number;
  113730. /**
  113731. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113732. */
  113733. static get ForceFullSceneLoadingForIncremental(): boolean;
  113734. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113735. /**
  113736. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113737. */
  113738. static get ShowLoadingScreen(): boolean;
  113739. static set ShowLoadingScreen(value: boolean);
  113740. /**
  113741. * Defines the current logging level (while loading the scene)
  113742. * @ignorenaming
  113743. */
  113744. static get loggingLevel(): number;
  113745. static set loggingLevel(value: number);
  113746. /**
  113747. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113748. */
  113749. static get CleanBoneMatrixWeights(): boolean;
  113750. static set CleanBoneMatrixWeights(value: boolean);
  113751. /**
  113752. * Event raised when a plugin is used to load a scene
  113753. */
  113754. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113755. private static _registeredPlugins;
  113756. private static _getDefaultPlugin;
  113757. private static _getPluginForExtension;
  113758. private static _getPluginForDirectLoad;
  113759. private static _getPluginForFilename;
  113760. private static _getDirectLoad;
  113761. private static _loadData;
  113762. private static _getFileInfo;
  113763. /**
  113764. * Gets a plugin that can load the given extension
  113765. * @param extension defines the extension to load
  113766. * @returns a plugin or null if none works
  113767. */
  113768. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113769. /**
  113770. * Gets a boolean indicating that the given extension can be loaded
  113771. * @param extension defines the extension to load
  113772. * @returns true if the extension is supported
  113773. */
  113774. static IsPluginForExtensionAvailable(extension: string): boolean;
  113775. /**
  113776. * Adds a new plugin to the list of registered plugins
  113777. * @param plugin defines the plugin to add
  113778. */
  113779. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113780. /**
  113781. * Import meshes into a scene
  113782. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113783. * @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)
  113784. * @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)
  113785. * @param scene the instance of BABYLON.Scene to append to
  113786. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113787. * @param onProgress a callback with a progress event for each file being loaded
  113788. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113789. * @param pluginExtension the extension used to determine the plugin
  113790. * @returns The loaded plugin
  113791. */
  113792. 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>;
  113793. /**
  113794. * Import meshes into a scene
  113795. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113796. * @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)
  113797. * @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)
  113798. * @param scene the instance of BABYLON.Scene to append to
  113799. * @param onProgress a callback with a progress event for each file being loaded
  113800. * @param pluginExtension the extension used to determine the plugin
  113801. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113802. */
  113803. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113804. meshes: AbstractMesh[];
  113805. particleSystems: IParticleSystem[];
  113806. skeletons: Skeleton[];
  113807. animationGroups: AnimationGroup[];
  113808. }>;
  113809. /**
  113810. * Load a scene
  113811. * @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)
  113812. * @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)
  113813. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113814. * @param onSuccess a callback with the scene when import succeeds
  113815. * @param onProgress a callback with a progress event for each file being loaded
  113816. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113817. * @param pluginExtension the extension used to determine the plugin
  113818. * @returns The loaded plugin
  113819. */
  113820. 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>;
  113821. /**
  113822. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  113826. * @param onProgress a callback with a progress event for each file being loaded
  113827. * @param pluginExtension the extension used to determine the plugin
  113828. * @returns The loaded scene
  113829. */
  113830. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113831. /**
  113832. * Append a scene
  113833. * @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)
  113834. * @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)
  113835. * @param scene is the instance of BABYLON.Scene to append to
  113836. * @param onSuccess a callback with the scene when import succeeds
  113837. * @param onProgress a callback with a progress event for each file being loaded
  113838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113839. * @param pluginExtension the extension used to determine the plugin
  113840. * @returns The loaded plugin
  113841. */
  113842. 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>;
  113843. /**
  113844. * Append a scene
  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
  113848. * @param onProgress a callback with a progress event for each file being loaded
  113849. * @param pluginExtension the extension used to determine the plugin
  113850. * @returns The given scene
  113851. */
  113852. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113853. /**
  113854. * Load a scene into an asset container
  113855. * @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)
  113856. * @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)
  113857. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113858. * @param onSuccess a callback with the scene when import succeeds
  113859. * @param onProgress a callback with a progress event for each file being loaded
  113860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113861. * @param pluginExtension the extension used to determine the plugin
  113862. * @returns The loaded plugin
  113863. */
  113864. 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>;
  113865. /**
  113866. * Load a scene into an asset container
  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 (default: empty string)
  113869. * @param scene is the instance of Scene to append to
  113870. * @param onProgress a callback with a progress event for each file being loaded
  113871. * @param pluginExtension the extension used to determine the plugin
  113872. * @returns The loaded asset container
  113873. */
  113874. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113875. /**
  113876. * Import animations from a file into a scene
  113877. * @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)
  113878. * @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)
  113879. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113880. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113881. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113882. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113883. * @param onSuccess a callback with the scene when import succeeds
  113884. * @param onProgress a callback with a progress event for each file being loaded
  113885. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113886. */
  113887. 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;
  113888. /**
  113889. * Import animations from a file into a scene
  113890. * @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)
  113891. * @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)
  113892. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113893. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113894. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113895. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113896. * @param onSuccess a callback with the scene when import succeeds
  113897. * @param onProgress a callback with a progress event for each file being loaded
  113898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113899. * @returns the updated scene with imported animations
  113900. */
  113901. 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>;
  113902. }
  113903. }
  113904. declare module BABYLON {
  113905. /**
  113906. * Generic Controller
  113907. */
  113908. export class GenericController extends WebVRController {
  113909. /**
  113910. * Base Url for the controller model.
  113911. */
  113912. static readonly MODEL_BASE_URL: string;
  113913. /**
  113914. * File name for the controller model.
  113915. */
  113916. static readonly MODEL_FILENAME: string;
  113917. /**
  113918. * Creates a new GenericController from a gamepad
  113919. * @param vrGamepad the gamepad that the controller should be created from
  113920. */
  113921. constructor(vrGamepad: any);
  113922. /**
  113923. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113924. * @param scene scene in which to add meshes
  113925. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113926. */
  113927. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113928. /**
  113929. * Called once for each button that changed state since the last frame
  113930. * @param buttonIdx Which button index changed
  113931. * @param state New state of the button
  113932. * @param changes Which properties on the state changed since last frame
  113933. */
  113934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113935. }
  113936. }
  113937. declare module BABYLON {
  113938. /**
  113939. * Defines the WindowsMotionController object that the state of the windows motion controller
  113940. */
  113941. export class WindowsMotionController extends WebVRController {
  113942. /**
  113943. * The base url used to load the left and right controller models
  113944. */
  113945. static MODEL_BASE_URL: string;
  113946. /**
  113947. * The name of the left controller model file
  113948. */
  113949. static MODEL_LEFT_FILENAME: string;
  113950. /**
  113951. * The name of the right controller model file
  113952. */
  113953. static MODEL_RIGHT_FILENAME: string;
  113954. /**
  113955. * The controller name prefix for this controller type
  113956. */
  113957. static readonly GAMEPAD_ID_PREFIX: string;
  113958. /**
  113959. * The controller id pattern for this controller type
  113960. */
  113961. private static readonly GAMEPAD_ID_PATTERN;
  113962. private _loadedMeshInfo;
  113963. protected readonly _mapping: {
  113964. buttons: string[];
  113965. buttonMeshNames: {
  113966. 'trigger': string;
  113967. 'menu': string;
  113968. 'grip': string;
  113969. 'thumbstick': string;
  113970. 'trackpad': string;
  113971. };
  113972. buttonObservableNames: {
  113973. 'trigger': string;
  113974. 'menu': string;
  113975. 'grip': string;
  113976. 'thumbstick': string;
  113977. 'trackpad': string;
  113978. };
  113979. axisMeshNames: string[];
  113980. pointingPoseMeshName: string;
  113981. };
  113982. /**
  113983. * Fired when the trackpad on this controller is clicked
  113984. */
  113985. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113986. /**
  113987. * Fired when the trackpad on this controller is modified
  113988. */
  113989. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113990. /**
  113991. * The current x and y values of this controller's trackpad
  113992. */
  113993. trackpad: StickValues;
  113994. /**
  113995. * Creates a new WindowsMotionController from a gamepad
  113996. * @param vrGamepad the gamepad that the controller should be created from
  113997. */
  113998. constructor(vrGamepad: any);
  113999. /**
  114000. * Fired when the trigger on this controller is modified
  114001. */
  114002. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114003. /**
  114004. * Fired when the menu button on this controller is modified
  114005. */
  114006. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114007. /**
  114008. * Fired when the grip button on this controller is modified
  114009. */
  114010. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114011. /**
  114012. * Fired when the thumbstick button on this controller is modified
  114013. */
  114014. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114015. /**
  114016. * Fired when the touchpad button on this controller is modified
  114017. */
  114018. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114019. /**
  114020. * Fired when the touchpad values on this controller are modified
  114021. */
  114022. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  114023. protected _updateTrackpad(): void;
  114024. /**
  114025. * Called once per frame by the engine.
  114026. */
  114027. update(): void;
  114028. /**
  114029. * Called once for each button that changed state since the last frame
  114030. * @param buttonIdx Which button index changed
  114031. * @param state New state of the button
  114032. * @param changes Which properties on the state changed since last frame
  114033. */
  114034. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114035. /**
  114036. * Moves the buttons on the controller mesh based on their current state
  114037. * @param buttonName the name of the button to move
  114038. * @param buttonValue the value of the button which determines the buttons new position
  114039. */
  114040. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  114041. /**
  114042. * Moves the axis on the controller mesh based on its current state
  114043. * @param axis the index of the axis
  114044. * @param axisValue the value of the axis which determines the meshes new position
  114045. * @hidden
  114046. */
  114047. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  114048. /**
  114049. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114050. * @param scene scene in which to add meshes
  114051. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114052. */
  114053. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  114054. /**
  114055. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  114056. * can be transformed by button presses and axes values, based on this._mapping.
  114057. *
  114058. * @param scene scene in which the meshes exist
  114059. * @param meshes list of meshes that make up the controller model to process
  114060. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  114061. */
  114062. private processModel;
  114063. private createMeshInfo;
  114064. /**
  114065. * Gets the ray of the controller in the direction the controller is pointing
  114066. * @param length the length the resulting ray should be
  114067. * @returns a ray in the direction the controller is pointing
  114068. */
  114069. getForwardRay(length?: number): Ray;
  114070. /**
  114071. * Disposes of the controller
  114072. */
  114073. dispose(): void;
  114074. }
  114075. /**
  114076. * This class represents a new windows motion controller in XR.
  114077. */
  114078. export class XRWindowsMotionController extends WindowsMotionController {
  114079. /**
  114080. * Changing the original WIndowsMotionController mapping to fir the new mapping
  114081. */
  114082. protected readonly _mapping: {
  114083. buttons: string[];
  114084. buttonMeshNames: {
  114085. 'trigger': string;
  114086. 'menu': string;
  114087. 'grip': string;
  114088. 'thumbstick': string;
  114089. 'trackpad': string;
  114090. };
  114091. buttonObservableNames: {
  114092. 'trigger': string;
  114093. 'menu': string;
  114094. 'grip': string;
  114095. 'thumbstick': string;
  114096. 'trackpad': string;
  114097. };
  114098. axisMeshNames: string[];
  114099. pointingPoseMeshName: string;
  114100. };
  114101. /**
  114102. * Construct a new XR-Based windows motion controller
  114103. *
  114104. * @param gamepadInfo the gamepad object from the browser
  114105. */
  114106. constructor(gamepadInfo: any);
  114107. /**
  114108. * holds the thumbstick values (X,Y)
  114109. */
  114110. thumbstickValues: StickValues;
  114111. /**
  114112. * Fired when the thumbstick on this controller is clicked
  114113. */
  114114. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  114115. /**
  114116. * Fired when the thumbstick on this controller is modified
  114117. */
  114118. onThumbstickValuesChangedObservable: Observable<StickValues>;
  114119. /**
  114120. * Fired when the touchpad button on this controller is modified
  114121. */
  114122. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  114123. /**
  114124. * Fired when the touchpad values on this controller are modified
  114125. */
  114126. onTrackpadValuesChangedObservable: Observable<StickValues>;
  114127. /**
  114128. * Fired when the thumbstick button on this controller is modified
  114129. * here to prevent breaking changes
  114130. */
  114131. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114132. /**
  114133. * updating the thumbstick(!) and not the trackpad.
  114134. * This is named this way due to the difference between WebVR and XR and to avoid
  114135. * changing the parent class.
  114136. */
  114137. protected _updateTrackpad(): void;
  114138. /**
  114139. * Disposes the class with joy
  114140. */
  114141. dispose(): void;
  114142. }
  114143. }
  114144. declare module BABYLON {
  114145. /**
  114146. * Oculus Touch Controller
  114147. */
  114148. export class OculusTouchController extends WebVRController {
  114149. /**
  114150. * Base Url for the controller model.
  114151. */
  114152. static MODEL_BASE_URL: string;
  114153. /**
  114154. * File name for the left controller model.
  114155. */
  114156. static MODEL_LEFT_FILENAME: string;
  114157. /**
  114158. * File name for the right controller model.
  114159. */
  114160. static MODEL_RIGHT_FILENAME: string;
  114161. /**
  114162. * Base Url for the Quest controller model.
  114163. */
  114164. static QUEST_MODEL_BASE_URL: string;
  114165. /**
  114166. * @hidden
  114167. * If the controllers are running on a device that needs the updated Quest controller models
  114168. */
  114169. static _IsQuest: boolean;
  114170. /**
  114171. * Fired when the secondary trigger on this controller is modified
  114172. */
  114173. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  114174. /**
  114175. * Fired when the thumb rest on this controller is modified
  114176. */
  114177. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  114178. /**
  114179. * Creates a new OculusTouchController from a gamepad
  114180. * @param vrGamepad the gamepad that the controller should be created from
  114181. */
  114182. constructor(vrGamepad: any);
  114183. /**
  114184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114185. * @param scene scene in which to add meshes
  114186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114187. */
  114188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114189. /**
  114190. * Fired when the A button on this controller is modified
  114191. */
  114192. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114193. /**
  114194. * Fired when the B button on this controller is modified
  114195. */
  114196. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114197. /**
  114198. * Fired when the X button on this controller is modified
  114199. */
  114200. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114201. /**
  114202. * Fired when the Y button on this controller is modified
  114203. */
  114204. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114205. /**
  114206. * Called once for each button that changed state since the last frame
  114207. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114208. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114209. * 2) secondary trigger (same)
  114210. * 3) A (right) X (left), touch, pressed = value
  114211. * 4) B / Y
  114212. * 5) thumb rest
  114213. * @param buttonIdx Which button index changed
  114214. * @param state New state of the button
  114215. * @param changes Which properties on the state changed since last frame
  114216. */
  114217. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114218. }
  114219. }
  114220. declare module BABYLON {
  114221. /**
  114222. * Vive Controller
  114223. */
  114224. export class ViveController extends WebVRController {
  114225. /**
  114226. * Base Url for the controller model.
  114227. */
  114228. static MODEL_BASE_URL: string;
  114229. /**
  114230. * File name for the controller model.
  114231. */
  114232. static MODEL_FILENAME: string;
  114233. /**
  114234. * Creates a new ViveController from a gamepad
  114235. * @param vrGamepad the gamepad that the controller should be created from
  114236. */
  114237. constructor(vrGamepad: any);
  114238. /**
  114239. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114240. * @param scene scene in which to add meshes
  114241. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114242. */
  114243. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114244. /**
  114245. * Fired when the left button on this controller is modified
  114246. */
  114247. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114248. /**
  114249. * Fired when the right button on this controller is modified
  114250. */
  114251. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114252. /**
  114253. * Fired when the menu button on this controller is modified
  114254. */
  114255. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114256. /**
  114257. * Called once for each button that changed state since the last frame
  114258. * Vive mapping:
  114259. * 0: touchpad
  114260. * 1: trigger
  114261. * 2: left AND right buttons
  114262. * 3: menu button
  114263. * @param buttonIdx Which button index changed
  114264. * @param state New state of the button
  114265. * @param changes Which properties on the state changed since last frame
  114266. */
  114267. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114268. }
  114269. }
  114270. declare module BABYLON {
  114271. /**
  114272. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114273. */
  114274. export class WebXRControllerModelLoader {
  114275. /**
  114276. * an observable that triggers when a new model (the mesh itself) was initialized.
  114277. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114278. */
  114279. onControllerModelLoaded: Observable<WebXRController>;
  114280. /**
  114281. * Creates the WebXRControllerModelLoader
  114282. * @param input xr input that creates the controllers
  114283. */
  114284. constructor(input: WebXRInput);
  114285. }
  114286. }
  114287. declare module BABYLON {
  114288. /**
  114289. * Handles pointer input automatically for the pointer of XR controllers
  114290. */
  114291. export class WebXRControllerPointerSelection {
  114292. private static _idCounter;
  114293. private _tmpRay;
  114294. /**
  114295. * Creates a WebXRControllerPointerSelection
  114296. * @param input input manager to setup pointer selection
  114297. */
  114298. constructor(input: WebXRInput);
  114299. private _convertNormalToDirectionOfRay;
  114300. private _updatePointerDistance;
  114301. }
  114302. }
  114303. declare module BABYLON {
  114304. /**
  114305. * Enables teleportation
  114306. */
  114307. export class WebXRControllerTeleportation {
  114308. private _teleportationFillColor;
  114309. private _teleportationBorderColor;
  114310. private _tmpRay;
  114311. private _tmpVector;
  114312. /**
  114313. * when set to true (default) teleportation will wait for thumbstick changes.
  114314. * When set to false teleportation will be disabled.
  114315. *
  114316. * If set to false while teleporting results can be unexpected.
  114317. */
  114318. enabled: boolean;
  114319. /**
  114320. * Creates a WebXRControllerTeleportation
  114321. * @param input input manager to add teleportation to
  114322. * @param floorMeshes floormeshes which can be teleported to
  114323. */
  114324. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114325. }
  114326. }
  114327. declare module BABYLON {
  114328. /**
  114329. * Button which can be used to enter a different mode of XR
  114330. */
  114331. export class WebXREnterExitUIButton {
  114332. /** button element */
  114333. element: HTMLElement;
  114334. /** XR initialization options for the button */
  114335. sessionMode: XRSessionMode;
  114336. /** Reference space type */
  114337. referenceSpaceType: XRReferenceSpaceType;
  114338. /**
  114339. * Creates a WebXREnterExitUIButton
  114340. * @param element button element
  114341. * @param sessionMode XR initialization session mode
  114342. * @param referenceSpaceType the type of reference space to be used
  114343. */
  114344. constructor(
  114345. /** button element */
  114346. element: HTMLElement,
  114347. /** XR initialization options for the button */
  114348. sessionMode: XRSessionMode,
  114349. /** Reference space type */
  114350. referenceSpaceType: XRReferenceSpaceType);
  114351. /**
  114352. * Overwritable function which can be used to update the button's visuals when the state changes
  114353. * @param activeButton the current active button in the UI
  114354. */
  114355. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114356. }
  114357. /**
  114358. * Options to create the webXR UI
  114359. */
  114360. export class WebXREnterExitUIOptions {
  114361. /**
  114362. * Context to enter xr with
  114363. */
  114364. renderTarget?: Nullable<WebXRRenderTarget>;
  114365. /**
  114366. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114367. */
  114368. customButtons?: Array<WebXREnterExitUIButton>;
  114369. /**
  114370. * A session mode to use when creating the default button.
  114371. * Default is immersive-vr
  114372. */
  114373. sessionMode?: XRSessionMode;
  114374. /**
  114375. * A reference space type to use when creating the default button.
  114376. * Default is local-floor
  114377. */
  114378. referenceSpaceType?: XRReferenceSpaceType;
  114379. }
  114380. /**
  114381. * UI to allow the user to enter/exit XR mode
  114382. */
  114383. export class WebXREnterExitUI implements IDisposable {
  114384. private scene;
  114385. /** version of the options passed to this UI */
  114386. options: WebXREnterExitUIOptions;
  114387. private _overlay;
  114388. private _buttons;
  114389. private _activeButton;
  114390. /**
  114391. * Fired every time the active button is changed.
  114392. *
  114393. * When xr is entered via a button that launches xr that button will be the callback parameter
  114394. *
  114395. * When exiting xr the callback parameter will be null)
  114396. */
  114397. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114398. /**
  114399. * Creates UI to allow the user to enter/exit XR mode
  114400. * @param scene the scene to add the ui to
  114401. * @param helper the xr experience helper to enter/exit xr with
  114402. * @param options options to configure the UI
  114403. * @returns the created ui
  114404. */
  114405. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114406. /**
  114407. *
  114408. * @param scene babylon scene object to use
  114409. * @param options (read-only) version of the options passed to this UI
  114410. */
  114411. private constructor();
  114412. private _updateButtons;
  114413. /**
  114414. * Disposes of the object
  114415. */
  114416. dispose(): void;
  114417. }
  114418. }
  114419. declare module BABYLON {
  114420. /**
  114421. * Options for the default xr helper
  114422. */
  114423. export class WebXRDefaultExperienceOptions {
  114424. /**
  114425. * Floor meshes that should be used for teleporting
  114426. */
  114427. floorMeshes: Array<AbstractMesh>;
  114428. /**
  114429. * Enable or disable default UI to enter XR
  114430. */
  114431. disableDefaultUI?: boolean;
  114432. /**
  114433. * optional configuration for the output canvas
  114434. */
  114435. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114436. /**
  114437. * optional UI options. This can be used among other to change session mode and reference space type
  114438. */
  114439. uiOptions?: WebXREnterExitUIOptions;
  114440. }
  114441. /**
  114442. * Default experience which provides a similar setup to the previous webVRExperience
  114443. */
  114444. export class WebXRDefaultExperience {
  114445. /**
  114446. * Base experience
  114447. */
  114448. baseExperience: WebXRExperienceHelper;
  114449. /**
  114450. * Input experience extension
  114451. */
  114452. input: WebXRInput;
  114453. /**
  114454. * Loads the controller models
  114455. */
  114456. controllerModelLoader: WebXRControllerModelLoader;
  114457. /**
  114458. * Enables laser pointer and selection
  114459. */
  114460. pointerSelection: WebXRControllerPointerSelection;
  114461. /**
  114462. * Enables teleportation
  114463. */
  114464. teleportation: WebXRControllerTeleportation;
  114465. /**
  114466. * Enables ui for entering/exiting xr
  114467. */
  114468. enterExitUI: WebXREnterExitUI;
  114469. /**
  114470. * Default target xr should render to
  114471. */
  114472. renderTarget: WebXRRenderTarget;
  114473. /**
  114474. * Creates the default xr experience
  114475. * @param scene scene
  114476. * @param options options for basic configuration
  114477. * @returns resulting WebXRDefaultExperience
  114478. */
  114479. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114480. private constructor();
  114481. /**
  114482. * DIsposes of the experience helper
  114483. */
  114484. dispose(): void;
  114485. }
  114486. }
  114487. declare module BABYLON {
  114488. /**
  114489. * Options to modify the vr teleportation behavior.
  114490. */
  114491. export interface VRTeleportationOptions {
  114492. /**
  114493. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114494. */
  114495. floorMeshName?: string;
  114496. /**
  114497. * A list of meshes to be used as the teleportation floor. (default: empty)
  114498. */
  114499. floorMeshes?: Mesh[];
  114500. /**
  114501. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114502. */
  114503. teleportationMode?: number;
  114504. /**
  114505. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114506. */
  114507. teleportationTime?: number;
  114508. /**
  114509. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114510. */
  114511. teleportationSpeed?: number;
  114512. /**
  114513. * The easing function used in the animation or null for Linear. (default CircleEase)
  114514. */
  114515. easingFunction?: EasingFunction;
  114516. }
  114517. /**
  114518. * Options to modify the vr experience helper's behavior.
  114519. */
  114520. export interface VRExperienceHelperOptions extends WebVROptions {
  114521. /**
  114522. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114523. */
  114524. createDeviceOrientationCamera?: boolean;
  114525. /**
  114526. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114527. */
  114528. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114529. /**
  114530. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114531. */
  114532. laserToggle?: boolean;
  114533. /**
  114534. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114535. */
  114536. floorMeshes?: Mesh[];
  114537. /**
  114538. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114539. */
  114540. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114541. /**
  114542. * Defines if WebXR should be used instead of WebVR (if available)
  114543. */
  114544. useXR?: boolean;
  114545. }
  114546. /**
  114547. * Event containing information after VR has been entered
  114548. */
  114549. export class OnAfterEnteringVRObservableEvent {
  114550. /**
  114551. * If entering vr was successful
  114552. */
  114553. success: boolean;
  114554. }
  114555. /**
  114556. * Helps to quickly add VR support to an existing scene.
  114557. * See http://doc.babylonjs.com/how_to/webvr_helper
  114558. */
  114559. export class VRExperienceHelper {
  114560. /** Options to modify the vr experience helper's behavior. */
  114561. webVROptions: VRExperienceHelperOptions;
  114562. private _scene;
  114563. private _position;
  114564. private _btnVR;
  114565. private _btnVRDisplayed;
  114566. private _webVRsupported;
  114567. private _webVRready;
  114568. private _webVRrequesting;
  114569. private _webVRpresenting;
  114570. private _hasEnteredVR;
  114571. private _fullscreenVRpresenting;
  114572. private _inputElement;
  114573. private _webVRCamera;
  114574. private _vrDeviceOrientationCamera;
  114575. private _deviceOrientationCamera;
  114576. private _existingCamera;
  114577. private _onKeyDown;
  114578. private _onVrDisplayPresentChange;
  114579. private _onVRDisplayChanged;
  114580. private _onVRRequestPresentStart;
  114581. private _onVRRequestPresentComplete;
  114582. /**
  114583. * 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)
  114584. */
  114585. enableGazeEvenWhenNoPointerLock: boolean;
  114586. /**
  114587. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114588. */
  114589. exitVROnDoubleTap: boolean;
  114590. /**
  114591. * Observable raised right before entering VR.
  114592. */
  114593. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114594. /**
  114595. * Observable raised when entering VR has completed.
  114596. */
  114597. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114598. /**
  114599. * Observable raised when exiting VR.
  114600. */
  114601. onExitingVRObservable: Observable<VRExperienceHelper>;
  114602. /**
  114603. * Observable raised when controller mesh is loaded.
  114604. */
  114605. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114606. /** Return this.onEnteringVRObservable
  114607. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114608. */
  114609. get onEnteringVR(): Observable<VRExperienceHelper>;
  114610. /** Return this.onExitingVRObservable
  114611. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114612. */
  114613. get onExitingVR(): Observable<VRExperienceHelper>;
  114614. /** Return this.onControllerMeshLoadedObservable
  114615. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114616. */
  114617. get onControllerMeshLoaded(): Observable<WebVRController>;
  114618. private _rayLength;
  114619. private _useCustomVRButton;
  114620. private _teleportationRequested;
  114621. private _teleportActive;
  114622. private _floorMeshName;
  114623. private _floorMeshesCollection;
  114624. private _teleportationMode;
  114625. private _teleportationTime;
  114626. private _teleportationSpeed;
  114627. private _teleportationEasing;
  114628. private _rotationAllowed;
  114629. private _teleportBackwardsVector;
  114630. private _teleportationTarget;
  114631. private _isDefaultTeleportationTarget;
  114632. private _postProcessMove;
  114633. private _teleportationFillColor;
  114634. private _teleportationBorderColor;
  114635. private _rotationAngle;
  114636. private _haloCenter;
  114637. private _cameraGazer;
  114638. private _padSensibilityUp;
  114639. private _padSensibilityDown;
  114640. private _leftController;
  114641. private _rightController;
  114642. private _gazeColor;
  114643. private _laserColor;
  114644. private _pickedLaserColor;
  114645. private _pickedGazeColor;
  114646. /**
  114647. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114648. */
  114649. onNewMeshSelected: Observable<AbstractMesh>;
  114650. /**
  114651. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114652. * This observable will provide the mesh and the controller used to select the mesh
  114653. */
  114654. onMeshSelectedWithController: Observable<{
  114655. mesh: AbstractMesh;
  114656. controller: WebVRController;
  114657. }>;
  114658. /**
  114659. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114660. */
  114661. onNewMeshPicked: Observable<PickingInfo>;
  114662. private _circleEase;
  114663. /**
  114664. * Observable raised before camera teleportation
  114665. */
  114666. onBeforeCameraTeleport: Observable<Vector3>;
  114667. /**
  114668. * Observable raised after camera teleportation
  114669. */
  114670. onAfterCameraTeleport: Observable<Vector3>;
  114671. /**
  114672. * Observable raised when current selected mesh gets unselected
  114673. */
  114674. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114675. private _raySelectionPredicate;
  114676. /**
  114677. * To be optionaly changed by user to define custom ray selection
  114678. */
  114679. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114680. /**
  114681. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114682. */
  114683. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114684. /**
  114685. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114686. */
  114687. teleportationEnabled: boolean;
  114688. private _defaultHeight;
  114689. private _teleportationInitialized;
  114690. private _interactionsEnabled;
  114691. private _interactionsRequested;
  114692. private _displayGaze;
  114693. private _displayLaserPointer;
  114694. /**
  114695. * The mesh used to display where the user is going to teleport.
  114696. */
  114697. get teleportationTarget(): Mesh;
  114698. /**
  114699. * Sets the mesh to be used to display where the user is going to teleport.
  114700. */
  114701. set teleportationTarget(value: Mesh);
  114702. /**
  114703. * 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
  114704. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114705. * See http://doc.babylonjs.com/resources/baking_transformations
  114706. */
  114707. get gazeTrackerMesh(): Mesh;
  114708. set gazeTrackerMesh(value: Mesh);
  114709. /**
  114710. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114711. */
  114712. updateGazeTrackerScale: boolean;
  114713. /**
  114714. * If the gaze trackers color should be updated when selecting meshes
  114715. */
  114716. updateGazeTrackerColor: boolean;
  114717. /**
  114718. * If the controller laser color should be updated when selecting meshes
  114719. */
  114720. updateControllerLaserColor: boolean;
  114721. /**
  114722. * The gaze tracking mesh corresponding to the left controller
  114723. */
  114724. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114725. /**
  114726. * The gaze tracking mesh corresponding to the right controller
  114727. */
  114728. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114729. /**
  114730. * If the ray of the gaze should be displayed.
  114731. */
  114732. get displayGaze(): boolean;
  114733. /**
  114734. * Sets if the ray of the gaze should be displayed.
  114735. */
  114736. set displayGaze(value: boolean);
  114737. /**
  114738. * If the ray of the LaserPointer should be displayed.
  114739. */
  114740. get displayLaserPointer(): boolean;
  114741. /**
  114742. * Sets if the ray of the LaserPointer should be displayed.
  114743. */
  114744. set displayLaserPointer(value: boolean);
  114745. /**
  114746. * The deviceOrientationCamera used as the camera when not in VR.
  114747. */
  114748. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114749. /**
  114750. * Based on the current WebVR support, returns the current VR camera used.
  114751. */
  114752. get currentVRCamera(): Nullable<Camera>;
  114753. /**
  114754. * The webVRCamera which is used when in VR.
  114755. */
  114756. get webVRCamera(): WebVRFreeCamera;
  114757. /**
  114758. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114759. */
  114760. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114761. /**
  114762. * The html button that is used to trigger entering into VR.
  114763. */
  114764. get vrButton(): Nullable<HTMLButtonElement>;
  114765. private get _teleportationRequestInitiated();
  114766. /**
  114767. * Defines wether or not Pointer lock should be requested when switching to
  114768. * full screen.
  114769. */
  114770. requestPointerLockOnFullScreen: boolean;
  114771. /**
  114772. * If asking to force XR, this will be populated with the default xr experience
  114773. */
  114774. xr: WebXRDefaultExperience;
  114775. /**
  114776. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114777. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114778. */
  114779. xrTestDone: boolean;
  114780. /**
  114781. * Instantiates a VRExperienceHelper.
  114782. * Helps to quickly add VR support to an existing scene.
  114783. * @param scene The scene the VRExperienceHelper belongs to.
  114784. * @param webVROptions Options to modify the vr experience helper's behavior.
  114785. */
  114786. constructor(scene: Scene,
  114787. /** Options to modify the vr experience helper's behavior. */
  114788. webVROptions?: VRExperienceHelperOptions);
  114789. private completeVRInit;
  114790. private _onDefaultMeshLoaded;
  114791. private _onResize;
  114792. private _onFullscreenChange;
  114793. /**
  114794. * Gets a value indicating if we are currently in VR mode.
  114795. */
  114796. get isInVRMode(): boolean;
  114797. private onVrDisplayPresentChange;
  114798. private onVRDisplayChanged;
  114799. private moveButtonToBottomRight;
  114800. private displayVRButton;
  114801. private updateButtonVisibility;
  114802. private _cachedAngularSensibility;
  114803. /**
  114804. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114805. * Otherwise, will use the fullscreen API.
  114806. */
  114807. enterVR(): void;
  114808. /**
  114809. * Attempt to exit VR, or fullscreen.
  114810. */
  114811. exitVR(): void;
  114812. /**
  114813. * The position of the vr experience helper.
  114814. */
  114815. get position(): Vector3;
  114816. /**
  114817. * Sets the position of the vr experience helper.
  114818. */
  114819. set position(value: Vector3);
  114820. /**
  114821. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114822. */
  114823. enableInteractions(): void;
  114824. private get _noControllerIsActive();
  114825. private beforeRender;
  114826. private _isTeleportationFloor;
  114827. /**
  114828. * Adds a floor mesh to be used for teleportation.
  114829. * @param floorMesh the mesh to be used for teleportation.
  114830. */
  114831. addFloorMesh(floorMesh: Mesh): void;
  114832. /**
  114833. * Removes a floor mesh from being used for teleportation.
  114834. * @param floorMesh the mesh to be removed.
  114835. */
  114836. removeFloorMesh(floorMesh: Mesh): void;
  114837. /**
  114838. * Enables interactions and teleportation using the VR controllers and gaze.
  114839. * @param vrTeleportationOptions options to modify teleportation behavior.
  114840. */
  114841. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114842. private _onNewGamepadConnected;
  114843. private _tryEnableInteractionOnController;
  114844. private _onNewGamepadDisconnected;
  114845. private _enableInteractionOnController;
  114846. private _checkTeleportWithRay;
  114847. private _checkRotate;
  114848. private _checkTeleportBackwards;
  114849. private _enableTeleportationOnController;
  114850. private _createTeleportationCircles;
  114851. private _displayTeleportationTarget;
  114852. private _hideTeleportationTarget;
  114853. private _rotateCamera;
  114854. private _moveTeleportationSelectorTo;
  114855. private _workingVector;
  114856. private _workingQuaternion;
  114857. private _workingMatrix;
  114858. /**
  114859. * Time Constant Teleportation Mode
  114860. */
  114861. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114862. /**
  114863. * Speed Constant Teleportation Mode
  114864. */
  114865. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114866. /**
  114867. * Teleports the users feet to the desired location
  114868. * @param location The location where the user's feet should be placed
  114869. */
  114870. teleportCamera(location: Vector3): void;
  114871. private _convertNormalToDirectionOfRay;
  114872. private _castRayAndSelectObject;
  114873. private _notifySelectedMeshUnselected;
  114874. /**
  114875. * Permanently set new colors for the laser pointer
  114876. * @param color the new laser color
  114877. * @param pickedColor the new laser color when picked mesh detected
  114878. */
  114879. setLaserColor(color: Color3, pickedColor?: Color3): void;
  114880. /**
  114881. * Permanently set new colors for the gaze pointer
  114882. * @param color the new gaze color
  114883. * @param pickedColor the new gaze color when picked mesh detected
  114884. */
  114885. setGazeColor(color: Color3, pickedColor?: Color3): void;
  114886. /**
  114887. * Sets the color of the laser ray from the vr controllers.
  114888. * @param color new color for the ray.
  114889. */
  114890. changeLaserColor(color: Color3): void;
  114891. /**
  114892. * Sets the color of the ray from the vr headsets gaze.
  114893. * @param color new color for the ray.
  114894. */
  114895. changeGazeColor(color: Color3): void;
  114896. /**
  114897. * Exits VR and disposes of the vr experience helper
  114898. */
  114899. dispose(): void;
  114900. /**
  114901. * Gets the name of the VRExperienceHelper class
  114902. * @returns "VRExperienceHelper"
  114903. */
  114904. getClassName(): string;
  114905. }
  114906. }
  114907. declare module BABYLON {
  114908. /**
  114909. * Options used for hit testing
  114910. */
  114911. export interface IWebXRHitTestOptions {
  114912. /**
  114913. * Only test when user interacted with the scene. Default - hit test every frame
  114914. */
  114915. testOnPointerDownOnly?: boolean;
  114916. /**
  114917. * The node to use to transform the local results to world coordinates
  114918. */
  114919. worldParentNode?: TransformNode;
  114920. }
  114921. /**
  114922. * Interface defining the babylon result of raycasting/hit-test
  114923. */
  114924. export interface IWebXRHitResult {
  114925. /**
  114926. * The native hit test result
  114927. */
  114928. xrHitResult: XRHitResult;
  114929. /**
  114930. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114931. */
  114932. transformationMatrix: Matrix;
  114933. }
  114934. /**
  114935. * The currently-working hit-test module.
  114936. * Hit test (or raycasting) is used to interact with the real world.
  114937. * For further information read here - https://github.com/immersive-web/hit-test
  114938. */
  114939. export class WebXRHitTestLegacy implements IWebXRFeature {
  114940. private _xrSessionManager;
  114941. /**
  114942. * options to use when constructing this feature
  114943. */
  114944. readonly options: IWebXRHitTestOptions;
  114945. /**
  114946. * The module's name
  114947. */
  114948. static readonly Name: string;
  114949. /**
  114950. * The (Babylon) version of this module.
  114951. * This is an integer representing the implementation version.
  114952. * This number does not correspond to the webxr specs version
  114953. */
  114954. static readonly Version: number;
  114955. /**
  114956. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114957. * @param event the (select) event to use to select with
  114958. * @param referenceSpace the reference space to use for this hit test
  114959. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114960. */
  114961. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114962. /**
  114963. * execute a hit test with an XR Ray
  114964. *
  114965. * @param xrSession a native xrSession that will execute this hit test
  114966. * @param xrRay the ray (position and direction) to use for raycasting
  114967. * @param referenceSpace native XR reference space to use for the hit-test
  114968. * @param filter filter function that will filter the results
  114969. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114970. */
  114971. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114972. /**
  114973. * Triggered when new babylon (transformed) hit test results are available
  114974. */
  114975. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114976. /**
  114977. * Creates a new instance of the (legacy version) hit test feature
  114978. * @param _xrSessionManager an instance of WebXRSessionManager
  114979. * @param options options to use when constructing this feature
  114980. */
  114981. constructor(_xrSessionManager: WebXRSessionManager,
  114982. /**
  114983. * options to use when constructing this feature
  114984. */
  114985. options?: IWebXRHitTestOptions);
  114986. private _onSelectEnabled;
  114987. private _xrFrameObserver;
  114988. private _attached;
  114989. /**
  114990. * Populated with the last native XR Hit Results
  114991. */
  114992. lastNativeXRHitResults: XRHitResult[];
  114993. /**
  114994. * attach this feature
  114995. * Will usually be called by the features manager
  114996. *
  114997. * @returns true if successful.
  114998. */
  114999. attach(): boolean;
  115000. /**
  115001. * detach this feature.
  115002. * Will usually be called by the features manager
  115003. *
  115004. * @returns true if successful.
  115005. */
  115006. detach(): boolean;
  115007. private _onHitTestResults;
  115008. private _onSelect;
  115009. /**
  115010. * Dispose this feature and all of the resources attached
  115011. */
  115012. dispose(): void;
  115013. }
  115014. }
  115015. declare module BABYLON {
  115016. /**
  115017. * Options used in the plane detector module
  115018. */
  115019. export interface IWebXRPlaneDetectorOptions {
  115020. /**
  115021. * The node to use to transform the local results to world coordinates
  115022. */
  115023. worldParentNode?: TransformNode;
  115024. }
  115025. /**
  115026. * A babylon interface for a webxr plane.
  115027. * A Plane is actually a polygon, built from N points in space
  115028. */
  115029. export interface IWebXRPlane {
  115030. /**
  115031. * a babylon-assigned ID for this polygon
  115032. */
  115033. id: number;
  115034. /**
  115035. * the native xr-plane object
  115036. */
  115037. xrPlane: XRPlane;
  115038. /**
  115039. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  115040. */
  115041. polygonDefinition: Array<Vector3>;
  115042. /**
  115043. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  115044. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  115045. */
  115046. transformationMatrix: Matrix;
  115047. }
  115048. /**
  115049. * The plane detector is used to detect planes in the real world when in AR
  115050. * For more information see https://github.com/immersive-web/real-world-geometry/
  115051. */
  115052. export class WebXRPlaneDetector implements IWebXRFeature {
  115053. private _xrSessionManager;
  115054. private _options;
  115055. /**
  115056. * The module's name
  115057. */
  115058. static readonly Name: string;
  115059. /**
  115060. * The (Babylon) version of this module.
  115061. * This is an integer representing the implementation version.
  115062. * This number does not correspond to the webxr specs version
  115063. */
  115064. static readonly Version: number;
  115065. /**
  115066. * Observers registered here will be executed when a new plane was added to the session
  115067. */
  115068. onPlaneAddedObservable: Observable<IWebXRPlane>;
  115069. /**
  115070. * Observers registered here will be executed when a plane is no longer detected in the session
  115071. */
  115072. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115073. /**
  115074. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115075. * This can execute N times every frame
  115076. */
  115077. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115078. private _enabled;
  115079. private _attached;
  115080. private _detectedPlanes;
  115081. private _lastFrameDetected;
  115082. private _observerTracked;
  115083. /**
  115084. * construct a new Plane Detector
  115085. * @param _xrSessionManager an instance of xr Session manager
  115086. * @param _options configuration to use when constructing this feature
  115087. */
  115088. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115089. /**
  115090. * attach this feature
  115091. * Will usually be called by the features manager
  115092. *
  115093. * @returns true if successful.
  115094. */
  115095. attach(): boolean;
  115096. /**
  115097. * detach this feature.
  115098. * Will usually be called by the features manager
  115099. *
  115100. * @returns true if successful.
  115101. */
  115102. detach(): boolean;
  115103. /**
  115104. * Dispose this feature and all of the resources attached
  115105. */
  115106. dispose(): void;
  115107. private _updatePlaneWithXRPlane;
  115108. /**
  115109. * avoiding using Array.find for global support.
  115110. * @param xrPlane the plane to find in the array
  115111. */
  115112. private findIndexInPlaneArray;
  115113. }
  115114. }
  115115. declare module BABYLON {
  115116. /**
  115117. * Configuration options of the anchor system
  115118. */
  115119. export interface IWebXRAnchorSystemOptions {
  115120. /**
  115121. * a node that will be used to convert local to world coordinates
  115122. */
  115123. worldParentNode?: TransformNode;
  115124. /**
  115125. * should the anchor system use plane detection.
  115126. * If set to true, the plane-detection feature should be set using setPlaneDetector
  115127. */
  115128. usePlaneDetection?: boolean;
  115129. /**
  115130. * Should a new anchor be added every time a select event is triggered
  115131. */
  115132. addAnchorOnSelect?: boolean;
  115133. }
  115134. /**
  115135. * A babylon container for an XR Anchor
  115136. */
  115137. export interface IWebXRAnchor {
  115138. /**
  115139. * A babylon-assigned ID for this anchor
  115140. */
  115141. id: number;
  115142. /**
  115143. * The native anchor object
  115144. */
  115145. xrAnchor: XRAnchor;
  115146. /**
  115147. * Transformation matrix to apply to an object attached to this anchor
  115148. */
  115149. transformationMatrix: Matrix;
  115150. }
  115151. /**
  115152. * An implementation of the anchor system of WebXR.
  115153. * Note that the current documented implementation is not available in any browser. Future implementations
  115154. * will use the frame to create an anchor and not the session or a detected plane
  115155. * For further information see https://github.com/immersive-web/anchors/
  115156. */
  115157. export class WebXRAnchorSystem implements IWebXRFeature {
  115158. private _xrSessionManager;
  115159. private _options;
  115160. /**
  115161. * The module's name
  115162. */
  115163. static readonly Name: string;
  115164. /**
  115165. * The (Babylon) version of this module.
  115166. * This is an integer representing the implementation version.
  115167. * This number does not correspond to the webxr specs version
  115168. */
  115169. static readonly Version: number;
  115170. /**
  115171. * Observers registered here will be executed when a new anchor was added to the session
  115172. */
  115173. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  115174. /**
  115175. * Observers registered here will be executed when an existing anchor updates
  115176. * This can execute N times every frame
  115177. */
  115178. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  115179. /**
  115180. * Observers registered here will be executed when an anchor was removed from the session
  115181. */
  115182. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  115183. private _planeDetector;
  115184. private _hitTestModule;
  115185. private _enabled;
  115186. private _attached;
  115187. private _trackedAnchors;
  115188. private _lastFrameDetected;
  115189. private _observerTracked;
  115190. /**
  115191. * constructs a new anchor system
  115192. * @param _xrSessionManager an instance of WebXRSessionManager
  115193. * @param _options configuration object for this feature
  115194. */
  115195. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  115196. /**
  115197. * set the plane detector to use in order to create anchors from frames
  115198. * @param planeDetector the plane-detector module to use
  115199. * @param enable enable plane-anchors. default is true
  115200. */
  115201. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  115202. /**
  115203. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  115204. * @param hitTestModule the hit-test module to use.
  115205. */
  115206. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  115207. /**
  115208. * attach this feature
  115209. * Will usually be called by the features manager
  115210. *
  115211. * @returns true if successful.
  115212. */
  115213. attach(): boolean;
  115214. /**
  115215. * detach this feature.
  115216. * Will usually be called by the features manager
  115217. *
  115218. * @returns true if successful.
  115219. */
  115220. detach(): boolean;
  115221. /**
  115222. * Dispose this feature and all of the resources attached
  115223. */
  115224. dispose(): void;
  115225. private _onSelect;
  115226. /**
  115227. * Add anchor at a specific XR point.
  115228. *
  115229. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115230. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115231. * @returns a promise the fulfills when the anchor was created
  115232. */
  115233. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115234. private _updateAnchorWithXRFrame;
  115235. /**
  115236. * avoiding using Array.find for global support.
  115237. * @param xrAnchor the plane to find in the array
  115238. */
  115239. private _findIndexInAnchorArray;
  115240. }
  115241. }
  115242. declare module BABYLON {
  115243. /**
  115244. * Options interface for the background remover plugin
  115245. */
  115246. export interface IWebXRBackgroundRemoverOptions {
  115247. /**
  115248. * don't disable the environment helper
  115249. */
  115250. ignoreEnvironmentHelper?: boolean;
  115251. /**
  115252. * flags to configure the removal of the environment helper.
  115253. * If not set, the entire background will be removed. If set, flags should be set as well.
  115254. */
  115255. environmentHelperRemovalFlags?: {
  115256. /**
  115257. * Should the skybox be removed (default false)
  115258. */
  115259. skyBox?: boolean;
  115260. /**
  115261. * Should the ground be removed (default false)
  115262. */
  115263. ground?: boolean;
  115264. };
  115265. /**
  115266. * Further background meshes to disable when entering AR
  115267. */
  115268. backgroundMeshes?: AbstractMesh[];
  115269. }
  115270. /**
  115271. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115272. */
  115273. export class WebXRBackgroundRemover implements IWebXRFeature {
  115274. private _xrSessionManager;
  115275. /**
  115276. * read-only options to be used in this module
  115277. */
  115278. readonly options: IWebXRBackgroundRemoverOptions;
  115279. /**
  115280. * The module's name
  115281. */
  115282. static readonly Name: string;
  115283. /**
  115284. * The (Babylon) version of this module.
  115285. * This is an integer representing the implementation version.
  115286. * This number does not correspond to the webxr specs version
  115287. */
  115288. static readonly Version: number;
  115289. /**
  115290. * registered observers will be triggered when the background state changes
  115291. */
  115292. onBackgroundStateChangedObservable: Observable<boolean>;
  115293. /**
  115294. * constructs a new background remover module
  115295. * @param _xrSessionManager the session manager for this module
  115296. * @param options read-only options to be used in this module
  115297. */
  115298. constructor(_xrSessionManager: WebXRSessionManager,
  115299. /**
  115300. * read-only options to be used in this module
  115301. */
  115302. options?: IWebXRBackgroundRemoverOptions);
  115303. /**
  115304. * attach this feature
  115305. * Will usually be called by the features manager
  115306. *
  115307. * @returns true if successful.
  115308. */
  115309. attach(): boolean;
  115310. /**
  115311. * detach this feature.
  115312. * Will usually be called by the features manager
  115313. *
  115314. * @returns true if successful.
  115315. */
  115316. detach(): boolean;
  115317. private _setBackgroundState;
  115318. /**
  115319. * Dispose this feature and all of the resources attached
  115320. */
  115321. dispose(): void;
  115322. }
  115323. }
  115324. declare module BABYLON {
  115325. /**
  115326. * Contains an array of blocks representing the octree
  115327. */
  115328. export interface IOctreeContainer<T> {
  115329. /**
  115330. * Blocks within the octree
  115331. */
  115332. blocks: Array<OctreeBlock<T>>;
  115333. }
  115334. /**
  115335. * Class used to store a cell in an octree
  115336. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115337. */
  115338. export class OctreeBlock<T> {
  115339. /**
  115340. * Gets the content of the current block
  115341. */
  115342. entries: T[];
  115343. /**
  115344. * Gets the list of block children
  115345. */
  115346. blocks: Array<OctreeBlock<T>>;
  115347. private _depth;
  115348. private _maxDepth;
  115349. private _capacity;
  115350. private _minPoint;
  115351. private _maxPoint;
  115352. private _boundingVectors;
  115353. private _creationFunc;
  115354. /**
  115355. * Creates a new block
  115356. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115357. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115358. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115359. * @param depth defines the current depth of this block in the octree
  115360. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115361. * @param creationFunc defines a callback to call when an element is added to the block
  115362. */
  115363. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115364. /**
  115365. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115366. */
  115367. get capacity(): number;
  115368. /**
  115369. * Gets the minimum vector (in world space) of the block's bounding box
  115370. */
  115371. get minPoint(): Vector3;
  115372. /**
  115373. * Gets the maximum vector (in world space) of the block's bounding box
  115374. */
  115375. get maxPoint(): Vector3;
  115376. /**
  115377. * Add a new element to this block
  115378. * @param entry defines the element to add
  115379. */
  115380. addEntry(entry: T): void;
  115381. /**
  115382. * Remove an element from this block
  115383. * @param entry defines the element to remove
  115384. */
  115385. removeEntry(entry: T): void;
  115386. /**
  115387. * Add an array of elements to this block
  115388. * @param entries defines the array of elements to add
  115389. */
  115390. addEntries(entries: T[]): void;
  115391. /**
  115392. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115393. * @param frustumPlanes defines the frustum planes to test
  115394. * @param selection defines the array to store current content if selection is positive
  115395. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115396. */
  115397. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115398. /**
  115399. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115400. * @param sphereCenter defines the bounding sphere center
  115401. * @param sphereRadius defines the bounding sphere radius
  115402. * @param selection defines the array to store current content if selection is positive
  115403. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115404. */
  115405. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115406. /**
  115407. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115408. * @param ray defines the ray to test with
  115409. * @param selection defines the array to store current content if selection is positive
  115410. */
  115411. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115412. /**
  115413. * Subdivide the content into child blocks (this block will then be empty)
  115414. */
  115415. createInnerBlocks(): void;
  115416. /**
  115417. * @hidden
  115418. */
  115419. 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;
  115420. }
  115421. }
  115422. declare module BABYLON {
  115423. /**
  115424. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115425. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115426. */
  115427. export class Octree<T> {
  115428. /** 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.) */
  115429. maxDepth: number;
  115430. /**
  115431. * Blocks within the octree containing objects
  115432. */
  115433. blocks: Array<OctreeBlock<T>>;
  115434. /**
  115435. * Content stored in the octree
  115436. */
  115437. dynamicContent: T[];
  115438. private _maxBlockCapacity;
  115439. private _selectionContent;
  115440. private _creationFunc;
  115441. /**
  115442. * Creates a octree
  115443. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115444. * @param creationFunc function to be used to instatiate the octree
  115445. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115446. * @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.)
  115447. */
  115448. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115449. /** 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.) */
  115450. maxDepth?: number);
  115451. /**
  115452. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115453. * @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);
  115454. * @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);
  115455. * @param entries meshes to be added to the octree blocks
  115456. */
  115457. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115458. /**
  115459. * Adds a mesh to the octree
  115460. * @param entry Mesh to add to the octree
  115461. */
  115462. addMesh(entry: T): void;
  115463. /**
  115464. * Remove an element from the octree
  115465. * @param entry defines the element to remove
  115466. */
  115467. removeMesh(entry: T): void;
  115468. /**
  115469. * Selects an array of meshes within the frustum
  115470. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115471. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115472. * @returns array of meshes within the frustum
  115473. */
  115474. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115475. /**
  115476. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115477. * @param sphereCenter defines the bounding sphere center
  115478. * @param sphereRadius defines the bounding sphere radius
  115479. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115480. * @returns an array of objects that intersect the sphere
  115481. */
  115482. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115483. /**
  115484. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115485. * @param ray defines the ray to test with
  115486. * @returns array of intersected objects
  115487. */
  115488. intersectsRay(ray: Ray): SmartArray<T>;
  115489. /**
  115490. * Adds a mesh into the octree block if it intersects the block
  115491. */
  115492. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115493. /**
  115494. * Adds a submesh into the octree block if it intersects the block
  115495. */
  115496. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115497. }
  115498. }
  115499. declare module BABYLON {
  115500. interface Scene {
  115501. /**
  115502. * @hidden
  115503. * Backing Filed
  115504. */
  115505. _selectionOctree: Octree<AbstractMesh>;
  115506. /**
  115507. * Gets the octree used to boost mesh selection (picking)
  115508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115509. */
  115510. selectionOctree: Octree<AbstractMesh>;
  115511. /**
  115512. * Creates or updates the octree used to boost selection (picking)
  115513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115514. * @param maxCapacity defines the maximum capacity per leaf
  115515. * @param maxDepth defines the maximum depth of the octree
  115516. * @returns an octree of AbstractMesh
  115517. */
  115518. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115519. }
  115520. interface AbstractMesh {
  115521. /**
  115522. * @hidden
  115523. * Backing Field
  115524. */
  115525. _submeshesOctree: Octree<SubMesh>;
  115526. /**
  115527. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115528. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115529. * @param maxCapacity defines the maximum size of each block (64 by default)
  115530. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115531. * @returns the new octree
  115532. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115534. */
  115535. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115536. }
  115537. /**
  115538. * Defines the octree scene component responsible to manage any octrees
  115539. * in a given scene.
  115540. */
  115541. export class OctreeSceneComponent {
  115542. /**
  115543. * The component name help to identify the component in the list of scene components.
  115544. */
  115545. readonly name: string;
  115546. /**
  115547. * The scene the component belongs to.
  115548. */
  115549. scene: Scene;
  115550. /**
  115551. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115552. */
  115553. readonly checksIsEnabled: boolean;
  115554. /**
  115555. * Creates a new instance of the component for the given scene
  115556. * @param scene Defines the scene to register the component in
  115557. */
  115558. constructor(scene: Scene);
  115559. /**
  115560. * Registers the component in a given scene
  115561. */
  115562. register(): void;
  115563. /**
  115564. * Return the list of active meshes
  115565. * @returns the list of active meshes
  115566. */
  115567. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115568. /**
  115569. * Return the list of active sub meshes
  115570. * @param mesh The mesh to get the candidates sub meshes from
  115571. * @returns the list of active sub meshes
  115572. */
  115573. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115574. private _tempRay;
  115575. /**
  115576. * Return the list of sub meshes intersecting with a given local ray
  115577. * @param mesh defines the mesh to find the submesh for
  115578. * @param localRay defines the ray in local space
  115579. * @returns the list of intersecting sub meshes
  115580. */
  115581. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115582. /**
  115583. * Return the list of sub meshes colliding with a collider
  115584. * @param mesh defines the mesh to find the submesh for
  115585. * @param collider defines the collider to evaluate the collision against
  115586. * @returns the list of colliding sub meshes
  115587. */
  115588. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115589. /**
  115590. * Rebuilds the elements related to this component in case of
  115591. * context lost for instance.
  115592. */
  115593. rebuild(): void;
  115594. /**
  115595. * Disposes the component and the associated ressources.
  115596. */
  115597. dispose(): void;
  115598. }
  115599. }
  115600. declare module BABYLON {
  115601. /**
  115602. * Renders a layer on top of an existing scene
  115603. */
  115604. export class UtilityLayerRenderer implements IDisposable {
  115605. /** the original scene that will be rendered on top of */
  115606. originalScene: Scene;
  115607. private _pointerCaptures;
  115608. private _lastPointerEvents;
  115609. private static _DefaultUtilityLayer;
  115610. private static _DefaultKeepDepthUtilityLayer;
  115611. private _sharedGizmoLight;
  115612. private _renderCamera;
  115613. /**
  115614. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115615. * @returns the camera that is used when rendering the utility layer
  115616. */
  115617. getRenderCamera(): Nullable<Camera>;
  115618. /**
  115619. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115620. * @param cam the camera that should be used when rendering the utility layer
  115621. */
  115622. setRenderCamera(cam: Nullable<Camera>): void;
  115623. /**
  115624. * @hidden
  115625. * Light which used by gizmos to get light shading
  115626. */
  115627. _getSharedGizmoLight(): HemisphericLight;
  115628. /**
  115629. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115630. */
  115631. pickUtilitySceneFirst: boolean;
  115632. /**
  115633. * 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)
  115634. */
  115635. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115636. /**
  115637. * 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)
  115638. */
  115639. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115640. /**
  115641. * The scene that is rendered on top of the original scene
  115642. */
  115643. utilityLayerScene: Scene;
  115644. /**
  115645. * If the utility layer should automatically be rendered on top of existing scene
  115646. */
  115647. shouldRender: boolean;
  115648. /**
  115649. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115650. */
  115651. onlyCheckPointerDownEvents: boolean;
  115652. /**
  115653. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115654. */
  115655. processAllEvents: boolean;
  115656. /**
  115657. * Observable raised when the pointer move from the utility layer scene to the main scene
  115658. */
  115659. onPointerOutObservable: Observable<number>;
  115660. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115661. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115662. private _afterRenderObserver;
  115663. private _sceneDisposeObserver;
  115664. private _originalPointerObserver;
  115665. /**
  115666. * Instantiates a UtilityLayerRenderer
  115667. * @param originalScene the original scene that will be rendered on top of
  115668. * @param handleEvents boolean indicating if the utility layer should handle events
  115669. */
  115670. constructor(
  115671. /** the original scene that will be rendered on top of */
  115672. originalScene: Scene, handleEvents?: boolean);
  115673. private _notifyObservers;
  115674. /**
  115675. * Renders the utility layers scene on top of the original scene
  115676. */
  115677. render(): void;
  115678. /**
  115679. * Disposes of the renderer
  115680. */
  115681. dispose(): void;
  115682. private _updateCamera;
  115683. }
  115684. }
  115685. declare module BABYLON {
  115686. /**
  115687. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115688. */
  115689. export class Gizmo implements IDisposable {
  115690. /** The utility layer the gizmo will be added to */
  115691. gizmoLayer: UtilityLayerRenderer;
  115692. /**
  115693. * The root mesh of the gizmo
  115694. */
  115695. _rootMesh: Mesh;
  115696. private _attachedMesh;
  115697. /**
  115698. * Ratio for the scale of the gizmo (Default: 1)
  115699. */
  115700. scaleRatio: number;
  115701. /**
  115702. * If a custom mesh has been set (Default: false)
  115703. */
  115704. protected _customMeshSet: boolean;
  115705. /**
  115706. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115707. * * When set, interactions will be enabled
  115708. */
  115709. get attachedMesh(): Nullable<AbstractMesh>;
  115710. set attachedMesh(value: Nullable<AbstractMesh>);
  115711. /**
  115712. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115713. * @param mesh The mesh to replace the default mesh of the gizmo
  115714. */
  115715. setCustomMesh(mesh: Mesh): void;
  115716. /**
  115717. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115718. */
  115719. updateGizmoRotationToMatchAttachedMesh: boolean;
  115720. /**
  115721. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115722. */
  115723. updateGizmoPositionToMatchAttachedMesh: boolean;
  115724. /**
  115725. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115726. */
  115727. updateScale: boolean;
  115728. protected _interactionsEnabled: boolean;
  115729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115730. private _beforeRenderObserver;
  115731. private _tempVector;
  115732. /**
  115733. * Creates a gizmo
  115734. * @param gizmoLayer The utility layer the gizmo will be added to
  115735. */
  115736. constructor(
  115737. /** The utility layer the gizmo will be added to */
  115738. gizmoLayer?: UtilityLayerRenderer);
  115739. /**
  115740. * Updates the gizmo to match the attached mesh's position/rotation
  115741. */
  115742. protected _update(): void;
  115743. /**
  115744. * Disposes of the gizmo
  115745. */
  115746. dispose(): void;
  115747. }
  115748. }
  115749. declare module BABYLON {
  115750. /**
  115751. * Single plane drag gizmo
  115752. */
  115753. export class PlaneDragGizmo extends Gizmo {
  115754. /**
  115755. * Drag behavior responsible for the gizmos dragging interactions
  115756. */
  115757. dragBehavior: PointerDragBehavior;
  115758. private _pointerObserver;
  115759. /**
  115760. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115761. */
  115762. snapDistance: number;
  115763. /**
  115764. * Event that fires each time the gizmo snaps to a new location.
  115765. * * snapDistance is the the change in distance
  115766. */
  115767. onSnapObservable: Observable<{
  115768. snapDistance: number;
  115769. }>;
  115770. private _plane;
  115771. private _coloredMaterial;
  115772. private _hoverMaterial;
  115773. private _isEnabled;
  115774. private _parent;
  115775. /** @hidden */
  115776. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115777. /** @hidden */
  115778. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115779. /**
  115780. * Creates a PlaneDragGizmo
  115781. * @param gizmoLayer The utility layer the gizmo will be added to
  115782. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115783. * @param color The color of the gizmo
  115784. */
  115785. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115786. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115787. /**
  115788. * If the gizmo is enabled
  115789. */
  115790. set isEnabled(value: boolean);
  115791. get isEnabled(): boolean;
  115792. /**
  115793. * Disposes of the gizmo
  115794. */
  115795. dispose(): void;
  115796. }
  115797. }
  115798. declare module BABYLON {
  115799. /**
  115800. * Gizmo that enables dragging a mesh along 3 axis
  115801. */
  115802. export class PositionGizmo extends Gizmo {
  115803. /**
  115804. * Internal gizmo used for interactions on the x axis
  115805. */
  115806. xGizmo: AxisDragGizmo;
  115807. /**
  115808. * Internal gizmo used for interactions on the y axis
  115809. */
  115810. yGizmo: AxisDragGizmo;
  115811. /**
  115812. * Internal gizmo used for interactions on the z axis
  115813. */
  115814. zGizmo: AxisDragGizmo;
  115815. /**
  115816. * Internal gizmo used for interactions on the yz plane
  115817. */
  115818. xPlaneGizmo: PlaneDragGizmo;
  115819. /**
  115820. * Internal gizmo used for interactions on the xz plane
  115821. */
  115822. yPlaneGizmo: PlaneDragGizmo;
  115823. /**
  115824. * Internal gizmo used for interactions on the xy plane
  115825. */
  115826. zPlaneGizmo: PlaneDragGizmo;
  115827. /**
  115828. * private variables
  115829. */
  115830. private _meshAttached;
  115831. private _updateGizmoRotationToMatchAttachedMesh;
  115832. private _snapDistance;
  115833. private _scaleRatio;
  115834. /** Fires an event when any of it's sub gizmos are dragged */
  115835. onDragStartObservable: Observable<unknown>;
  115836. /** Fires an event when any of it's sub gizmos are released from dragging */
  115837. onDragEndObservable: Observable<unknown>;
  115838. /**
  115839. * If set to true, planar drag is enabled
  115840. */
  115841. private _planarGizmoEnabled;
  115842. get attachedMesh(): Nullable<AbstractMesh>;
  115843. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115844. /**
  115845. * Creates a PositionGizmo
  115846. * @param gizmoLayer The utility layer the gizmo will be added to
  115847. */
  115848. constructor(gizmoLayer?: UtilityLayerRenderer);
  115849. /**
  115850. * If the planar drag gizmo is enabled
  115851. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115852. */
  115853. set planarGizmoEnabled(value: boolean);
  115854. get planarGizmoEnabled(): boolean;
  115855. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115856. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115857. /**
  115858. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115859. */
  115860. set snapDistance(value: number);
  115861. get snapDistance(): number;
  115862. /**
  115863. * Ratio for the scale of the gizmo (Default: 1)
  115864. */
  115865. set scaleRatio(value: number);
  115866. get scaleRatio(): number;
  115867. /**
  115868. * Disposes of the gizmo
  115869. */
  115870. dispose(): void;
  115871. /**
  115872. * CustomMeshes are not supported by this gizmo
  115873. * @param mesh The mesh to replace the default mesh of the gizmo
  115874. */
  115875. setCustomMesh(mesh: Mesh): void;
  115876. }
  115877. }
  115878. declare module BABYLON {
  115879. /**
  115880. * Single axis drag gizmo
  115881. */
  115882. export class AxisDragGizmo extends Gizmo {
  115883. /**
  115884. * Drag behavior responsible for the gizmos dragging interactions
  115885. */
  115886. dragBehavior: PointerDragBehavior;
  115887. private _pointerObserver;
  115888. /**
  115889. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115890. */
  115891. snapDistance: number;
  115892. /**
  115893. * Event that fires each time the gizmo snaps to a new location.
  115894. * * snapDistance is the the change in distance
  115895. */
  115896. onSnapObservable: Observable<{
  115897. snapDistance: number;
  115898. }>;
  115899. private _isEnabled;
  115900. private _parent;
  115901. private _arrow;
  115902. private _coloredMaterial;
  115903. private _hoverMaterial;
  115904. /** @hidden */
  115905. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115906. /** @hidden */
  115907. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115908. /**
  115909. * Creates an AxisDragGizmo
  115910. * @param gizmoLayer The utility layer the gizmo will be added to
  115911. * @param dragAxis The axis which the gizmo will be able to drag on
  115912. * @param color The color of the gizmo
  115913. */
  115914. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115915. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115916. /**
  115917. * If the gizmo is enabled
  115918. */
  115919. set isEnabled(value: boolean);
  115920. get isEnabled(): boolean;
  115921. /**
  115922. * Disposes of the gizmo
  115923. */
  115924. dispose(): void;
  115925. }
  115926. }
  115927. declare module BABYLON.Debug {
  115928. /**
  115929. * The Axes viewer will show 3 axes in a specific point in space
  115930. */
  115931. export class AxesViewer {
  115932. private _xAxis;
  115933. private _yAxis;
  115934. private _zAxis;
  115935. private _scaleLinesFactor;
  115936. private _instanced;
  115937. /**
  115938. * Gets the hosting scene
  115939. */
  115940. scene: Scene;
  115941. /**
  115942. * Gets or sets a number used to scale line length
  115943. */
  115944. scaleLines: number;
  115945. /** Gets the node hierarchy used to render x-axis */
  115946. get xAxis(): TransformNode;
  115947. /** Gets the node hierarchy used to render y-axis */
  115948. get yAxis(): TransformNode;
  115949. /** Gets the node hierarchy used to render z-axis */
  115950. get zAxis(): TransformNode;
  115951. /**
  115952. * Creates a new AxesViewer
  115953. * @param scene defines the hosting scene
  115954. * @param scaleLines defines a number used to scale line length (1 by default)
  115955. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115956. * @param xAxis defines the node hierarchy used to render the x-axis
  115957. * @param yAxis defines the node hierarchy used to render the y-axis
  115958. * @param zAxis defines the node hierarchy used to render the z-axis
  115959. */
  115960. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115961. /**
  115962. * Force the viewer to update
  115963. * @param position defines the position of the viewer
  115964. * @param xaxis defines the x axis of the viewer
  115965. * @param yaxis defines the y axis of the viewer
  115966. * @param zaxis defines the z axis of the viewer
  115967. */
  115968. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115969. /**
  115970. * Creates an instance of this axes viewer.
  115971. * @returns a new axes viewer with instanced meshes
  115972. */
  115973. createInstance(): AxesViewer;
  115974. /** Releases resources */
  115975. dispose(): void;
  115976. private static _SetRenderingGroupId;
  115977. }
  115978. }
  115979. declare module BABYLON.Debug {
  115980. /**
  115981. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115982. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115983. */
  115984. export class BoneAxesViewer extends AxesViewer {
  115985. /**
  115986. * Gets or sets the target mesh where to display the axes viewer
  115987. */
  115988. mesh: Nullable<Mesh>;
  115989. /**
  115990. * Gets or sets the target bone where to display the axes viewer
  115991. */
  115992. bone: Nullable<Bone>;
  115993. /** Gets current position */
  115994. pos: Vector3;
  115995. /** Gets direction of X axis */
  115996. xaxis: Vector3;
  115997. /** Gets direction of Y axis */
  115998. yaxis: Vector3;
  115999. /** Gets direction of Z axis */
  116000. zaxis: Vector3;
  116001. /**
  116002. * Creates a new BoneAxesViewer
  116003. * @param scene defines the hosting scene
  116004. * @param bone defines the target bone
  116005. * @param mesh defines the target mesh
  116006. * @param scaleLines defines a scaling factor for line length (1 by default)
  116007. */
  116008. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  116009. /**
  116010. * Force the viewer to update
  116011. */
  116012. update(): void;
  116013. /** Releases resources */
  116014. dispose(): void;
  116015. }
  116016. }
  116017. declare module BABYLON {
  116018. /**
  116019. * Interface used to define scene explorer extensibility option
  116020. */
  116021. export interface IExplorerExtensibilityOption {
  116022. /**
  116023. * Define the option label
  116024. */
  116025. label: string;
  116026. /**
  116027. * Defines the action to execute on click
  116028. */
  116029. action: (entity: any) => void;
  116030. }
  116031. /**
  116032. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  116033. */
  116034. export interface IExplorerExtensibilityGroup {
  116035. /**
  116036. * Defines a predicate to test if a given type mut be extended
  116037. */
  116038. predicate: (entity: any) => boolean;
  116039. /**
  116040. * Gets the list of options added to a type
  116041. */
  116042. entries: IExplorerExtensibilityOption[];
  116043. }
  116044. /**
  116045. * Interface used to define the options to use to create the Inspector
  116046. */
  116047. export interface IInspectorOptions {
  116048. /**
  116049. * Display in overlay mode (default: false)
  116050. */
  116051. overlay?: boolean;
  116052. /**
  116053. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  116054. */
  116055. globalRoot?: HTMLElement;
  116056. /**
  116057. * Display the Scene explorer
  116058. */
  116059. showExplorer?: boolean;
  116060. /**
  116061. * Display the property inspector
  116062. */
  116063. showInspector?: boolean;
  116064. /**
  116065. * Display in embed mode (both panes on the right)
  116066. */
  116067. embedMode?: boolean;
  116068. /**
  116069. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  116070. */
  116071. handleResize?: boolean;
  116072. /**
  116073. * Allow the panes to popup (default: true)
  116074. */
  116075. enablePopup?: boolean;
  116076. /**
  116077. * Allow the panes to be closed by users (default: true)
  116078. */
  116079. enableClose?: boolean;
  116080. /**
  116081. * Optional list of extensibility entries
  116082. */
  116083. explorerExtensibility?: IExplorerExtensibilityGroup[];
  116084. /**
  116085. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  116086. */
  116087. inspectorURL?: string;
  116088. /**
  116089. * Optional initial tab (default to DebugLayerTab.Properties)
  116090. */
  116091. initialTab?: DebugLayerTab;
  116092. }
  116093. interface Scene {
  116094. /**
  116095. * @hidden
  116096. * Backing field
  116097. */
  116098. _debugLayer: DebugLayer;
  116099. /**
  116100. * Gets the debug layer (aka Inspector) associated with the scene
  116101. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116102. */
  116103. debugLayer: DebugLayer;
  116104. }
  116105. /**
  116106. * Enum of inspector action tab
  116107. */
  116108. export enum DebugLayerTab {
  116109. /**
  116110. * Properties tag (default)
  116111. */
  116112. Properties = 0,
  116113. /**
  116114. * Debug tab
  116115. */
  116116. Debug = 1,
  116117. /**
  116118. * Statistics tab
  116119. */
  116120. Statistics = 2,
  116121. /**
  116122. * Tools tab
  116123. */
  116124. Tools = 3,
  116125. /**
  116126. * Settings tab
  116127. */
  116128. Settings = 4
  116129. }
  116130. /**
  116131. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116132. * what is happening in your scene
  116133. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116134. */
  116135. export class DebugLayer {
  116136. /**
  116137. * Define the url to get the inspector script from.
  116138. * By default it uses the babylonjs CDN.
  116139. * @ignoreNaming
  116140. */
  116141. static InspectorURL: string;
  116142. private _scene;
  116143. private BJSINSPECTOR;
  116144. private _onPropertyChangedObservable?;
  116145. /**
  116146. * Observable triggered when a property is changed through the inspector.
  116147. */
  116148. get onPropertyChangedObservable(): any;
  116149. /**
  116150. * Instantiates a new debug layer.
  116151. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116152. * what is happening in your scene
  116153. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116154. * @param scene Defines the scene to inspect
  116155. */
  116156. constructor(scene: Scene);
  116157. /** Creates the inspector window. */
  116158. private _createInspector;
  116159. /**
  116160. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  116161. * @param entity defines the entity to select
  116162. * @param lineContainerTitle defines the specific block to highlight
  116163. */
  116164. select(entity: any, lineContainerTitle?: string): void;
  116165. /** Get the inspector from bundle or global */
  116166. private _getGlobalInspector;
  116167. /**
  116168. * Get if the inspector is visible or not.
  116169. * @returns true if visible otherwise, false
  116170. */
  116171. isVisible(): boolean;
  116172. /**
  116173. * Hide the inspector and close its window.
  116174. */
  116175. hide(): void;
  116176. /**
  116177. * Launch the debugLayer.
  116178. * @param config Define the configuration of the inspector
  116179. * @return a promise fulfilled when the debug layer is visible
  116180. */
  116181. show(config?: IInspectorOptions): Promise<DebugLayer>;
  116182. }
  116183. }
  116184. declare module BABYLON {
  116185. /**
  116186. * Class containing static functions to help procedurally build meshes
  116187. */
  116188. export class BoxBuilder {
  116189. /**
  116190. * Creates a box mesh
  116191. * * The parameter `size` sets the size (float) of each box side (default 1)
  116192. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116193. * * 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)
  116194. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116199. * @param name defines the name of the mesh
  116200. * @param options defines the options used to create the mesh
  116201. * @param scene defines the hosting scene
  116202. * @returns the box mesh
  116203. */
  116204. static CreateBox(name: string, options: {
  116205. size?: number;
  116206. width?: number;
  116207. height?: number;
  116208. depth?: number;
  116209. faceUV?: Vector4[];
  116210. faceColors?: Color4[];
  116211. sideOrientation?: number;
  116212. frontUVs?: Vector4;
  116213. backUVs?: Vector4;
  116214. wrap?: boolean;
  116215. topBaseAt?: number;
  116216. bottomBaseAt?: number;
  116217. updatable?: boolean;
  116218. }, scene?: Nullable<Scene>): Mesh;
  116219. }
  116220. }
  116221. declare module BABYLON {
  116222. /**
  116223. * Class containing static functions to help procedurally build meshes
  116224. */
  116225. export class SphereBuilder {
  116226. /**
  116227. * Creates a sphere mesh
  116228. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116229. * * 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`)
  116230. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116231. * * 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
  116232. * * 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)
  116233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116236. * @param name defines the name of the mesh
  116237. * @param options defines the options used to create the mesh
  116238. * @param scene defines the hosting scene
  116239. * @returns the sphere mesh
  116240. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116241. */
  116242. static CreateSphere(name: string, options: {
  116243. segments?: number;
  116244. diameter?: number;
  116245. diameterX?: number;
  116246. diameterY?: number;
  116247. diameterZ?: number;
  116248. arc?: number;
  116249. slice?: number;
  116250. sideOrientation?: number;
  116251. frontUVs?: Vector4;
  116252. backUVs?: Vector4;
  116253. updatable?: boolean;
  116254. }, scene?: Nullable<Scene>): Mesh;
  116255. }
  116256. }
  116257. declare module BABYLON.Debug {
  116258. /**
  116259. * Used to show the physics impostor around the specific mesh
  116260. */
  116261. export class PhysicsViewer {
  116262. /** @hidden */
  116263. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116264. /** @hidden */
  116265. protected _meshes: Array<Nullable<AbstractMesh>>;
  116266. /** @hidden */
  116267. protected _scene: Nullable<Scene>;
  116268. /** @hidden */
  116269. protected _numMeshes: number;
  116270. /** @hidden */
  116271. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116272. private _renderFunction;
  116273. private _utilityLayer;
  116274. private _debugBoxMesh;
  116275. private _debugSphereMesh;
  116276. private _debugCylinderMesh;
  116277. private _debugMaterial;
  116278. private _debugMeshMeshes;
  116279. /**
  116280. * Creates a new PhysicsViewer
  116281. * @param scene defines the hosting scene
  116282. */
  116283. constructor(scene: Scene);
  116284. /** @hidden */
  116285. protected _updateDebugMeshes(): void;
  116286. /**
  116287. * Renders a specified physic impostor
  116288. * @param impostor defines the impostor to render
  116289. * @param targetMesh defines the mesh represented by the impostor
  116290. * @returns the new debug mesh used to render the impostor
  116291. */
  116292. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116293. /**
  116294. * Hides a specified physic impostor
  116295. * @param impostor defines the impostor to hide
  116296. */
  116297. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116298. private _getDebugMaterial;
  116299. private _getDebugBoxMesh;
  116300. private _getDebugSphereMesh;
  116301. private _getDebugCylinderMesh;
  116302. private _getDebugMeshMesh;
  116303. private _getDebugMesh;
  116304. /** Releases all resources */
  116305. dispose(): void;
  116306. }
  116307. }
  116308. declare module BABYLON {
  116309. /**
  116310. * Class containing static functions to help procedurally build meshes
  116311. */
  116312. export class LinesBuilder {
  116313. /**
  116314. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116315. * * 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
  116316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116317. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116318. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116319. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116321. * * 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
  116322. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116325. * @param name defines the name of the new line system
  116326. * @param options defines the options used to create the line system
  116327. * @param scene defines the hosting scene
  116328. * @returns a new line system mesh
  116329. */
  116330. static CreateLineSystem(name: string, options: {
  116331. lines: Vector3[][];
  116332. updatable?: boolean;
  116333. instance?: Nullable<LinesMesh>;
  116334. colors?: Nullable<Color4[][]>;
  116335. useVertexAlpha?: boolean;
  116336. }, scene: Nullable<Scene>): LinesMesh;
  116337. /**
  116338. * Creates a line mesh
  116339. * 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
  116340. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116341. * * The parameter `points` is an array successive Vector3
  116342. * * 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
  116343. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116344. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116345. * * When updating an instance, remember that only point positions can change, not the number of points
  116346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116348. * @param name defines the name of the new line system
  116349. * @param options defines the options used to create the line system
  116350. * @param scene defines the hosting scene
  116351. * @returns a new line mesh
  116352. */
  116353. static CreateLines(name: string, options: {
  116354. points: Vector3[];
  116355. updatable?: boolean;
  116356. instance?: Nullable<LinesMesh>;
  116357. colors?: Color4[];
  116358. useVertexAlpha?: boolean;
  116359. }, scene?: Nullable<Scene>): LinesMesh;
  116360. /**
  116361. * Creates a dashed line mesh
  116362. * * 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
  116363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116364. * * The parameter `points` is an array successive Vector3
  116365. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116366. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116367. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116368. * * 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
  116369. * * When updating an instance, remember that only point positions can change, not the number of points
  116370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116371. * @param name defines the name of the mesh
  116372. * @param options defines the options used to create the mesh
  116373. * @param scene defines the hosting scene
  116374. * @returns the dashed line mesh
  116375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116376. */
  116377. static CreateDashedLines(name: string, options: {
  116378. points: Vector3[];
  116379. dashSize?: number;
  116380. gapSize?: number;
  116381. dashNb?: number;
  116382. updatable?: boolean;
  116383. instance?: LinesMesh;
  116384. }, scene?: Nullable<Scene>): LinesMesh;
  116385. }
  116386. }
  116387. declare module BABYLON {
  116388. /**
  116389. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116390. * in order to better appreciate the issue one might have.
  116391. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116392. */
  116393. export class RayHelper {
  116394. /**
  116395. * Defines the ray we are currently tryin to visualize.
  116396. */
  116397. ray: Nullable<Ray>;
  116398. private _renderPoints;
  116399. private _renderLine;
  116400. private _renderFunction;
  116401. private _scene;
  116402. private _updateToMeshFunction;
  116403. private _attachedToMesh;
  116404. private _meshSpaceDirection;
  116405. private _meshSpaceOrigin;
  116406. /**
  116407. * Helper function to create a colored helper in a scene in one line.
  116408. * @param ray Defines the ray we are currently tryin to visualize
  116409. * @param scene Defines the scene the ray is used in
  116410. * @param color Defines the color we want to see the ray in
  116411. * @returns The newly created ray helper.
  116412. */
  116413. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116414. /**
  116415. * Instantiate a new ray helper.
  116416. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116417. * in order to better appreciate the issue one might have.
  116418. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116419. * @param ray Defines the ray we are currently tryin to visualize
  116420. */
  116421. constructor(ray: Ray);
  116422. /**
  116423. * Shows the ray we are willing to debug.
  116424. * @param scene Defines the scene the ray needs to be rendered in
  116425. * @param color Defines the color the ray needs to be rendered in
  116426. */
  116427. show(scene: Scene, color?: Color3): void;
  116428. /**
  116429. * Hides the ray we are debugging.
  116430. */
  116431. hide(): void;
  116432. private _render;
  116433. /**
  116434. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116435. * @param mesh Defines the mesh we want the helper attached to
  116436. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116437. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116438. * @param length Defines the length of the ray
  116439. */
  116440. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116441. /**
  116442. * Detach the ray helper from the mesh it has previously been attached to.
  116443. */
  116444. detachFromMesh(): void;
  116445. private _updateToMesh;
  116446. /**
  116447. * Dispose the helper and release its associated resources.
  116448. */
  116449. dispose(): void;
  116450. }
  116451. }
  116452. declare module BABYLON.Debug {
  116453. /**
  116454. * Class used to render a debug view of a given skeleton
  116455. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116456. */
  116457. export class SkeletonViewer {
  116458. /** defines the skeleton to render */
  116459. skeleton: Skeleton;
  116460. /** defines the mesh attached to the skeleton */
  116461. mesh: AbstractMesh;
  116462. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116463. autoUpdateBonesMatrices: boolean;
  116464. /** defines the rendering group id to use with the viewer */
  116465. renderingGroupId: number;
  116466. /** Gets or sets the color used to render the skeleton */
  116467. color: Color3;
  116468. private _scene;
  116469. private _debugLines;
  116470. private _debugMesh;
  116471. private _isEnabled;
  116472. private _renderFunction;
  116473. private _utilityLayer;
  116474. /**
  116475. * Returns the mesh used to render the bones
  116476. */
  116477. get debugMesh(): Nullable<LinesMesh>;
  116478. /**
  116479. * Creates a new SkeletonViewer
  116480. * @param skeleton defines the skeleton to render
  116481. * @param mesh defines the mesh attached to the skeleton
  116482. * @param scene defines the hosting scene
  116483. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116484. * @param renderingGroupId defines the rendering group id to use with the viewer
  116485. */
  116486. constructor(
  116487. /** defines the skeleton to render */
  116488. skeleton: Skeleton,
  116489. /** defines the mesh attached to the skeleton */
  116490. mesh: AbstractMesh, scene: Scene,
  116491. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116492. autoUpdateBonesMatrices?: boolean,
  116493. /** defines the rendering group id to use with the viewer */
  116494. renderingGroupId?: number);
  116495. /** Gets or sets a boolean indicating if the viewer is enabled */
  116496. set isEnabled(value: boolean);
  116497. get isEnabled(): boolean;
  116498. private _getBonePosition;
  116499. private _getLinesForBonesWithLength;
  116500. private _getLinesForBonesNoLength;
  116501. /** Update the viewer to sync with current skeleton state */
  116502. update(): void;
  116503. /** Release associated resources */
  116504. dispose(): void;
  116505. }
  116506. }
  116507. declare module BABYLON {
  116508. /**
  116509. * Options to create the null engine
  116510. */
  116511. export class NullEngineOptions {
  116512. /**
  116513. * Render width (Default: 512)
  116514. */
  116515. renderWidth: number;
  116516. /**
  116517. * Render height (Default: 256)
  116518. */
  116519. renderHeight: number;
  116520. /**
  116521. * Texture size (Default: 512)
  116522. */
  116523. textureSize: number;
  116524. /**
  116525. * If delta time between frames should be constant
  116526. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116527. */
  116528. deterministicLockstep: boolean;
  116529. /**
  116530. * Maximum about of steps between frames (Default: 4)
  116531. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116532. */
  116533. lockstepMaxSteps: number;
  116534. }
  116535. /**
  116536. * The null engine class provides support for headless version of babylon.js.
  116537. * This can be used in server side scenario or for testing purposes
  116538. */
  116539. export class NullEngine extends Engine {
  116540. private _options;
  116541. /**
  116542. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116544. * @returns true if engine is in deterministic lock step mode
  116545. */
  116546. isDeterministicLockStep(): boolean;
  116547. /**
  116548. * Gets the max steps when engine is running in deterministic lock step
  116549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116550. * @returns the max steps
  116551. */
  116552. getLockstepMaxSteps(): number;
  116553. /**
  116554. * Gets the current hardware scaling level.
  116555. * By default the hardware scaling level is computed from the window device ratio.
  116556. * 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.
  116557. * @returns a number indicating the current hardware scaling level
  116558. */
  116559. getHardwareScalingLevel(): number;
  116560. constructor(options?: NullEngineOptions);
  116561. /**
  116562. * Creates a vertex buffer
  116563. * @param vertices the data for the vertex buffer
  116564. * @returns the new WebGL static buffer
  116565. */
  116566. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116567. /**
  116568. * Creates a new index buffer
  116569. * @param indices defines the content of the index buffer
  116570. * @param updatable defines if the index buffer must be updatable
  116571. * @returns a new webGL buffer
  116572. */
  116573. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116574. /**
  116575. * Clear the current render buffer or the current render target (if any is set up)
  116576. * @param color defines the color to use
  116577. * @param backBuffer defines if the back buffer must be cleared
  116578. * @param depth defines if the depth buffer must be cleared
  116579. * @param stencil defines if the stencil buffer must be cleared
  116580. */
  116581. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116582. /**
  116583. * Gets the current render width
  116584. * @param useScreen defines if screen size must be used (or the current render target if any)
  116585. * @returns a number defining the current render width
  116586. */
  116587. getRenderWidth(useScreen?: boolean): number;
  116588. /**
  116589. * Gets the current render height
  116590. * @param useScreen defines if screen size must be used (or the current render target if any)
  116591. * @returns a number defining the current render height
  116592. */
  116593. getRenderHeight(useScreen?: boolean): number;
  116594. /**
  116595. * Set the WebGL's viewport
  116596. * @param viewport defines the viewport element to be used
  116597. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116598. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116599. */
  116600. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116601. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116602. /**
  116603. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116604. * @param pipelineContext defines the pipeline context to use
  116605. * @param uniformsNames defines the list of uniform names
  116606. * @returns an array of webGL uniform locations
  116607. */
  116608. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116609. /**
  116610. * Gets the lsit of active attributes for a given webGL program
  116611. * @param pipelineContext defines the pipeline context to use
  116612. * @param attributesNames defines the list of attribute names to get
  116613. * @returns an array of indices indicating the offset of each attribute
  116614. */
  116615. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116616. /**
  116617. * Binds an effect to the webGL context
  116618. * @param effect defines the effect to bind
  116619. */
  116620. bindSamplers(effect: Effect): void;
  116621. /**
  116622. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116623. * @param effect defines the effect to activate
  116624. */
  116625. enableEffect(effect: Effect): void;
  116626. /**
  116627. * Set various states to the webGL context
  116628. * @param culling defines backface culling state
  116629. * @param zOffset defines the value to apply to zOffset (0 by default)
  116630. * @param force defines if states must be applied even if cache is up to date
  116631. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116632. */
  116633. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116634. /**
  116635. * Set the value of an uniform to an array of int32
  116636. * @param uniform defines the webGL uniform location where to store the value
  116637. * @param array defines the array of int32 to store
  116638. */
  116639. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116640. /**
  116641. * Set the value of an uniform to an array of int32 (stored as vec2)
  116642. * @param uniform defines the webGL uniform location where to store the value
  116643. * @param array defines the array of int32 to store
  116644. */
  116645. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116646. /**
  116647. * Set the value of an uniform to an array of int32 (stored as vec3)
  116648. * @param uniform defines the webGL uniform location where to store the value
  116649. * @param array defines the array of int32 to store
  116650. */
  116651. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116652. /**
  116653. * Set the value of an uniform to an array of int32 (stored as vec4)
  116654. * @param uniform defines the webGL uniform location where to store the value
  116655. * @param array defines the array of int32 to store
  116656. */
  116657. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116658. /**
  116659. * Set the value of an uniform to an array of float32
  116660. * @param uniform defines the webGL uniform location where to store the value
  116661. * @param array defines the array of float32 to store
  116662. */
  116663. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116664. /**
  116665. * Set the value of an uniform to an array of float32 (stored as vec2)
  116666. * @param uniform defines the webGL uniform location where to store the value
  116667. * @param array defines the array of float32 to store
  116668. */
  116669. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116670. /**
  116671. * Set the value of an uniform to an array of float32 (stored as vec3)
  116672. * @param uniform defines the webGL uniform location where to store the value
  116673. * @param array defines the array of float32 to store
  116674. */
  116675. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116676. /**
  116677. * Set the value of an uniform to an array of float32 (stored as vec4)
  116678. * @param uniform defines the webGL uniform location where to store the value
  116679. * @param array defines the array of float32 to store
  116680. */
  116681. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116682. /**
  116683. * Set the value of an uniform to an array of number
  116684. * @param uniform defines the webGL uniform location where to store the value
  116685. * @param array defines the array of number to store
  116686. */
  116687. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116688. /**
  116689. * Set the value of an uniform to an array of number (stored as vec2)
  116690. * @param uniform defines the webGL uniform location where to store the value
  116691. * @param array defines the array of number to store
  116692. */
  116693. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116694. /**
  116695. * Set the value of an uniform to an array of number (stored as vec3)
  116696. * @param uniform defines the webGL uniform location where to store the value
  116697. * @param array defines the array of number to store
  116698. */
  116699. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116700. /**
  116701. * Set the value of an uniform to an array of number (stored as vec4)
  116702. * @param uniform defines the webGL uniform location where to store the value
  116703. * @param array defines the array of number to store
  116704. */
  116705. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116706. /**
  116707. * Set the value of an uniform to an array of float32 (stored as matrices)
  116708. * @param uniform defines the webGL uniform location where to store the value
  116709. * @param matrices defines the array of float32 to store
  116710. */
  116711. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116712. /**
  116713. * Set the value of an uniform to a matrix (3x3)
  116714. * @param uniform defines the webGL uniform location where to store the value
  116715. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116716. */
  116717. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116718. /**
  116719. * Set the value of an uniform to a matrix (2x2)
  116720. * @param uniform defines the webGL uniform location where to store the value
  116721. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116722. */
  116723. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116724. /**
  116725. * Set the value of an uniform to a number (float)
  116726. * @param uniform defines the webGL uniform location where to store the value
  116727. * @param value defines the float number to store
  116728. */
  116729. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116730. /**
  116731. * Set the value of an uniform to a vec2
  116732. * @param uniform defines the webGL uniform location where to store the value
  116733. * @param x defines the 1st component of the value
  116734. * @param y defines the 2nd component of the value
  116735. */
  116736. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116737. /**
  116738. * Set the value of an uniform to a vec3
  116739. * @param uniform defines the webGL uniform location where to store the value
  116740. * @param x defines the 1st component of the value
  116741. * @param y defines the 2nd component of the value
  116742. * @param z defines the 3rd component of the value
  116743. */
  116744. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116745. /**
  116746. * Set the value of an uniform to a boolean
  116747. * @param uniform defines the webGL uniform location where to store the value
  116748. * @param bool defines the boolean to store
  116749. */
  116750. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116751. /**
  116752. * Set the value of an uniform to a vec4
  116753. * @param uniform defines the webGL uniform location where to store the value
  116754. * @param x defines the 1st component of the value
  116755. * @param y defines the 2nd component of the value
  116756. * @param z defines the 3rd component of the value
  116757. * @param w defines the 4th component of the value
  116758. */
  116759. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116760. /**
  116761. * Sets the current alpha mode
  116762. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116763. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116765. */
  116766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116767. /**
  116768. * Bind webGl buffers directly to the webGL context
  116769. * @param vertexBuffers defines the vertex buffer to bind
  116770. * @param indexBuffer defines the index buffer to bind
  116771. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116772. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116773. * @param effect defines the effect associated with the vertex buffer
  116774. */
  116775. bindBuffers(vertexBuffers: {
  116776. [key: string]: VertexBuffer;
  116777. }, indexBuffer: DataBuffer, effect: Effect): void;
  116778. /**
  116779. * Force the entire cache to be cleared
  116780. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116781. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116782. */
  116783. wipeCaches(bruteForce?: boolean): void;
  116784. /**
  116785. * Send a draw order
  116786. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116787. * @param indexStart defines the starting index
  116788. * @param indexCount defines the number of index to draw
  116789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116790. */
  116791. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116792. /**
  116793. * Draw a list of indexed primitives
  116794. * @param fillMode defines the primitive to use
  116795. * @param indexStart defines the starting index
  116796. * @param indexCount defines the number of index to draw
  116797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116798. */
  116799. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116800. /**
  116801. * Draw a list of unindexed primitives
  116802. * @param fillMode defines the primitive to use
  116803. * @param verticesStart defines the index of first vertex to draw
  116804. * @param verticesCount defines the count of vertices to draw
  116805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116806. */
  116807. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116808. /** @hidden */
  116809. _createTexture(): WebGLTexture;
  116810. /** @hidden */
  116811. _releaseTexture(texture: InternalTexture): void;
  116812. /**
  116813. * Usually called from Texture.ts.
  116814. * Passed information to create a WebGLTexture
  116815. * @param urlArg defines a value which contains one of the following:
  116816. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116817. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116818. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116820. * @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)
  116821. * @param scene needed for loading to the correct scene
  116822. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116823. * @param onLoad optional callback to be called upon successful completion
  116824. * @param onError optional callback to be called upon failure
  116825. * @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
  116826. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116827. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116828. * @param forcedExtension defines the extension to use to pick the right loader
  116829. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116830. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116831. */
  116832. 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;
  116833. /**
  116834. * Creates a new render target texture
  116835. * @param size defines the size of the texture
  116836. * @param options defines the options used to create the texture
  116837. * @returns a new render target texture stored in an InternalTexture
  116838. */
  116839. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116840. /**
  116841. * Update the sampling mode of a given texture
  116842. * @param samplingMode defines the required sampling mode
  116843. * @param texture defines the texture to update
  116844. */
  116845. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116846. /**
  116847. * Binds the frame buffer to the specified texture.
  116848. * @param texture The texture to render to or null for the default canvas
  116849. * @param faceIndex The face of the texture to render to in case of cube texture
  116850. * @param requiredWidth The width of the target to render to
  116851. * @param requiredHeight The height of the target to render to
  116852. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116853. * @param depthStencilTexture The depth stencil texture to use to render
  116854. * @param lodLevel defines le lod level to bind to the frame buffer
  116855. */
  116856. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116857. /**
  116858. * Unbind the current render target texture from the webGL context
  116859. * @param texture defines the render target texture to unbind
  116860. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116861. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116862. */
  116863. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116864. /**
  116865. * Creates a dynamic vertex buffer
  116866. * @param vertices the data for the dynamic vertex buffer
  116867. * @returns the new WebGL dynamic buffer
  116868. */
  116869. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116870. /**
  116871. * Update the content of a dynamic texture
  116872. * @param texture defines the texture to update
  116873. * @param canvas defines the canvas containing the source
  116874. * @param invertY defines if data must be stored with Y axis inverted
  116875. * @param premulAlpha defines if alpha is stored as premultiplied
  116876. * @param format defines the format of the data
  116877. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116878. */
  116879. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116880. /**
  116881. * Gets a boolean indicating if all created effects are ready
  116882. * @returns true if all effects are ready
  116883. */
  116884. areAllEffectsReady(): boolean;
  116885. /**
  116886. * @hidden
  116887. * Get the current error code of the webGL context
  116888. * @returns the error code
  116889. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116890. */
  116891. getError(): number;
  116892. /** @hidden */
  116893. _getUnpackAlignement(): number;
  116894. /** @hidden */
  116895. _unpackFlipY(value: boolean): void;
  116896. /**
  116897. * Update a dynamic index buffer
  116898. * @param indexBuffer defines the target index buffer
  116899. * @param indices defines the data to update
  116900. * @param offset defines the offset in the target index buffer where update should start
  116901. */
  116902. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116903. /**
  116904. * Updates a dynamic vertex buffer.
  116905. * @param vertexBuffer the vertex buffer to update
  116906. * @param vertices the data used to update the vertex buffer
  116907. * @param byteOffset the byte offset of the data (optional)
  116908. * @param byteLength the byte length of the data (optional)
  116909. */
  116910. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116911. /** @hidden */
  116912. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116913. /** @hidden */
  116914. _bindTexture(channel: number, texture: InternalTexture): void;
  116915. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116916. /**
  116917. * 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
  116918. */
  116919. releaseEffects(): void;
  116920. displayLoadingUI(): void;
  116921. hideLoadingUI(): void;
  116922. /** @hidden */
  116923. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116924. /** @hidden */
  116925. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116926. /** @hidden */
  116927. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116928. /** @hidden */
  116929. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116930. }
  116931. }
  116932. declare module BABYLON {
  116933. /** @hidden */
  116934. export class _OcclusionDataStorage {
  116935. /** @hidden */
  116936. occlusionInternalRetryCounter: number;
  116937. /** @hidden */
  116938. isOcclusionQueryInProgress: boolean;
  116939. /** @hidden */
  116940. isOccluded: boolean;
  116941. /** @hidden */
  116942. occlusionRetryCount: number;
  116943. /** @hidden */
  116944. occlusionType: number;
  116945. /** @hidden */
  116946. occlusionQueryAlgorithmType: number;
  116947. }
  116948. interface Engine {
  116949. /**
  116950. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116951. * @return the new query
  116952. */
  116953. createQuery(): WebGLQuery;
  116954. /**
  116955. * Delete and release a webGL query
  116956. * @param query defines the query to delete
  116957. * @return the current engine
  116958. */
  116959. deleteQuery(query: WebGLQuery): Engine;
  116960. /**
  116961. * Check if a given query has resolved and got its value
  116962. * @param query defines the query to check
  116963. * @returns true if the query got its value
  116964. */
  116965. isQueryResultAvailable(query: WebGLQuery): boolean;
  116966. /**
  116967. * Gets the value of a given query
  116968. * @param query defines the query to check
  116969. * @returns the value of the query
  116970. */
  116971. getQueryResult(query: WebGLQuery): number;
  116972. /**
  116973. * Initiates an occlusion query
  116974. * @param algorithmType defines the algorithm to use
  116975. * @param query defines the query to use
  116976. * @returns the current engine
  116977. * @see http://doc.babylonjs.com/features/occlusionquery
  116978. */
  116979. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116980. /**
  116981. * Ends an occlusion query
  116982. * @see http://doc.babylonjs.com/features/occlusionquery
  116983. * @param algorithmType defines the algorithm to use
  116984. * @returns the current engine
  116985. */
  116986. endOcclusionQuery(algorithmType: number): Engine;
  116987. /**
  116988. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116989. * Please note that only one query can be issued at a time
  116990. * @returns a time token used to track the time span
  116991. */
  116992. startTimeQuery(): Nullable<_TimeToken>;
  116993. /**
  116994. * Ends a time query
  116995. * @param token defines the token used to measure the time span
  116996. * @returns the time spent (in ns)
  116997. */
  116998. endTimeQuery(token: _TimeToken): int;
  116999. /** @hidden */
  117000. _currentNonTimestampToken: Nullable<_TimeToken>;
  117001. /** @hidden */
  117002. _createTimeQuery(): WebGLQuery;
  117003. /** @hidden */
  117004. _deleteTimeQuery(query: WebGLQuery): void;
  117005. /** @hidden */
  117006. _getGlAlgorithmType(algorithmType: number): number;
  117007. /** @hidden */
  117008. _getTimeQueryResult(query: WebGLQuery): any;
  117009. /** @hidden */
  117010. _getTimeQueryAvailability(query: WebGLQuery): any;
  117011. }
  117012. interface AbstractMesh {
  117013. /**
  117014. * Backing filed
  117015. * @hidden
  117016. */
  117017. __occlusionDataStorage: _OcclusionDataStorage;
  117018. /**
  117019. * Access property
  117020. * @hidden
  117021. */
  117022. _occlusionDataStorage: _OcclusionDataStorage;
  117023. /**
  117024. * 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.
  117025. * The default value is -1 which means don't break the query and wait till the result
  117026. * @see http://doc.babylonjs.com/features/occlusionquery
  117027. */
  117028. occlusionRetryCount: number;
  117029. /**
  117030. * 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:
  117031. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  117032. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  117033. * * 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.
  117034. * @see http://doc.babylonjs.com/features/occlusionquery
  117035. */
  117036. occlusionType: number;
  117037. /**
  117038. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  117039. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  117040. * * 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.
  117041. * @see http://doc.babylonjs.com/features/occlusionquery
  117042. */
  117043. occlusionQueryAlgorithmType: number;
  117044. /**
  117045. * 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
  117046. * @see http://doc.babylonjs.com/features/occlusionquery
  117047. */
  117048. isOccluded: boolean;
  117049. /**
  117050. * Flag to check the progress status of the query
  117051. * @see http://doc.babylonjs.com/features/occlusionquery
  117052. */
  117053. isOcclusionQueryInProgress: boolean;
  117054. }
  117055. }
  117056. declare module BABYLON {
  117057. /** @hidden */
  117058. export var _forceTransformFeedbackToBundle: boolean;
  117059. interface Engine {
  117060. /**
  117061. * Creates a webGL transform feedback object
  117062. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  117063. * @returns the webGL transform feedback object
  117064. */
  117065. createTransformFeedback(): WebGLTransformFeedback;
  117066. /**
  117067. * Delete a webGL transform feedback object
  117068. * @param value defines the webGL transform feedback object to delete
  117069. */
  117070. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  117071. /**
  117072. * Bind a webGL transform feedback object to the webgl context
  117073. * @param value defines the webGL transform feedback object to bind
  117074. */
  117075. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  117076. /**
  117077. * Begins a transform feedback operation
  117078. * @param usePoints defines if points or triangles must be used
  117079. */
  117080. beginTransformFeedback(usePoints: boolean): void;
  117081. /**
  117082. * Ends a transform feedback operation
  117083. */
  117084. endTransformFeedback(): void;
  117085. /**
  117086. * Specify the varyings to use with transform feedback
  117087. * @param program defines the associated webGL program
  117088. * @param value defines the list of strings representing the varying names
  117089. */
  117090. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  117091. /**
  117092. * Bind a webGL buffer for a transform feedback operation
  117093. * @param value defines the webGL buffer to bind
  117094. */
  117095. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  117096. }
  117097. }
  117098. declare module BABYLON {
  117099. /**
  117100. * Creation options of the multi render target texture.
  117101. */
  117102. export interface IMultiRenderTargetOptions {
  117103. /**
  117104. * Define if the texture needs to create mip maps after render.
  117105. */
  117106. generateMipMaps?: boolean;
  117107. /**
  117108. * Define the types of all the draw buffers we want to create
  117109. */
  117110. types?: number[];
  117111. /**
  117112. * Define the sampling modes of all the draw buffers we want to create
  117113. */
  117114. samplingModes?: number[];
  117115. /**
  117116. * Define if a depth buffer is required
  117117. */
  117118. generateDepthBuffer?: boolean;
  117119. /**
  117120. * Define if a stencil buffer is required
  117121. */
  117122. generateStencilBuffer?: boolean;
  117123. /**
  117124. * Define if a depth texture is required instead of a depth buffer
  117125. */
  117126. generateDepthTexture?: boolean;
  117127. /**
  117128. * Define the number of desired draw buffers
  117129. */
  117130. textureCount?: number;
  117131. /**
  117132. * Define if aspect ratio should be adapted to the texture or stay the scene one
  117133. */
  117134. doNotChangeAspectRatio?: boolean;
  117135. /**
  117136. * Define the default type of the buffers we are creating
  117137. */
  117138. defaultType?: number;
  117139. }
  117140. /**
  117141. * A multi render target, like a render target provides the ability to render to a texture.
  117142. * Unlike the render target, it can render to several draw buffers in one draw.
  117143. * This is specially interesting in deferred rendering or for any effects requiring more than
  117144. * just one color from a single pass.
  117145. */
  117146. export class MultiRenderTarget extends RenderTargetTexture {
  117147. private _internalTextures;
  117148. private _textures;
  117149. private _multiRenderTargetOptions;
  117150. /**
  117151. * Get if draw buffers are currently supported by the used hardware and browser.
  117152. */
  117153. get isSupported(): boolean;
  117154. /**
  117155. * Get the list of textures generated by the multi render target.
  117156. */
  117157. get textures(): Texture[];
  117158. /**
  117159. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  117160. */
  117161. get depthTexture(): Texture;
  117162. /**
  117163. * Set the wrapping mode on U of all the textures we are rendering to.
  117164. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117165. */
  117166. set wrapU(wrap: number);
  117167. /**
  117168. * Set the wrapping mode on V of all the textures we are rendering to.
  117169. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117170. */
  117171. set wrapV(wrap: number);
  117172. /**
  117173. * Instantiate a new multi render target texture.
  117174. * A multi render target, like a render target provides the ability to render to a texture.
  117175. * Unlike the render target, it can render to several draw buffers in one draw.
  117176. * This is specially interesting in deferred rendering or for any effects requiring more than
  117177. * just one color from a single pass.
  117178. * @param name Define the name of the texture
  117179. * @param size Define the size of the buffers to render to
  117180. * @param count Define the number of target we are rendering into
  117181. * @param scene Define the scene the texture belongs to
  117182. * @param options Define the options used to create the multi render target
  117183. */
  117184. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  117185. /** @hidden */
  117186. _rebuild(): void;
  117187. private _createInternalTextures;
  117188. private _createTextures;
  117189. /**
  117190. * Define the number of samples used if MSAA is enabled.
  117191. */
  117192. get samples(): number;
  117193. set samples(value: number);
  117194. /**
  117195. * Resize all the textures in the multi render target.
  117196. * Be carrefull as it will recreate all the data in the new texture.
  117197. * @param size Define the new size
  117198. */
  117199. resize(size: any): void;
  117200. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  117201. /**
  117202. * Dispose the render targets and their associated resources
  117203. */
  117204. dispose(): void;
  117205. /**
  117206. * Release all the underlying texture used as draw buffers.
  117207. */
  117208. releaseInternalTextures(): void;
  117209. }
  117210. }
  117211. declare module BABYLON {
  117212. interface ThinEngine {
  117213. /**
  117214. * Unbind a list of render target textures from the webGL context
  117215. * This is used only when drawBuffer extension or webGL2 are active
  117216. * @param textures defines the render target textures to unbind
  117217. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117218. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117219. */
  117220. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117221. /**
  117222. * Create a multi render target texture
  117223. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117224. * @param size defines the size of the texture
  117225. * @param options defines the creation options
  117226. * @returns the cube texture as an InternalTexture
  117227. */
  117228. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117229. /**
  117230. * Update the sample count for a given multiple render target texture
  117231. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117232. * @param textures defines the textures to update
  117233. * @param samples defines the sample count to set
  117234. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117235. */
  117236. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117237. }
  117238. }
  117239. declare module BABYLON {
  117240. /**
  117241. * Class used to define an additional view for the engine
  117242. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117243. */
  117244. export class EngineView {
  117245. /** Defines the canvas where to render the view */
  117246. target: HTMLCanvasElement;
  117247. /** Defines an optional camera used to render the view (will use active camera else) */
  117248. camera?: Camera;
  117249. }
  117250. interface Engine {
  117251. /**
  117252. * Gets or sets the HTML element to use for attaching events
  117253. */
  117254. inputElement: Nullable<HTMLElement>;
  117255. /**
  117256. * Gets the current engine view
  117257. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117258. */
  117259. activeView: Nullable<EngineView>;
  117260. /** Gets or sets the list of views */
  117261. views: EngineView[];
  117262. /**
  117263. * Register a new child canvas
  117264. * @param canvas defines the canvas to register
  117265. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117266. * @returns the associated view
  117267. */
  117268. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117269. /**
  117270. * Remove a registered child canvas
  117271. * @param canvas defines the canvas to remove
  117272. * @returns the current engine
  117273. */
  117274. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117275. }
  117276. }
  117277. declare module BABYLON {
  117278. /**
  117279. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117280. */
  117281. export interface CubeMapInfo {
  117282. /**
  117283. * The pixel array for the front face.
  117284. * This is stored in format, left to right, up to down format.
  117285. */
  117286. front: Nullable<ArrayBufferView>;
  117287. /**
  117288. * The pixel array for the back face.
  117289. * This is stored in format, left to right, up to down format.
  117290. */
  117291. back: Nullable<ArrayBufferView>;
  117292. /**
  117293. * The pixel array for the left face.
  117294. * This is stored in format, left to right, up to down format.
  117295. */
  117296. left: Nullable<ArrayBufferView>;
  117297. /**
  117298. * The pixel array for the right face.
  117299. * This is stored in format, left to right, up to down format.
  117300. */
  117301. right: Nullable<ArrayBufferView>;
  117302. /**
  117303. * The pixel array for the up face.
  117304. * This is stored in format, left to right, up to down format.
  117305. */
  117306. up: Nullable<ArrayBufferView>;
  117307. /**
  117308. * The pixel array for the down face.
  117309. * This is stored in format, left to right, up to down format.
  117310. */
  117311. down: Nullable<ArrayBufferView>;
  117312. /**
  117313. * The size of the cubemap stored.
  117314. *
  117315. * Each faces will be size * size pixels.
  117316. */
  117317. size: number;
  117318. /**
  117319. * The format of the texture.
  117320. *
  117321. * RGBA, RGB.
  117322. */
  117323. format: number;
  117324. /**
  117325. * The type of the texture data.
  117326. *
  117327. * UNSIGNED_INT, FLOAT.
  117328. */
  117329. type: number;
  117330. /**
  117331. * Specifies whether the texture is in gamma space.
  117332. */
  117333. gammaSpace: boolean;
  117334. }
  117335. /**
  117336. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117337. */
  117338. export class PanoramaToCubeMapTools {
  117339. private static FACE_FRONT;
  117340. private static FACE_BACK;
  117341. private static FACE_RIGHT;
  117342. private static FACE_LEFT;
  117343. private static FACE_DOWN;
  117344. private static FACE_UP;
  117345. /**
  117346. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117347. *
  117348. * @param float32Array The source data.
  117349. * @param inputWidth The width of the input panorama.
  117350. * @param inputHeight The height of the input panorama.
  117351. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117352. * @return The cubemap data
  117353. */
  117354. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117355. private static CreateCubemapTexture;
  117356. private static CalcProjectionSpherical;
  117357. }
  117358. }
  117359. declare module BABYLON {
  117360. /**
  117361. * Helper class dealing with the extraction of spherical polynomial dataArray
  117362. * from a cube map.
  117363. */
  117364. export class CubeMapToSphericalPolynomialTools {
  117365. private static FileFaces;
  117366. /**
  117367. * Converts a texture to the according Spherical Polynomial data.
  117368. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117369. *
  117370. * @param texture The texture to extract the information from.
  117371. * @return The Spherical Polynomial data.
  117372. */
  117373. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117374. /**
  117375. * Converts a cubemap to the according Spherical Polynomial data.
  117376. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117377. *
  117378. * @param cubeInfo The Cube map to extract the information from.
  117379. * @return The Spherical Polynomial data.
  117380. */
  117381. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117382. }
  117383. }
  117384. declare module BABYLON {
  117385. interface BaseTexture {
  117386. /**
  117387. * Get the polynomial representation of the texture data.
  117388. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117389. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117390. */
  117391. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117392. }
  117393. }
  117394. declare module BABYLON {
  117395. /** @hidden */
  117396. export var rgbdEncodePixelShader: {
  117397. name: string;
  117398. shader: string;
  117399. };
  117400. }
  117401. declare module BABYLON {
  117402. /** @hidden */
  117403. export var rgbdDecodePixelShader: {
  117404. name: string;
  117405. shader: string;
  117406. };
  117407. }
  117408. declare module BABYLON {
  117409. /**
  117410. * Raw texture data and descriptor sufficient for WebGL texture upload
  117411. */
  117412. export interface EnvironmentTextureInfo {
  117413. /**
  117414. * Version of the environment map
  117415. */
  117416. version: number;
  117417. /**
  117418. * Width of image
  117419. */
  117420. width: number;
  117421. /**
  117422. * Irradiance information stored in the file.
  117423. */
  117424. irradiance: any;
  117425. /**
  117426. * Specular information stored in the file.
  117427. */
  117428. specular: any;
  117429. }
  117430. /**
  117431. * Defines One Image in the file. It requires only the position in the file
  117432. * as well as the length.
  117433. */
  117434. interface BufferImageData {
  117435. /**
  117436. * Length of the image data.
  117437. */
  117438. length: number;
  117439. /**
  117440. * Position of the data from the null terminator delimiting the end of the JSON.
  117441. */
  117442. position: number;
  117443. }
  117444. /**
  117445. * Defines the specular data enclosed in the file.
  117446. * This corresponds to the version 1 of the data.
  117447. */
  117448. export interface EnvironmentTextureSpecularInfoV1 {
  117449. /**
  117450. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117451. */
  117452. specularDataPosition?: number;
  117453. /**
  117454. * This contains all the images data needed to reconstruct the cubemap.
  117455. */
  117456. mipmaps: Array<BufferImageData>;
  117457. /**
  117458. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117459. */
  117460. lodGenerationScale: number;
  117461. }
  117462. /**
  117463. * Sets of helpers addressing the serialization and deserialization of environment texture
  117464. * stored in a BabylonJS env file.
  117465. * Those files are usually stored as .env files.
  117466. */
  117467. export class EnvironmentTextureTools {
  117468. /**
  117469. * Magic number identifying the env file.
  117470. */
  117471. private static _MagicBytes;
  117472. /**
  117473. * Gets the environment info from an env file.
  117474. * @param data The array buffer containing the .env bytes.
  117475. * @returns the environment file info (the json header) if successfully parsed.
  117476. */
  117477. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117478. /**
  117479. * Creates an environment texture from a loaded cube texture.
  117480. * @param texture defines the cube texture to convert in env file
  117481. * @return a promise containing the environment data if succesfull.
  117482. */
  117483. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117484. /**
  117485. * Creates a JSON representation of the spherical data.
  117486. * @param texture defines the texture containing the polynomials
  117487. * @return the JSON representation of the spherical info
  117488. */
  117489. private static _CreateEnvTextureIrradiance;
  117490. /**
  117491. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117492. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117493. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117494. * @return the views described by info providing access to the underlying buffer
  117495. */
  117496. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117497. /**
  117498. * Uploads the texture info contained in the env file to the GPU.
  117499. * @param texture defines the internal texture to upload to
  117500. * @param arrayBuffer defines the buffer cotaining the data to load
  117501. * @param info defines the texture info retrieved through the GetEnvInfo method
  117502. * @returns a promise
  117503. */
  117504. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117505. private static _OnImageReadyAsync;
  117506. /**
  117507. * Uploads the levels of image data to the GPU.
  117508. * @param texture defines the internal texture to upload to
  117509. * @param imageData defines the array buffer views of image data [mipmap][face]
  117510. * @returns a promise
  117511. */
  117512. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117513. /**
  117514. * Uploads spherical polynomials information to the texture.
  117515. * @param texture defines the texture we are trying to upload the information to
  117516. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117517. */
  117518. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117519. /** @hidden */
  117520. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117521. }
  117522. }
  117523. declare module BABYLON {
  117524. /**
  117525. * Contains position and normal vectors for a vertex
  117526. */
  117527. export class PositionNormalVertex {
  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. * Creates a PositionNormalVertex
  117534. * @param position the position of the vertex (defaut: 0,0,0)
  117535. * @param normal the normal of the vertex (defaut: 0,1,0)
  117536. */
  117537. constructor(
  117538. /** the position of the vertex (defaut: 0,0,0) */
  117539. position?: Vector3,
  117540. /** the normal of the vertex (defaut: 0,1,0) */
  117541. normal?: Vector3);
  117542. /**
  117543. * Clones the PositionNormalVertex
  117544. * @returns the cloned PositionNormalVertex
  117545. */
  117546. clone(): PositionNormalVertex;
  117547. }
  117548. /**
  117549. * Contains position, normal and uv vectors for a vertex
  117550. */
  117551. export class PositionNormalTextureVertex {
  117552. /** the position of the vertex (defaut: 0,0,0) */
  117553. position: Vector3;
  117554. /** the normal of the vertex (defaut: 0,1,0) */
  117555. normal: Vector3;
  117556. /** the uv of the vertex (default: 0,0) */
  117557. uv: Vector2;
  117558. /**
  117559. * Creates a PositionNormalTextureVertex
  117560. * @param position the position of the vertex (defaut: 0,0,0)
  117561. * @param normal the normal of the vertex (defaut: 0,1,0)
  117562. * @param uv the uv of the vertex (default: 0,0)
  117563. */
  117564. constructor(
  117565. /** the position of the vertex (defaut: 0,0,0) */
  117566. position?: Vector3,
  117567. /** the normal of the vertex (defaut: 0,1,0) */
  117568. normal?: Vector3,
  117569. /** the uv of the vertex (default: 0,0) */
  117570. uv?: Vector2);
  117571. /**
  117572. * Clones the PositionNormalTextureVertex
  117573. * @returns the cloned PositionNormalTextureVertex
  117574. */
  117575. clone(): PositionNormalTextureVertex;
  117576. }
  117577. }
  117578. declare module BABYLON {
  117579. /** @hidden */
  117580. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117581. private _genericAttributeLocation;
  117582. private _varyingLocationCount;
  117583. private _varyingLocationMap;
  117584. private _replacements;
  117585. private _textureCount;
  117586. private _uniforms;
  117587. lineProcessor(line: string): string;
  117588. attributeProcessor(attribute: string): string;
  117589. varyingProcessor(varying: string, isFragment: boolean): string;
  117590. uniformProcessor(uniform: string): string;
  117591. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117592. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117593. }
  117594. }
  117595. declare module BABYLON {
  117596. /**
  117597. * Container for accessors for natively-stored mesh data buffers.
  117598. */
  117599. class NativeDataBuffer extends DataBuffer {
  117600. /**
  117601. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117602. */
  117603. nativeIndexBuffer?: any;
  117604. /**
  117605. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117606. */
  117607. nativeVertexBuffer?: any;
  117608. }
  117609. /** @hidden */
  117610. class NativeTexture extends InternalTexture {
  117611. getInternalTexture(): InternalTexture;
  117612. getViewCount(): number;
  117613. }
  117614. /** @hidden */
  117615. export class NativeEngine extends Engine {
  117616. private readonly _native;
  117617. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117618. private readonly INVALID_HANDLE;
  117619. getHardwareScalingLevel(): number;
  117620. constructor();
  117621. /**
  117622. * Can be used to override the current requestAnimationFrame requester.
  117623. * @hidden
  117624. */
  117625. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117626. /**
  117627. * Override default engine behavior.
  117628. * @param color
  117629. * @param backBuffer
  117630. * @param depth
  117631. * @param stencil
  117632. */
  117633. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117634. /**
  117635. * Gets host document
  117636. * @returns the host document object
  117637. */
  117638. getHostDocument(): Nullable<Document>;
  117639. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117640. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117641. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117642. recordVertexArrayObject(vertexBuffers: {
  117643. [key: string]: VertexBuffer;
  117644. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117645. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117646. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117647. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117648. /**
  117649. * Draw a list of indexed primitives
  117650. * @param fillMode defines the primitive to use
  117651. * @param indexStart defines the starting index
  117652. * @param indexCount defines the number of index to draw
  117653. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117654. */
  117655. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117656. /**
  117657. * Draw a list of unindexed primitives
  117658. * @param fillMode defines the primitive to use
  117659. * @param verticesStart defines the index of first vertex to draw
  117660. * @param verticesCount defines the count of vertices to draw
  117661. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117662. */
  117663. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117664. createPipelineContext(): IPipelineContext;
  117665. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117666. /** @hidden */
  117667. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117668. /** @hidden */
  117669. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117670. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117671. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117672. protected _setProgram(program: WebGLProgram): void;
  117673. _releaseEffect(effect: Effect): void;
  117674. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117675. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117676. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117677. bindSamplers(effect: Effect): void;
  117678. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117679. getRenderWidth(useScreen?: boolean): number;
  117680. getRenderHeight(useScreen?: boolean): number;
  117681. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117682. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117683. /**
  117684. * Set the z offset to apply to current rendering
  117685. * @param value defines the offset to apply
  117686. */
  117687. setZOffset(value: number): void;
  117688. /**
  117689. * Gets the current value of the zOffset
  117690. * @returns the current zOffset state
  117691. */
  117692. getZOffset(): number;
  117693. /**
  117694. * Enable or disable depth buffering
  117695. * @param enable defines the state to set
  117696. */
  117697. setDepthBuffer(enable: boolean): void;
  117698. /**
  117699. * Gets a boolean indicating if depth writing is enabled
  117700. * @returns the current depth writing state
  117701. */
  117702. getDepthWrite(): boolean;
  117703. /**
  117704. * Enable or disable depth writing
  117705. * @param enable defines the state to set
  117706. */
  117707. setDepthWrite(enable: boolean): void;
  117708. /**
  117709. * Enable or disable color writing
  117710. * @param enable defines the state to set
  117711. */
  117712. setColorWrite(enable: boolean): void;
  117713. /**
  117714. * Gets a boolean indicating if color writing is enabled
  117715. * @returns the current color writing state
  117716. */
  117717. getColorWrite(): boolean;
  117718. /**
  117719. * Sets alpha constants used by some alpha blending modes
  117720. * @param r defines the red component
  117721. * @param g defines the green component
  117722. * @param b defines the blue component
  117723. * @param a defines the alpha component
  117724. */
  117725. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117726. /**
  117727. * Sets the current alpha mode
  117728. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117729. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117731. */
  117732. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117733. /**
  117734. * Gets the current alpha mode
  117735. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117736. * @returns the current alpha mode
  117737. */
  117738. getAlphaMode(): number;
  117739. setInt(uniform: WebGLUniformLocation, int: number): void;
  117740. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117741. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117742. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117743. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117744. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117745. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117746. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117747. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117748. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117749. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117750. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117751. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117752. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117753. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117754. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117755. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117756. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117757. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117758. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117759. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117760. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117761. wipeCaches(bruteForce?: boolean): void;
  117762. _createTexture(): WebGLTexture;
  117763. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117764. /**
  117765. * Usually called from BABYLON.Texture.ts.
  117766. * Passed information to create a WebGLTexture
  117767. * @param urlArg defines a value which contains one of the following:
  117768. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117769. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117770. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117772. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117773. * @param scene needed for loading to the correct scene
  117774. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117775. * @param onLoad optional callback to be called upon successful completion
  117776. * @param onError optional callback to be called upon failure
  117777. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117778. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117779. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117780. * @param forcedExtension defines the extension to use to pick the right loader
  117781. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117782. */
  117783. 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;
  117784. /**
  117785. * Creates a cube texture
  117786. * @param rootUrl defines the url where the files to load is located
  117787. * @param scene defines the current scene
  117788. * @param files defines the list of files to load (1 per face)
  117789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117790. * @param onLoad defines an optional callback raised when the texture is loaded
  117791. * @param onError defines an optional callback raised if there is an issue to load the texture
  117792. * @param format defines the format of the data
  117793. * @param forcedExtension defines the extension to use to pick the right loader
  117794. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117795. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117796. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117797. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117798. * @returns the cube texture as an InternalTexture
  117799. */
  117800. 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;
  117801. private _getSamplingFilter;
  117802. private static _GetNativeTextureFormat;
  117803. createRenderTargetTexture(size: number | {
  117804. width: number;
  117805. height: number;
  117806. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117807. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117808. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117809. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117810. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117811. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117812. /**
  117813. * Updates a dynamic vertex buffer.
  117814. * @param vertexBuffer the vertex buffer to update
  117815. * @param data the data used to update the vertex buffer
  117816. * @param byteOffset the byte offset of the data (optional)
  117817. * @param byteLength the byte length of the data (optional)
  117818. */
  117819. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117820. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117821. private _updateAnisotropicLevel;
  117822. private _getAddressMode;
  117823. /** @hidden */
  117824. _bindTexture(channel: number, texture: InternalTexture): void;
  117825. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117826. releaseEffects(): void;
  117827. /** @hidden */
  117828. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117829. /** @hidden */
  117830. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117831. /** @hidden */
  117832. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117833. /** @hidden */
  117834. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117835. }
  117836. }
  117837. declare module BABYLON {
  117838. /**
  117839. * Gather the list of clipboard event types as constants.
  117840. */
  117841. export class ClipboardEventTypes {
  117842. /**
  117843. * The clipboard event is fired when a copy command is active (pressed).
  117844. */
  117845. static readonly COPY: number;
  117846. /**
  117847. * The clipboard event is fired when a cut command is active (pressed).
  117848. */
  117849. static readonly CUT: number;
  117850. /**
  117851. * The clipboard event is fired when a paste command is active (pressed).
  117852. */
  117853. static readonly PASTE: number;
  117854. }
  117855. /**
  117856. * This class is used to store clipboard related info for the onClipboardObservable event.
  117857. */
  117858. export class ClipboardInfo {
  117859. /**
  117860. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117861. */
  117862. type: number;
  117863. /**
  117864. * Defines the related dom event
  117865. */
  117866. event: ClipboardEvent;
  117867. /**
  117868. *Creates an instance of ClipboardInfo.
  117869. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117870. * @param event Defines the related dom event
  117871. */
  117872. constructor(
  117873. /**
  117874. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117875. */
  117876. type: number,
  117877. /**
  117878. * Defines the related dom event
  117879. */
  117880. event: ClipboardEvent);
  117881. /**
  117882. * Get the clipboard event's type from the keycode.
  117883. * @param keyCode Defines the keyCode for the current keyboard event.
  117884. * @return {number}
  117885. */
  117886. static GetTypeFromCharacter(keyCode: number): number;
  117887. }
  117888. }
  117889. declare module BABYLON {
  117890. /**
  117891. * Google Daydream controller
  117892. */
  117893. export class DaydreamController extends WebVRController {
  117894. /**
  117895. * Base Url for the controller model.
  117896. */
  117897. static MODEL_BASE_URL: string;
  117898. /**
  117899. * File name for the controller model.
  117900. */
  117901. static MODEL_FILENAME: string;
  117902. /**
  117903. * Gamepad Id prefix used to identify Daydream Controller.
  117904. */
  117905. static readonly GAMEPAD_ID_PREFIX: string;
  117906. /**
  117907. * Creates a new DaydreamController from a gamepad
  117908. * @param vrGamepad the gamepad that the controller should be created from
  117909. */
  117910. constructor(vrGamepad: any);
  117911. /**
  117912. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117913. * @param scene scene in which to add meshes
  117914. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117915. */
  117916. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117917. /**
  117918. * Called once for each button that changed state since the last frame
  117919. * @param buttonIdx Which button index changed
  117920. * @param state New state of the button
  117921. * @param changes Which properties on the state changed since last frame
  117922. */
  117923. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117924. }
  117925. }
  117926. declare module BABYLON {
  117927. /**
  117928. * Gear VR Controller
  117929. */
  117930. export class GearVRController extends WebVRController {
  117931. /**
  117932. * Base Url for the controller model.
  117933. */
  117934. static MODEL_BASE_URL: string;
  117935. /**
  117936. * File name for the controller model.
  117937. */
  117938. static MODEL_FILENAME: string;
  117939. /**
  117940. * Gamepad Id prefix used to identify this controller.
  117941. */
  117942. static readonly GAMEPAD_ID_PREFIX: string;
  117943. private readonly _buttonIndexToObservableNameMap;
  117944. /**
  117945. * Creates a new GearVRController from a gamepad
  117946. * @param vrGamepad the gamepad that the controller should be created from
  117947. */
  117948. constructor(vrGamepad: any);
  117949. /**
  117950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117951. * @param scene scene in which to add meshes
  117952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117953. */
  117954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117955. /**
  117956. * Called once for each button that changed state since the last frame
  117957. * @param buttonIdx Which button index changed
  117958. * @param state New state of the button
  117959. * @param changes Which properties on the state changed since last frame
  117960. */
  117961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117962. }
  117963. }
  117964. declare module BABYLON {
  117965. /**
  117966. * Class containing static functions to help procedurally build meshes
  117967. */
  117968. export class PolyhedronBuilder {
  117969. /**
  117970. * Creates a polyhedron mesh
  117971. * * 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
  117972. * * The parameter `size` (positive float, default 1) sets the polygon size
  117973. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117974. * * 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`
  117975. * * 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
  117976. * * 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)`)
  117977. * * 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
  117978. * * 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
  117979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117982. * @param name defines the name of the mesh
  117983. * @param options defines the options used to create the mesh
  117984. * @param scene defines the hosting scene
  117985. * @returns the polyhedron mesh
  117986. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117987. */
  117988. static CreatePolyhedron(name: string, options: {
  117989. type?: number;
  117990. size?: number;
  117991. sizeX?: number;
  117992. sizeY?: number;
  117993. sizeZ?: number;
  117994. custom?: any;
  117995. faceUV?: Vector4[];
  117996. faceColors?: Color4[];
  117997. flat?: boolean;
  117998. updatable?: boolean;
  117999. sideOrientation?: number;
  118000. frontUVs?: Vector4;
  118001. backUVs?: Vector4;
  118002. }, scene?: Nullable<Scene>): Mesh;
  118003. }
  118004. }
  118005. declare module BABYLON {
  118006. /**
  118007. * Gizmo that enables scaling a mesh along 3 axis
  118008. */
  118009. export class ScaleGizmo extends Gizmo {
  118010. /**
  118011. * Internal gizmo used for interactions on the x axis
  118012. */
  118013. xGizmo: AxisScaleGizmo;
  118014. /**
  118015. * Internal gizmo used for interactions on the y axis
  118016. */
  118017. yGizmo: AxisScaleGizmo;
  118018. /**
  118019. * Internal gizmo used for interactions on the z axis
  118020. */
  118021. zGizmo: AxisScaleGizmo;
  118022. /**
  118023. * Internal gizmo used to scale all axis equally
  118024. */
  118025. uniformScaleGizmo: AxisScaleGizmo;
  118026. private _meshAttached;
  118027. private _updateGizmoRotationToMatchAttachedMesh;
  118028. private _snapDistance;
  118029. private _scaleRatio;
  118030. private _uniformScalingMesh;
  118031. private _octahedron;
  118032. private _sensitivity;
  118033. /** Fires an event when any of it's sub gizmos are dragged */
  118034. onDragStartObservable: Observable<unknown>;
  118035. /** Fires an event when any of it's sub gizmos are released from dragging */
  118036. onDragEndObservable: Observable<unknown>;
  118037. get attachedMesh(): Nullable<AbstractMesh>;
  118038. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118039. /**
  118040. * Creates a ScaleGizmo
  118041. * @param gizmoLayer The utility layer the gizmo will be added to
  118042. */
  118043. constructor(gizmoLayer?: UtilityLayerRenderer);
  118044. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118045. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118046. /**
  118047. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118048. */
  118049. set snapDistance(value: number);
  118050. get snapDistance(): number;
  118051. /**
  118052. * Ratio for the scale of the gizmo (Default: 1)
  118053. */
  118054. set scaleRatio(value: number);
  118055. get scaleRatio(): number;
  118056. /**
  118057. * Sensitivity factor for dragging (Default: 1)
  118058. */
  118059. set sensitivity(value: number);
  118060. get sensitivity(): number;
  118061. /**
  118062. * Disposes of the gizmo
  118063. */
  118064. dispose(): void;
  118065. }
  118066. }
  118067. declare module BABYLON {
  118068. /**
  118069. * Single axis scale gizmo
  118070. */
  118071. export class AxisScaleGizmo extends Gizmo {
  118072. /**
  118073. * Drag behavior responsible for the gizmos dragging interactions
  118074. */
  118075. dragBehavior: PointerDragBehavior;
  118076. private _pointerObserver;
  118077. /**
  118078. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118079. */
  118080. snapDistance: number;
  118081. /**
  118082. * Event that fires each time the gizmo snaps to a new location.
  118083. * * snapDistance is the the change in distance
  118084. */
  118085. onSnapObservable: Observable<{
  118086. snapDistance: number;
  118087. }>;
  118088. /**
  118089. * If the scaling operation should be done on all axis (default: false)
  118090. */
  118091. uniformScaling: boolean;
  118092. /**
  118093. * Custom sensitivity value for the drag strength
  118094. */
  118095. sensitivity: number;
  118096. private _isEnabled;
  118097. private _parent;
  118098. private _arrow;
  118099. private _coloredMaterial;
  118100. private _hoverMaterial;
  118101. /**
  118102. * Creates an AxisScaleGizmo
  118103. * @param gizmoLayer The utility layer the gizmo will be added to
  118104. * @param dragAxis The axis which the gizmo will be able to scale on
  118105. * @param color The color of the gizmo
  118106. */
  118107. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  118108. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118109. /**
  118110. * If the gizmo is enabled
  118111. */
  118112. set isEnabled(value: boolean);
  118113. get isEnabled(): boolean;
  118114. /**
  118115. * Disposes of the gizmo
  118116. */
  118117. dispose(): void;
  118118. /**
  118119. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118120. * @param mesh The mesh to replace the default mesh of the gizmo
  118121. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  118122. */
  118123. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  118124. }
  118125. }
  118126. declare module BABYLON {
  118127. /**
  118128. * Bounding box gizmo
  118129. */
  118130. export class BoundingBoxGizmo extends Gizmo {
  118131. private _lineBoundingBox;
  118132. private _rotateSpheresParent;
  118133. private _scaleBoxesParent;
  118134. private _boundingDimensions;
  118135. private _renderObserver;
  118136. private _pointerObserver;
  118137. private _scaleDragSpeed;
  118138. private _tmpQuaternion;
  118139. private _tmpVector;
  118140. private _tmpRotationMatrix;
  118141. /**
  118142. * 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)
  118143. */
  118144. ignoreChildren: boolean;
  118145. /**
  118146. * 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)
  118147. */
  118148. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  118149. /**
  118150. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  118151. */
  118152. rotationSphereSize: number;
  118153. /**
  118154. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  118155. */
  118156. scaleBoxSize: number;
  118157. /**
  118158. * 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)
  118159. */
  118160. fixedDragMeshScreenSize: boolean;
  118161. /**
  118162. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  118163. */
  118164. fixedDragMeshScreenSizeDistanceFactor: number;
  118165. /**
  118166. * Fired when a rotation sphere or scale box is dragged
  118167. */
  118168. onDragStartObservable: Observable<{}>;
  118169. /**
  118170. * Fired when a scale box is dragged
  118171. */
  118172. onScaleBoxDragObservable: Observable<{}>;
  118173. /**
  118174. * Fired when a scale box drag is ended
  118175. */
  118176. onScaleBoxDragEndObservable: Observable<{}>;
  118177. /**
  118178. * Fired when a rotation sphere is dragged
  118179. */
  118180. onRotationSphereDragObservable: Observable<{}>;
  118181. /**
  118182. * Fired when a rotation sphere drag is ended
  118183. */
  118184. onRotationSphereDragEndObservable: Observable<{}>;
  118185. /**
  118186. * 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)
  118187. */
  118188. scalePivot: Nullable<Vector3>;
  118189. /**
  118190. * Mesh used as a pivot to rotate the attached mesh
  118191. */
  118192. private _anchorMesh;
  118193. private _existingMeshScale;
  118194. private _dragMesh;
  118195. private pointerDragBehavior;
  118196. private coloredMaterial;
  118197. private hoverColoredMaterial;
  118198. /**
  118199. * Sets the color of the bounding box gizmo
  118200. * @param color the color to set
  118201. */
  118202. setColor(color: Color3): void;
  118203. /**
  118204. * Creates an BoundingBoxGizmo
  118205. * @param gizmoLayer The utility layer the gizmo will be added to
  118206. * @param color The color of the gizmo
  118207. */
  118208. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  118209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118210. private _selectNode;
  118211. /**
  118212. * Updates the bounding box information for the Gizmo
  118213. */
  118214. updateBoundingBox(): void;
  118215. private _updateRotationSpheres;
  118216. private _updateScaleBoxes;
  118217. /**
  118218. * Enables rotation on the specified axis and disables rotation on the others
  118219. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118220. */
  118221. setEnabledRotationAxis(axis: string): void;
  118222. /**
  118223. * Enables/disables scaling
  118224. * @param enable if scaling should be enabled
  118225. */
  118226. setEnabledScaling(enable: boolean): void;
  118227. private _updateDummy;
  118228. /**
  118229. * Enables a pointer drag behavior on the bounding box of the gizmo
  118230. */
  118231. enableDragBehavior(): void;
  118232. /**
  118233. * Disposes of the gizmo
  118234. */
  118235. dispose(): void;
  118236. /**
  118237. * 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)
  118238. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118239. * @returns the bounding box mesh with the passed in mesh as a child
  118240. */
  118241. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118242. /**
  118243. * CustomMeshes are not supported by this gizmo
  118244. * @param mesh The mesh to replace the default mesh of the gizmo
  118245. */
  118246. setCustomMesh(mesh: Mesh): void;
  118247. }
  118248. }
  118249. declare module BABYLON {
  118250. /**
  118251. * Single plane rotation gizmo
  118252. */
  118253. export class PlaneRotationGizmo extends Gizmo {
  118254. /**
  118255. * Drag behavior responsible for the gizmos dragging interactions
  118256. */
  118257. dragBehavior: PointerDragBehavior;
  118258. private _pointerObserver;
  118259. /**
  118260. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118261. */
  118262. snapDistance: number;
  118263. /**
  118264. * Event that fires each time the gizmo snaps to a new location.
  118265. * * snapDistance is the the change in distance
  118266. */
  118267. onSnapObservable: Observable<{
  118268. snapDistance: number;
  118269. }>;
  118270. private _isEnabled;
  118271. private _parent;
  118272. /**
  118273. * Creates a PlaneRotationGizmo
  118274. * @param gizmoLayer The utility layer the gizmo will be added to
  118275. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118276. * @param color The color of the gizmo
  118277. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118278. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118279. */
  118280. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118281. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118282. /**
  118283. * If the gizmo is enabled
  118284. */
  118285. set isEnabled(value: boolean);
  118286. get isEnabled(): boolean;
  118287. /**
  118288. * Disposes of the gizmo
  118289. */
  118290. dispose(): void;
  118291. }
  118292. }
  118293. declare module BABYLON {
  118294. /**
  118295. * Gizmo that enables rotating a mesh along 3 axis
  118296. */
  118297. export class RotationGizmo extends Gizmo {
  118298. /**
  118299. * Internal gizmo used for interactions on the x axis
  118300. */
  118301. xGizmo: PlaneRotationGizmo;
  118302. /**
  118303. * Internal gizmo used for interactions on the y axis
  118304. */
  118305. yGizmo: PlaneRotationGizmo;
  118306. /**
  118307. * Internal gizmo used for interactions on the z axis
  118308. */
  118309. zGizmo: PlaneRotationGizmo;
  118310. /** Fires an event when any of it's sub gizmos are dragged */
  118311. onDragStartObservable: Observable<unknown>;
  118312. /** Fires an event when any of it's sub gizmos are released from dragging */
  118313. onDragEndObservable: Observable<unknown>;
  118314. private _meshAttached;
  118315. get attachedMesh(): Nullable<AbstractMesh>;
  118316. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118317. /**
  118318. * Creates a RotationGizmo
  118319. * @param gizmoLayer The utility layer the gizmo will be added to
  118320. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118321. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118322. */
  118323. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118324. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118325. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118326. /**
  118327. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118328. */
  118329. set snapDistance(value: number);
  118330. get snapDistance(): number;
  118331. /**
  118332. * Ratio for the scale of the gizmo (Default: 1)
  118333. */
  118334. set scaleRatio(value: number);
  118335. get scaleRatio(): number;
  118336. /**
  118337. * Disposes of the gizmo
  118338. */
  118339. dispose(): void;
  118340. /**
  118341. * CustomMeshes are not supported by this gizmo
  118342. * @param mesh The mesh to replace the default mesh of the gizmo
  118343. */
  118344. setCustomMesh(mesh: Mesh): void;
  118345. }
  118346. }
  118347. declare module BABYLON {
  118348. /**
  118349. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118350. */
  118351. export class GizmoManager implements IDisposable {
  118352. private scene;
  118353. /**
  118354. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118355. */
  118356. gizmos: {
  118357. positionGizmo: Nullable<PositionGizmo>;
  118358. rotationGizmo: Nullable<RotationGizmo>;
  118359. scaleGizmo: Nullable<ScaleGizmo>;
  118360. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118361. };
  118362. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118363. clearGizmoOnEmptyPointerEvent: boolean;
  118364. /** Fires an event when the manager is attached to a mesh */
  118365. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118366. private _gizmosEnabled;
  118367. private _pointerObserver;
  118368. private _attachedMesh;
  118369. private _boundingBoxColor;
  118370. private _defaultUtilityLayer;
  118371. private _defaultKeepDepthUtilityLayer;
  118372. /**
  118373. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118374. */
  118375. boundingBoxDragBehavior: SixDofDragBehavior;
  118376. /**
  118377. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118378. */
  118379. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118380. /**
  118381. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118382. */
  118383. usePointerToAttachGizmos: boolean;
  118384. /**
  118385. * Utility layer that the bounding box gizmo belongs to
  118386. */
  118387. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118388. /**
  118389. * Utility layer that all gizmos besides bounding box belong to
  118390. */
  118391. get utilityLayer(): UtilityLayerRenderer;
  118392. /**
  118393. * Instatiates a gizmo manager
  118394. * @param scene the scene to overlay the gizmos on top of
  118395. */
  118396. constructor(scene: Scene);
  118397. /**
  118398. * Attaches a set of gizmos to the specified mesh
  118399. * @param mesh The mesh the gizmo's should be attached to
  118400. */
  118401. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118402. /**
  118403. * If the position gizmo is enabled
  118404. */
  118405. set positionGizmoEnabled(value: boolean);
  118406. get positionGizmoEnabled(): boolean;
  118407. /**
  118408. * If the rotation gizmo is enabled
  118409. */
  118410. set rotationGizmoEnabled(value: boolean);
  118411. get rotationGizmoEnabled(): boolean;
  118412. /**
  118413. * If the scale gizmo is enabled
  118414. */
  118415. set scaleGizmoEnabled(value: boolean);
  118416. get scaleGizmoEnabled(): boolean;
  118417. /**
  118418. * If the boundingBox gizmo is enabled
  118419. */
  118420. set boundingBoxGizmoEnabled(value: boolean);
  118421. get boundingBoxGizmoEnabled(): boolean;
  118422. /**
  118423. * Disposes of the gizmo manager
  118424. */
  118425. dispose(): void;
  118426. }
  118427. }
  118428. declare module BABYLON {
  118429. /**
  118430. * A directional light is defined by a direction (what a surprise!).
  118431. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118432. * 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.
  118433. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118434. */
  118435. export class DirectionalLight extends ShadowLight {
  118436. private _shadowFrustumSize;
  118437. /**
  118438. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118439. */
  118440. get shadowFrustumSize(): number;
  118441. /**
  118442. * Specifies a fix frustum size for the shadow generation.
  118443. */
  118444. set shadowFrustumSize(value: number);
  118445. private _shadowOrthoScale;
  118446. /**
  118447. * Gets the shadow projection scale against the optimal computed one.
  118448. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118449. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118450. */
  118451. get shadowOrthoScale(): number;
  118452. /**
  118453. * Sets the shadow projection scale against the optimal computed one.
  118454. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118455. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118456. */
  118457. set shadowOrthoScale(value: number);
  118458. /**
  118459. * Automatically compute the projection matrix to best fit (including all the casters)
  118460. * on each frame.
  118461. */
  118462. autoUpdateExtends: boolean;
  118463. /**
  118464. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  118465. * on each frame. autoUpdateExtends must be set to true for this to work
  118466. */
  118467. autoCalcShadowZBounds: boolean;
  118468. private _orthoLeft;
  118469. private _orthoRight;
  118470. private _orthoTop;
  118471. private _orthoBottom;
  118472. /**
  118473. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118474. * The directional light is emitted from everywhere in the given direction.
  118475. * It can cast shadows.
  118476. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118477. * @param name The friendly name of the light
  118478. * @param direction The direction of the light
  118479. * @param scene The scene the light belongs to
  118480. */
  118481. constructor(name: string, direction: Vector3, scene: Scene);
  118482. /**
  118483. * Returns the string "DirectionalLight".
  118484. * @return The class name
  118485. */
  118486. getClassName(): string;
  118487. /**
  118488. * Returns the integer 1.
  118489. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118490. */
  118491. getTypeID(): number;
  118492. /**
  118493. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118497. /**
  118498. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118499. * Returns the DirectionalLight Shadow projection matrix.
  118500. */
  118501. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118502. /**
  118503. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118504. * Returns the DirectionalLight Shadow projection matrix.
  118505. */
  118506. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118507. protected _buildUniformLayout(): void;
  118508. /**
  118509. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118510. * @param effect The effect to update
  118511. * @param lightIndex The index of the light in the effect to update
  118512. * @returns The directional light
  118513. */
  118514. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118515. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118516. /**
  118517. * Gets the minZ used for shadow according to both the scene and the light.
  118518. *
  118519. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118520. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118521. * @param activeCamera The camera we are returning the min for
  118522. * @returns the depth min z
  118523. */
  118524. getDepthMinZ(activeCamera: Camera): number;
  118525. /**
  118526. * Gets the maxZ used for shadow according to both the scene and the light.
  118527. *
  118528. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118529. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118530. * @param activeCamera The camera we are returning the max for
  118531. * @returns the depth max z
  118532. */
  118533. getDepthMaxZ(activeCamera: Camera): number;
  118534. /**
  118535. * Prepares the list of defines specific to the light type.
  118536. * @param defines the list of defines
  118537. * @param lightIndex defines the index of the light for the effect
  118538. */
  118539. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118540. }
  118541. }
  118542. declare module BABYLON {
  118543. /**
  118544. * Class containing static functions to help procedurally build meshes
  118545. */
  118546. export class HemisphereBuilder {
  118547. /**
  118548. * Creates a hemisphere mesh
  118549. * @param name defines the name of the mesh
  118550. * @param options defines the options used to create the mesh
  118551. * @param scene defines the hosting scene
  118552. * @returns the hemisphere mesh
  118553. */
  118554. static CreateHemisphere(name: string, options: {
  118555. segments?: number;
  118556. diameter?: number;
  118557. sideOrientation?: number;
  118558. }, scene: any): Mesh;
  118559. }
  118560. }
  118561. declare module BABYLON {
  118562. /**
  118563. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118564. * These values define a cone of light starting from the position, emitting toward the direction.
  118565. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118566. * and the exponent defines the speed of the decay of the light with distance (reach).
  118567. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118568. */
  118569. export class SpotLight extends ShadowLight {
  118570. private _angle;
  118571. private _innerAngle;
  118572. private _cosHalfAngle;
  118573. private _lightAngleScale;
  118574. private _lightAngleOffset;
  118575. /**
  118576. * Gets the cone angle of the spot light in Radians.
  118577. */
  118578. get angle(): number;
  118579. /**
  118580. * Sets the cone angle of the spot light in Radians.
  118581. */
  118582. set angle(value: number);
  118583. /**
  118584. * Only used in gltf falloff mode, this defines the angle where
  118585. * the directional falloff will start before cutting at angle which could be seen
  118586. * as outer angle.
  118587. */
  118588. get innerAngle(): number;
  118589. /**
  118590. * Only used in gltf falloff mode, this defines the angle where
  118591. * the directional falloff will start before cutting at angle which could be seen
  118592. * as outer angle.
  118593. */
  118594. set innerAngle(value: number);
  118595. private _shadowAngleScale;
  118596. /**
  118597. * Allows scaling the angle of the light for shadow generation only.
  118598. */
  118599. get shadowAngleScale(): number;
  118600. /**
  118601. * Allows scaling the angle of the light for shadow generation only.
  118602. */
  118603. set shadowAngleScale(value: number);
  118604. /**
  118605. * The light decay speed with the distance from the emission spot.
  118606. */
  118607. exponent: number;
  118608. private _projectionTextureMatrix;
  118609. /**
  118610. * Allows reading the projecton texture
  118611. */
  118612. get projectionTextureMatrix(): Matrix;
  118613. protected _projectionTextureLightNear: number;
  118614. /**
  118615. * Gets the near clip of the Spotlight for texture projection.
  118616. */
  118617. get projectionTextureLightNear(): number;
  118618. /**
  118619. * Sets the near clip of the Spotlight for texture projection.
  118620. */
  118621. set projectionTextureLightNear(value: number);
  118622. protected _projectionTextureLightFar: number;
  118623. /**
  118624. * Gets the far clip of the Spotlight for texture projection.
  118625. */
  118626. get projectionTextureLightFar(): number;
  118627. /**
  118628. * Sets the far clip of the Spotlight for texture projection.
  118629. */
  118630. set projectionTextureLightFar(value: number);
  118631. protected _projectionTextureUpDirection: Vector3;
  118632. /**
  118633. * Gets the Up vector of the Spotlight for texture projection.
  118634. */
  118635. get projectionTextureUpDirection(): Vector3;
  118636. /**
  118637. * Sets the Up vector of the Spotlight for texture projection.
  118638. */
  118639. set projectionTextureUpDirection(value: Vector3);
  118640. private _projectionTexture;
  118641. /**
  118642. * Gets the projection texture of the light.
  118643. */
  118644. get projectionTexture(): Nullable<BaseTexture>;
  118645. /**
  118646. * Sets the projection texture of the light.
  118647. */
  118648. set projectionTexture(value: Nullable<BaseTexture>);
  118649. private _projectionTextureViewLightDirty;
  118650. private _projectionTextureProjectionLightDirty;
  118651. private _projectionTextureDirty;
  118652. private _projectionTextureViewTargetVector;
  118653. private _projectionTextureViewLightMatrix;
  118654. private _projectionTextureProjectionLightMatrix;
  118655. private _projectionTextureScalingMatrix;
  118656. /**
  118657. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118658. * It can cast shadows.
  118659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118660. * @param name The light friendly name
  118661. * @param position The position of the spot light in the scene
  118662. * @param direction The direction of the light in the scene
  118663. * @param angle The cone angle of the light in Radians
  118664. * @param exponent The light decay speed with the distance from the emission spot
  118665. * @param scene The scene the lights belongs to
  118666. */
  118667. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118668. /**
  118669. * Returns the string "SpotLight".
  118670. * @returns the class name
  118671. */
  118672. getClassName(): string;
  118673. /**
  118674. * Returns the integer 2.
  118675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118676. */
  118677. getTypeID(): number;
  118678. /**
  118679. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118680. */
  118681. protected _setDirection(value: Vector3): void;
  118682. /**
  118683. * Overrides the position setter to recompute the projection texture view light Matrix.
  118684. */
  118685. protected _setPosition(value: Vector3): void;
  118686. /**
  118687. * 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.
  118688. * Returns the SpotLight.
  118689. */
  118690. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118691. protected _computeProjectionTextureViewLightMatrix(): void;
  118692. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118693. /**
  118694. * Main function for light texture projection matrix computing.
  118695. */
  118696. protected _computeProjectionTextureMatrix(): void;
  118697. protected _buildUniformLayout(): void;
  118698. private _computeAngleValues;
  118699. /**
  118700. * Sets the passed Effect "effect" with the Light textures.
  118701. * @param effect The effect to update
  118702. * @param lightIndex The index of the light in the effect to update
  118703. * @returns The light
  118704. */
  118705. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118706. /**
  118707. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118708. * @param effect The effect to update
  118709. * @param lightIndex The index of the light in the effect to update
  118710. * @returns The spot light
  118711. */
  118712. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118713. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118714. /**
  118715. * Disposes the light and the associated resources.
  118716. */
  118717. dispose(): void;
  118718. /**
  118719. * Prepares the list of defines specific to the light type.
  118720. * @param defines the list of defines
  118721. * @param lightIndex defines the index of the light for the effect
  118722. */
  118723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118724. }
  118725. }
  118726. declare module BABYLON {
  118727. /**
  118728. * Gizmo that enables viewing a light
  118729. */
  118730. export class LightGizmo extends Gizmo {
  118731. private _lightMesh;
  118732. private _material;
  118733. private _cachedPosition;
  118734. private _cachedForward;
  118735. private _attachedMeshParent;
  118736. /**
  118737. * Creates a LightGizmo
  118738. * @param gizmoLayer The utility layer the gizmo will be added to
  118739. */
  118740. constructor(gizmoLayer?: UtilityLayerRenderer);
  118741. private _light;
  118742. /**
  118743. * The light that the gizmo is attached to
  118744. */
  118745. set light(light: Nullable<Light>);
  118746. get light(): Nullable<Light>;
  118747. /**
  118748. * Gets the material used to render the light gizmo
  118749. */
  118750. get material(): StandardMaterial;
  118751. /**
  118752. * @hidden
  118753. * Updates the gizmo to match the attached mesh's position/rotation
  118754. */
  118755. protected _update(): void;
  118756. private static _Scale;
  118757. /**
  118758. * Creates the lines for a light mesh
  118759. */
  118760. private static _CreateLightLines;
  118761. /**
  118762. * Disposes of the light gizmo
  118763. */
  118764. dispose(): void;
  118765. private static _CreateHemisphericLightMesh;
  118766. private static _CreatePointLightMesh;
  118767. private static _CreateSpotLightMesh;
  118768. private static _CreateDirectionalLightMesh;
  118769. }
  118770. }
  118771. declare module BABYLON {
  118772. /** @hidden */
  118773. export var backgroundFragmentDeclaration: {
  118774. name: string;
  118775. shader: string;
  118776. };
  118777. }
  118778. declare module BABYLON {
  118779. /** @hidden */
  118780. export var backgroundUboDeclaration: {
  118781. name: string;
  118782. shader: string;
  118783. };
  118784. }
  118785. declare module BABYLON {
  118786. /** @hidden */
  118787. export var backgroundPixelShader: {
  118788. name: string;
  118789. shader: string;
  118790. };
  118791. }
  118792. declare module BABYLON {
  118793. /** @hidden */
  118794. export var backgroundVertexDeclaration: {
  118795. name: string;
  118796. shader: string;
  118797. };
  118798. }
  118799. declare module BABYLON {
  118800. /** @hidden */
  118801. export var backgroundVertexShader: {
  118802. name: string;
  118803. shader: string;
  118804. };
  118805. }
  118806. declare module BABYLON {
  118807. /**
  118808. * Background material used to create an efficient environement around your scene.
  118809. */
  118810. export class BackgroundMaterial extends PushMaterial {
  118811. /**
  118812. * Standard reflectance value at parallel view angle.
  118813. */
  118814. static StandardReflectance0: number;
  118815. /**
  118816. * Standard reflectance value at grazing angle.
  118817. */
  118818. static StandardReflectance90: number;
  118819. protected _primaryColor: Color3;
  118820. /**
  118821. * Key light Color (multiply against the environement texture)
  118822. */
  118823. primaryColor: Color3;
  118824. protected __perceptualColor: Nullable<Color3>;
  118825. /**
  118826. * Experimental Internal Use Only.
  118827. *
  118828. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118829. * This acts as a helper to set the primary color to a more "human friendly" value.
  118830. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118831. * output color as close as possible from the chosen value.
  118832. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118833. * part of lighting setup.)
  118834. */
  118835. get _perceptualColor(): Nullable<Color3>;
  118836. set _perceptualColor(value: Nullable<Color3>);
  118837. protected _primaryColorShadowLevel: float;
  118838. /**
  118839. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118840. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118841. */
  118842. get primaryColorShadowLevel(): float;
  118843. set primaryColorShadowLevel(value: float);
  118844. protected _primaryColorHighlightLevel: float;
  118845. /**
  118846. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118847. * The primary color is used at the level chosen to define what the white area would look.
  118848. */
  118849. get primaryColorHighlightLevel(): float;
  118850. set primaryColorHighlightLevel(value: float);
  118851. protected _reflectionTexture: Nullable<BaseTexture>;
  118852. /**
  118853. * Reflection Texture used in the material.
  118854. * Should be author in a specific way for the best result (refer to the documentation).
  118855. */
  118856. reflectionTexture: Nullable<BaseTexture>;
  118857. protected _reflectionBlur: float;
  118858. /**
  118859. * Reflection Texture level of blur.
  118860. *
  118861. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118862. * texture twice.
  118863. */
  118864. reflectionBlur: float;
  118865. protected _diffuseTexture: Nullable<BaseTexture>;
  118866. /**
  118867. * Diffuse Texture used in the material.
  118868. * Should be author in a specific way for the best result (refer to the documentation).
  118869. */
  118870. diffuseTexture: Nullable<BaseTexture>;
  118871. protected _shadowLights: Nullable<IShadowLight[]>;
  118872. /**
  118873. * Specify the list of lights casting shadow on the material.
  118874. * All scene shadow lights will be included if null.
  118875. */
  118876. shadowLights: Nullable<IShadowLight[]>;
  118877. protected _shadowLevel: float;
  118878. /**
  118879. * Helps adjusting the shadow to a softer level if required.
  118880. * 0 means black shadows and 1 means no shadows.
  118881. */
  118882. shadowLevel: float;
  118883. protected _sceneCenter: Vector3;
  118884. /**
  118885. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118886. * It is usually zero but might be interesting to modify according to your setup.
  118887. */
  118888. sceneCenter: Vector3;
  118889. protected _opacityFresnel: boolean;
  118890. /**
  118891. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118892. * This helps ensuring a nice transition when the camera goes under the ground.
  118893. */
  118894. opacityFresnel: boolean;
  118895. protected _reflectionFresnel: boolean;
  118896. /**
  118897. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118898. * This helps adding a mirror texture on the ground.
  118899. */
  118900. reflectionFresnel: boolean;
  118901. protected _reflectionFalloffDistance: number;
  118902. /**
  118903. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118904. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118905. */
  118906. reflectionFalloffDistance: number;
  118907. protected _reflectionAmount: number;
  118908. /**
  118909. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118910. */
  118911. reflectionAmount: number;
  118912. protected _reflectionReflectance0: number;
  118913. /**
  118914. * This specifies the weight of the reflection at grazing angle.
  118915. */
  118916. reflectionReflectance0: number;
  118917. protected _reflectionReflectance90: number;
  118918. /**
  118919. * This specifies the weight of the reflection at a perpendicular point of view.
  118920. */
  118921. reflectionReflectance90: number;
  118922. /**
  118923. * Sets the reflection reflectance fresnel values according to the default standard
  118924. * empirically know to work well :-)
  118925. */
  118926. set reflectionStandardFresnelWeight(value: number);
  118927. protected _useRGBColor: boolean;
  118928. /**
  118929. * Helps to directly use the maps channels instead of their level.
  118930. */
  118931. useRGBColor: boolean;
  118932. protected _enableNoise: boolean;
  118933. /**
  118934. * This helps reducing the banding effect that could occur on the background.
  118935. */
  118936. enableNoise: boolean;
  118937. /**
  118938. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118939. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118940. * Recommended to be keep at 1.0 except for special cases.
  118941. */
  118942. get fovMultiplier(): number;
  118943. set fovMultiplier(value: number);
  118944. private _fovMultiplier;
  118945. /**
  118946. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118947. */
  118948. useEquirectangularFOV: boolean;
  118949. private _maxSimultaneousLights;
  118950. /**
  118951. * Number of Simultaneous lights allowed on the material.
  118952. */
  118953. maxSimultaneousLights: int;
  118954. /**
  118955. * Default configuration related to image processing available in the Background Material.
  118956. */
  118957. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118958. /**
  118959. * Keep track of the image processing observer to allow dispose and replace.
  118960. */
  118961. private _imageProcessingObserver;
  118962. /**
  118963. * Attaches a new image processing configuration to the PBR Material.
  118964. * @param configuration (if null the scene configuration will be use)
  118965. */
  118966. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118967. /**
  118968. * Gets the image processing configuration used either in this material.
  118969. */
  118970. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118971. /**
  118972. * Sets the Default image processing configuration used either in the this material.
  118973. *
  118974. * If sets to null, the scene one is in use.
  118975. */
  118976. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118977. /**
  118978. * Gets wether the color curves effect is enabled.
  118979. */
  118980. get cameraColorCurvesEnabled(): boolean;
  118981. /**
  118982. * Sets wether the color curves effect is enabled.
  118983. */
  118984. set cameraColorCurvesEnabled(value: boolean);
  118985. /**
  118986. * Gets wether the color grading effect is enabled.
  118987. */
  118988. get cameraColorGradingEnabled(): boolean;
  118989. /**
  118990. * Gets wether the color grading effect is enabled.
  118991. */
  118992. set cameraColorGradingEnabled(value: boolean);
  118993. /**
  118994. * Gets wether tonemapping is enabled or not.
  118995. */
  118996. get cameraToneMappingEnabled(): boolean;
  118997. /**
  118998. * Sets wether tonemapping is enabled or not
  118999. */
  119000. set cameraToneMappingEnabled(value: boolean);
  119001. /**
  119002. * The camera exposure used on this material.
  119003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119004. * This corresponds to a photographic exposure.
  119005. */
  119006. get cameraExposure(): float;
  119007. /**
  119008. * The camera exposure used on this material.
  119009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119010. * This corresponds to a photographic exposure.
  119011. */
  119012. set cameraExposure(value: float);
  119013. /**
  119014. * Gets The camera contrast used on this material.
  119015. */
  119016. get cameraContrast(): float;
  119017. /**
  119018. * Sets The camera contrast used on this material.
  119019. */
  119020. set cameraContrast(value: float);
  119021. /**
  119022. * Gets the Color Grading 2D Lookup Texture.
  119023. */
  119024. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  119025. /**
  119026. * Sets the Color Grading 2D Lookup Texture.
  119027. */
  119028. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  119029. /**
  119030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119032. * 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;
  119033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119034. */
  119035. get cameraColorCurves(): Nullable<ColorCurves>;
  119036. /**
  119037. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119038. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119039. * 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;
  119040. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119041. */
  119042. set cameraColorCurves(value: Nullable<ColorCurves>);
  119043. /**
  119044. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  119045. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  119046. */
  119047. switchToBGR: boolean;
  119048. private _renderTargets;
  119049. private _reflectionControls;
  119050. private _white;
  119051. private _primaryShadowColor;
  119052. private _primaryHighlightColor;
  119053. /**
  119054. * Instantiates a Background Material in the given scene
  119055. * @param name The friendly name of the material
  119056. * @param scene The scene to add the material to
  119057. */
  119058. constructor(name: string, scene: Scene);
  119059. /**
  119060. * Gets a boolean indicating that current material needs to register RTT
  119061. */
  119062. get hasRenderTargetTextures(): boolean;
  119063. /**
  119064. * The entire material has been created in order to prevent overdraw.
  119065. * @returns false
  119066. */
  119067. needAlphaTesting(): boolean;
  119068. /**
  119069. * The entire material has been created in order to prevent overdraw.
  119070. * @returns true if blending is enable
  119071. */
  119072. needAlphaBlending(): boolean;
  119073. /**
  119074. * Checks wether the material is ready to be rendered for a given mesh.
  119075. * @param mesh The mesh to render
  119076. * @param subMesh The submesh to check against
  119077. * @param useInstances Specify wether or not the material is used with instances
  119078. * @returns true if all the dependencies are ready (Textures, Effects...)
  119079. */
  119080. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119081. /**
  119082. * Compute the primary color according to the chosen perceptual color.
  119083. */
  119084. private _computePrimaryColorFromPerceptualColor;
  119085. /**
  119086. * Compute the highlights and shadow colors according to their chosen levels.
  119087. */
  119088. private _computePrimaryColors;
  119089. /**
  119090. * Build the uniform buffer used in the material.
  119091. */
  119092. buildUniformLayout(): void;
  119093. /**
  119094. * Unbind the material.
  119095. */
  119096. unbind(): void;
  119097. /**
  119098. * Bind only the world matrix to the material.
  119099. * @param world The world matrix to bind.
  119100. */
  119101. bindOnlyWorldMatrix(world: Matrix): void;
  119102. /**
  119103. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  119104. * @param world The world matrix to bind.
  119105. * @param subMesh The submesh to bind for.
  119106. */
  119107. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119108. /**
  119109. * Checks to see if a texture is used in the material.
  119110. * @param texture - Base texture to use.
  119111. * @returns - Boolean specifying if a texture is used in the material.
  119112. */
  119113. hasTexture(texture: BaseTexture): boolean;
  119114. /**
  119115. * Dispose the material.
  119116. * @param forceDisposeEffect Force disposal of the associated effect.
  119117. * @param forceDisposeTextures Force disposal of the associated textures.
  119118. */
  119119. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  119120. /**
  119121. * Clones the material.
  119122. * @param name The cloned name.
  119123. * @returns The cloned material.
  119124. */
  119125. clone(name: string): BackgroundMaterial;
  119126. /**
  119127. * Serializes the current material to its JSON representation.
  119128. * @returns The JSON representation.
  119129. */
  119130. serialize(): any;
  119131. /**
  119132. * Gets the class name of the material
  119133. * @returns "BackgroundMaterial"
  119134. */
  119135. getClassName(): string;
  119136. /**
  119137. * Parse a JSON input to create back a background material.
  119138. * @param source The JSON data to parse
  119139. * @param scene The scene to create the parsed material in
  119140. * @param rootUrl The root url of the assets the material depends upon
  119141. * @returns the instantiated BackgroundMaterial.
  119142. */
  119143. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  119144. }
  119145. }
  119146. declare module BABYLON {
  119147. /**
  119148. * Represents the different options available during the creation of
  119149. * a Environment helper.
  119150. *
  119151. * This can control the default ground, skybox and image processing setup of your scene.
  119152. */
  119153. export interface IEnvironmentHelperOptions {
  119154. /**
  119155. * Specifies wether or not to create a ground.
  119156. * True by default.
  119157. */
  119158. createGround: boolean;
  119159. /**
  119160. * Specifies the ground size.
  119161. * 15 by default.
  119162. */
  119163. groundSize: number;
  119164. /**
  119165. * The texture used on the ground for the main color.
  119166. * Comes from the BabylonJS CDN by default.
  119167. *
  119168. * Remarks: Can be either a texture or a url.
  119169. */
  119170. groundTexture: string | BaseTexture;
  119171. /**
  119172. * The color mixed in the ground texture by default.
  119173. * BabylonJS clearColor by default.
  119174. */
  119175. groundColor: Color3;
  119176. /**
  119177. * Specifies the ground opacity.
  119178. * 1 by default.
  119179. */
  119180. groundOpacity: number;
  119181. /**
  119182. * Enables the ground to receive shadows.
  119183. * True by default.
  119184. */
  119185. enableGroundShadow: boolean;
  119186. /**
  119187. * Helps preventing the shadow to be fully black on the ground.
  119188. * 0.5 by default.
  119189. */
  119190. groundShadowLevel: number;
  119191. /**
  119192. * Creates a mirror texture attach to the ground.
  119193. * false by default.
  119194. */
  119195. enableGroundMirror: boolean;
  119196. /**
  119197. * Specifies the ground mirror size ratio.
  119198. * 0.3 by default as the default kernel is 64.
  119199. */
  119200. groundMirrorSizeRatio: number;
  119201. /**
  119202. * Specifies the ground mirror blur kernel size.
  119203. * 64 by default.
  119204. */
  119205. groundMirrorBlurKernel: number;
  119206. /**
  119207. * Specifies the ground mirror visibility amount.
  119208. * 1 by default
  119209. */
  119210. groundMirrorAmount: number;
  119211. /**
  119212. * Specifies the ground mirror reflectance weight.
  119213. * This uses the standard weight of the background material to setup the fresnel effect
  119214. * of the mirror.
  119215. * 1 by default.
  119216. */
  119217. groundMirrorFresnelWeight: number;
  119218. /**
  119219. * Specifies the ground mirror Falloff distance.
  119220. * This can helps reducing the size of the reflection.
  119221. * 0 by Default.
  119222. */
  119223. groundMirrorFallOffDistance: number;
  119224. /**
  119225. * Specifies the ground mirror texture type.
  119226. * Unsigned Int by Default.
  119227. */
  119228. groundMirrorTextureType: number;
  119229. /**
  119230. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119231. * the shown objects.
  119232. */
  119233. groundYBias: number;
  119234. /**
  119235. * Specifies wether or not to create a skybox.
  119236. * True by default.
  119237. */
  119238. createSkybox: boolean;
  119239. /**
  119240. * Specifies the skybox size.
  119241. * 20 by default.
  119242. */
  119243. skyboxSize: number;
  119244. /**
  119245. * The texture used on the skybox for the main color.
  119246. * Comes from the BabylonJS CDN by default.
  119247. *
  119248. * Remarks: Can be either a texture or a url.
  119249. */
  119250. skyboxTexture: string | BaseTexture;
  119251. /**
  119252. * The color mixed in the skybox texture by default.
  119253. * BabylonJS clearColor by default.
  119254. */
  119255. skyboxColor: Color3;
  119256. /**
  119257. * The background rotation around the Y axis of the scene.
  119258. * This helps aligning the key lights of your scene with the background.
  119259. * 0 by default.
  119260. */
  119261. backgroundYRotation: number;
  119262. /**
  119263. * Compute automatically the size of the elements to best fit with the scene.
  119264. */
  119265. sizeAuto: boolean;
  119266. /**
  119267. * Default position of the rootMesh if autoSize is not true.
  119268. */
  119269. rootPosition: Vector3;
  119270. /**
  119271. * Sets up the image processing in the scene.
  119272. * true by default.
  119273. */
  119274. setupImageProcessing: boolean;
  119275. /**
  119276. * The texture used as your environment texture in the scene.
  119277. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119278. *
  119279. * Remarks: Can be either a texture or a url.
  119280. */
  119281. environmentTexture: string | BaseTexture;
  119282. /**
  119283. * The value of the exposure to apply to the scene.
  119284. * 0.6 by default if setupImageProcessing is true.
  119285. */
  119286. cameraExposure: number;
  119287. /**
  119288. * The value of the contrast to apply to the scene.
  119289. * 1.6 by default if setupImageProcessing is true.
  119290. */
  119291. cameraContrast: number;
  119292. /**
  119293. * Specifies wether or not tonemapping should be enabled in the scene.
  119294. * true by default if setupImageProcessing is true.
  119295. */
  119296. toneMappingEnabled: boolean;
  119297. }
  119298. /**
  119299. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119300. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119301. * It also helps with the default setup of your imageProcessing configuration.
  119302. */
  119303. export class EnvironmentHelper {
  119304. /**
  119305. * Default ground texture URL.
  119306. */
  119307. private static _groundTextureCDNUrl;
  119308. /**
  119309. * Default skybox texture URL.
  119310. */
  119311. private static _skyboxTextureCDNUrl;
  119312. /**
  119313. * Default environment texture URL.
  119314. */
  119315. private static _environmentTextureCDNUrl;
  119316. /**
  119317. * Creates the default options for the helper.
  119318. */
  119319. private static _getDefaultOptions;
  119320. private _rootMesh;
  119321. /**
  119322. * Gets the root mesh created by the helper.
  119323. */
  119324. get rootMesh(): Mesh;
  119325. private _skybox;
  119326. /**
  119327. * Gets the skybox created by the helper.
  119328. */
  119329. get skybox(): Nullable<Mesh>;
  119330. private _skyboxTexture;
  119331. /**
  119332. * Gets the skybox texture created by the helper.
  119333. */
  119334. get skyboxTexture(): Nullable<BaseTexture>;
  119335. private _skyboxMaterial;
  119336. /**
  119337. * Gets the skybox material created by the helper.
  119338. */
  119339. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119340. private _ground;
  119341. /**
  119342. * Gets the ground mesh created by the helper.
  119343. */
  119344. get ground(): Nullable<Mesh>;
  119345. private _groundTexture;
  119346. /**
  119347. * Gets the ground texture created by the helper.
  119348. */
  119349. get groundTexture(): Nullable<BaseTexture>;
  119350. private _groundMirror;
  119351. /**
  119352. * Gets the ground mirror created by the helper.
  119353. */
  119354. get groundMirror(): Nullable<MirrorTexture>;
  119355. /**
  119356. * Gets the ground mirror render list to helps pushing the meshes
  119357. * you wish in the ground reflection.
  119358. */
  119359. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119360. private _groundMaterial;
  119361. /**
  119362. * Gets the ground material created by the helper.
  119363. */
  119364. get groundMaterial(): Nullable<BackgroundMaterial>;
  119365. /**
  119366. * Stores the creation options.
  119367. */
  119368. private readonly _scene;
  119369. private _options;
  119370. /**
  119371. * This observable will be notified with any error during the creation of the environment,
  119372. * mainly texture creation errors.
  119373. */
  119374. onErrorObservable: Observable<{
  119375. message?: string;
  119376. exception?: any;
  119377. }>;
  119378. /**
  119379. * constructor
  119380. * @param options Defines the options we want to customize the helper
  119381. * @param scene The scene to add the material to
  119382. */
  119383. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119384. /**
  119385. * Updates the background according to the new options
  119386. * @param options
  119387. */
  119388. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119389. /**
  119390. * Sets the primary color of all the available elements.
  119391. * @param color the main color to affect to the ground and the background
  119392. */
  119393. setMainColor(color: Color3): void;
  119394. /**
  119395. * Setup the image processing according to the specified options.
  119396. */
  119397. private _setupImageProcessing;
  119398. /**
  119399. * Setup the environment texture according to the specified options.
  119400. */
  119401. private _setupEnvironmentTexture;
  119402. /**
  119403. * Setup the background according to the specified options.
  119404. */
  119405. private _setupBackground;
  119406. /**
  119407. * Get the scene sizes according to the setup.
  119408. */
  119409. private _getSceneSize;
  119410. /**
  119411. * Setup the ground according to the specified options.
  119412. */
  119413. private _setupGround;
  119414. /**
  119415. * Setup the ground material according to the specified options.
  119416. */
  119417. private _setupGroundMaterial;
  119418. /**
  119419. * Setup the ground diffuse texture according to the specified options.
  119420. */
  119421. private _setupGroundDiffuseTexture;
  119422. /**
  119423. * Setup the ground mirror texture according to the specified options.
  119424. */
  119425. private _setupGroundMirrorTexture;
  119426. /**
  119427. * Setup the ground to receive the mirror texture.
  119428. */
  119429. private _setupMirrorInGroundMaterial;
  119430. /**
  119431. * Setup the skybox according to the specified options.
  119432. */
  119433. private _setupSkybox;
  119434. /**
  119435. * Setup the skybox material according to the specified options.
  119436. */
  119437. private _setupSkyboxMaterial;
  119438. /**
  119439. * Setup the skybox reflection texture according to the specified options.
  119440. */
  119441. private _setupSkyboxReflectionTexture;
  119442. private _errorHandler;
  119443. /**
  119444. * Dispose all the elements created by the Helper.
  119445. */
  119446. dispose(): void;
  119447. }
  119448. }
  119449. declare module BABYLON {
  119450. /**
  119451. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119452. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119453. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119454. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119455. */
  119456. export class PhotoDome extends TransformNode {
  119457. /**
  119458. * Define the image as a Monoscopic panoramic 360 image.
  119459. */
  119460. static readonly MODE_MONOSCOPIC: number;
  119461. /**
  119462. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119463. */
  119464. static readonly MODE_TOPBOTTOM: number;
  119465. /**
  119466. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119467. */
  119468. static readonly MODE_SIDEBYSIDE: number;
  119469. private _useDirectMapping;
  119470. /**
  119471. * The texture being displayed on the sphere
  119472. */
  119473. protected _photoTexture: Texture;
  119474. /**
  119475. * Gets or sets the texture being displayed on the sphere
  119476. */
  119477. get photoTexture(): Texture;
  119478. set photoTexture(value: Texture);
  119479. /**
  119480. * Observable raised when an error occured while loading the 360 image
  119481. */
  119482. onLoadErrorObservable: Observable<string>;
  119483. /**
  119484. * The skybox material
  119485. */
  119486. protected _material: BackgroundMaterial;
  119487. /**
  119488. * The surface used for the skybox
  119489. */
  119490. protected _mesh: Mesh;
  119491. /**
  119492. * Gets the mesh used for the skybox.
  119493. */
  119494. get mesh(): Mesh;
  119495. /**
  119496. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119497. * Also see the options.resolution property.
  119498. */
  119499. get fovMultiplier(): number;
  119500. set fovMultiplier(value: number);
  119501. private _imageMode;
  119502. /**
  119503. * Gets or set the current video mode for the video. It can be:
  119504. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119505. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119506. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119507. */
  119508. get imageMode(): number;
  119509. set imageMode(value: number);
  119510. /**
  119511. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119512. * @param name Element's name, child elements will append suffixes for their own names.
  119513. * @param urlsOfPhoto defines the url of the photo to display
  119514. * @param options defines an object containing optional or exposed sub element properties
  119515. * @param onError defines a callback called when an error occured while loading the texture
  119516. */
  119517. constructor(name: string, urlOfPhoto: string, options: {
  119518. resolution?: number;
  119519. size?: number;
  119520. useDirectMapping?: boolean;
  119521. faceForward?: boolean;
  119522. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119523. private _onBeforeCameraRenderObserver;
  119524. private _changeImageMode;
  119525. /**
  119526. * Releases resources associated with this node.
  119527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119529. */
  119530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119531. }
  119532. }
  119533. declare module BABYLON {
  119534. /**
  119535. * Class used to host RGBD texture specific utilities
  119536. */
  119537. export class RGBDTextureTools {
  119538. /**
  119539. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119540. * @param texture the texture to expand.
  119541. */
  119542. static ExpandRGBDTexture(texture: Texture): void;
  119543. }
  119544. }
  119545. declare module BABYLON {
  119546. /**
  119547. * Class used to host texture specific utilities
  119548. */
  119549. export class BRDFTextureTools {
  119550. /**
  119551. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119552. * @param scene defines the hosting scene
  119553. * @returns the environment BRDF texture
  119554. */
  119555. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119556. private static _environmentBRDFBase64Texture;
  119557. }
  119558. }
  119559. declare module BABYLON {
  119560. /**
  119561. * @hidden
  119562. */
  119563. export interface IMaterialClearCoatDefines {
  119564. CLEARCOAT: boolean;
  119565. CLEARCOAT_DEFAULTIOR: boolean;
  119566. CLEARCOAT_TEXTURE: boolean;
  119567. CLEARCOAT_TEXTUREDIRECTUV: number;
  119568. CLEARCOAT_BUMP: boolean;
  119569. CLEARCOAT_BUMPDIRECTUV: number;
  119570. CLEARCOAT_TINT: boolean;
  119571. CLEARCOAT_TINT_TEXTURE: boolean;
  119572. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119573. /** @hidden */
  119574. _areTexturesDirty: boolean;
  119575. }
  119576. /**
  119577. * Define the code related to the clear coat parameters of the pbr material.
  119578. */
  119579. export class PBRClearCoatConfiguration {
  119580. /**
  119581. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119582. * The default fits with a polyurethane material.
  119583. */
  119584. private static readonly _DefaultIndexOfRefraction;
  119585. private _isEnabled;
  119586. /**
  119587. * Defines if the clear coat is enabled in the material.
  119588. */
  119589. isEnabled: boolean;
  119590. /**
  119591. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119592. */
  119593. intensity: number;
  119594. /**
  119595. * Defines the clear coat layer roughness.
  119596. */
  119597. roughness: number;
  119598. private _indexOfRefraction;
  119599. /**
  119600. * Defines the index of refraction of the clear coat.
  119601. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119602. * The default fits with a polyurethane material.
  119603. * Changing the default value is more performance intensive.
  119604. */
  119605. indexOfRefraction: number;
  119606. private _texture;
  119607. /**
  119608. * Stores the clear coat values in a texture.
  119609. */
  119610. texture: Nullable<BaseTexture>;
  119611. private _bumpTexture;
  119612. /**
  119613. * Define the clear coat specific bump texture.
  119614. */
  119615. bumpTexture: Nullable<BaseTexture>;
  119616. private _isTintEnabled;
  119617. /**
  119618. * Defines if the clear coat tint is enabled in the material.
  119619. */
  119620. isTintEnabled: boolean;
  119621. /**
  119622. * Defines the clear coat tint of the material.
  119623. * This is only use if tint is enabled
  119624. */
  119625. tintColor: Color3;
  119626. /**
  119627. * Defines the distance at which the tint color should be found in the
  119628. * clear coat media.
  119629. * This is only use if tint is enabled
  119630. */
  119631. tintColorAtDistance: number;
  119632. /**
  119633. * Defines the clear coat layer thickness.
  119634. * This is only use if tint is enabled
  119635. */
  119636. tintThickness: number;
  119637. private _tintTexture;
  119638. /**
  119639. * Stores the clear tint values in a texture.
  119640. * rgb is tint
  119641. * a is a thickness factor
  119642. */
  119643. tintTexture: Nullable<BaseTexture>;
  119644. /** @hidden */
  119645. private _internalMarkAllSubMeshesAsTexturesDirty;
  119646. /** @hidden */
  119647. _markAllSubMeshesAsTexturesDirty(): void;
  119648. /**
  119649. * Instantiate a new istance of clear coat configuration.
  119650. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119651. */
  119652. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119653. /**
  119654. * Gets wehter the submesh is ready to be used or not.
  119655. * @param defines the list of "defines" to update.
  119656. * @param scene defines the scene the material belongs to.
  119657. * @param engine defines the engine the material belongs to.
  119658. * @param disableBumpMap defines wether the material disables bump or not.
  119659. * @returns - boolean indicating that the submesh is ready or not.
  119660. */
  119661. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119662. /**
  119663. * Checks to see if a texture is used in the material.
  119664. * @param defines the list of "defines" to update.
  119665. * @param scene defines the scene to the material belongs to.
  119666. */
  119667. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119668. /**
  119669. * Binds the material data.
  119670. * @param uniformBuffer defines the Uniform buffer to fill in.
  119671. * @param scene defines the scene the material belongs to.
  119672. * @param engine defines the engine the material belongs to.
  119673. * @param disableBumpMap defines wether the material disables bump or not.
  119674. * @param isFrozen defines wether the material is frozen or not.
  119675. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119676. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119677. */
  119678. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119679. /**
  119680. * Checks to see if a texture is used in the material.
  119681. * @param texture - Base texture to use.
  119682. * @returns - Boolean specifying if a texture is used in the material.
  119683. */
  119684. hasTexture(texture: BaseTexture): boolean;
  119685. /**
  119686. * Returns an array of the actively used textures.
  119687. * @param activeTextures Array of BaseTextures
  119688. */
  119689. getActiveTextures(activeTextures: BaseTexture[]): void;
  119690. /**
  119691. * Returns the animatable textures.
  119692. * @param animatables Array of animatable textures.
  119693. */
  119694. getAnimatables(animatables: IAnimatable[]): void;
  119695. /**
  119696. * Disposes the resources of the material.
  119697. * @param forceDisposeTextures - Forces the disposal of all textures.
  119698. */
  119699. dispose(forceDisposeTextures?: boolean): void;
  119700. /**
  119701. * Get the current class name of the texture useful for serialization or dynamic coding.
  119702. * @returns "PBRClearCoatConfiguration"
  119703. */
  119704. getClassName(): string;
  119705. /**
  119706. * Add fallbacks to the effect fallbacks list.
  119707. * @param defines defines the Base texture to use.
  119708. * @param fallbacks defines the current fallback list.
  119709. * @param currentRank defines the current fallback rank.
  119710. * @returns the new fallback rank.
  119711. */
  119712. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119713. /**
  119714. * Add the required uniforms to the current list.
  119715. * @param uniforms defines the current uniform list.
  119716. */
  119717. static AddUniforms(uniforms: string[]): void;
  119718. /**
  119719. * Add the required samplers to the current list.
  119720. * @param samplers defines the current sampler list.
  119721. */
  119722. static AddSamplers(samplers: string[]): void;
  119723. /**
  119724. * Add the required uniforms to the current buffer.
  119725. * @param uniformBuffer defines the current uniform buffer.
  119726. */
  119727. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119728. /**
  119729. * Makes a duplicate of the current configuration into another one.
  119730. * @param clearCoatConfiguration define the config where to copy the info
  119731. */
  119732. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119733. /**
  119734. * Serializes this clear coat configuration.
  119735. * @returns - An object with the serialized config.
  119736. */
  119737. serialize(): any;
  119738. /**
  119739. * Parses a anisotropy Configuration from a serialized object.
  119740. * @param source - Serialized object.
  119741. * @param scene Defines the scene we are parsing for
  119742. * @param rootUrl Defines the rootUrl to load from
  119743. */
  119744. parse(source: any, scene: Scene, rootUrl: string): void;
  119745. }
  119746. }
  119747. declare module BABYLON {
  119748. /**
  119749. * @hidden
  119750. */
  119751. export interface IMaterialAnisotropicDefines {
  119752. ANISOTROPIC: boolean;
  119753. ANISOTROPIC_TEXTURE: boolean;
  119754. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119755. MAINUV1: boolean;
  119756. _areTexturesDirty: boolean;
  119757. _needUVs: boolean;
  119758. }
  119759. /**
  119760. * Define the code related to the anisotropic parameters of the pbr material.
  119761. */
  119762. export class PBRAnisotropicConfiguration {
  119763. private _isEnabled;
  119764. /**
  119765. * Defines if the anisotropy is enabled in the material.
  119766. */
  119767. isEnabled: boolean;
  119768. /**
  119769. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119770. */
  119771. intensity: number;
  119772. /**
  119773. * Defines if the effect is along the tangents, bitangents or in between.
  119774. * By default, the effect is "strectching" the highlights along the tangents.
  119775. */
  119776. direction: Vector2;
  119777. private _texture;
  119778. /**
  119779. * Stores the anisotropy values in a texture.
  119780. * rg is direction (like normal from -1 to 1)
  119781. * b is a intensity
  119782. */
  119783. texture: Nullable<BaseTexture>;
  119784. /** @hidden */
  119785. private _internalMarkAllSubMeshesAsTexturesDirty;
  119786. /** @hidden */
  119787. _markAllSubMeshesAsTexturesDirty(): void;
  119788. /**
  119789. * Instantiate a new istance of anisotropy configuration.
  119790. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119791. */
  119792. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119793. /**
  119794. * Specifies that the submesh is ready to be used.
  119795. * @param defines the list of "defines" to update.
  119796. * @param scene defines the scene the material belongs to.
  119797. * @returns - boolean indicating that the submesh is ready or not.
  119798. */
  119799. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119800. /**
  119801. * Checks to see if a texture is used in the material.
  119802. * @param defines the list of "defines" to update.
  119803. * @param mesh the mesh we are preparing the defines for.
  119804. * @param scene defines the scene the material belongs to.
  119805. */
  119806. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119807. /**
  119808. * Binds the material data.
  119809. * @param uniformBuffer defines the Uniform buffer to fill in.
  119810. * @param scene defines the scene the material belongs to.
  119811. * @param isFrozen defines wether the material is frozen or not.
  119812. */
  119813. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119814. /**
  119815. * Checks to see if a texture is used in the material.
  119816. * @param texture - Base texture to use.
  119817. * @returns - Boolean specifying if a texture is used in the material.
  119818. */
  119819. hasTexture(texture: BaseTexture): boolean;
  119820. /**
  119821. * Returns an array of the actively used textures.
  119822. * @param activeTextures Array of BaseTextures
  119823. */
  119824. getActiveTextures(activeTextures: BaseTexture[]): void;
  119825. /**
  119826. * Returns the animatable textures.
  119827. * @param animatables Array of animatable textures.
  119828. */
  119829. getAnimatables(animatables: IAnimatable[]): void;
  119830. /**
  119831. * Disposes the resources of the material.
  119832. * @param forceDisposeTextures - Forces the disposal of all textures.
  119833. */
  119834. dispose(forceDisposeTextures?: boolean): void;
  119835. /**
  119836. * Get the current class name of the texture useful for serialization or dynamic coding.
  119837. * @returns "PBRAnisotropicConfiguration"
  119838. */
  119839. getClassName(): string;
  119840. /**
  119841. * Add fallbacks to the effect fallbacks list.
  119842. * @param defines defines the Base texture to use.
  119843. * @param fallbacks defines the current fallback list.
  119844. * @param currentRank defines the current fallback rank.
  119845. * @returns the new fallback rank.
  119846. */
  119847. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119848. /**
  119849. * Add the required uniforms to the current list.
  119850. * @param uniforms defines the current uniform list.
  119851. */
  119852. static AddUniforms(uniforms: string[]): void;
  119853. /**
  119854. * Add the required uniforms to the current buffer.
  119855. * @param uniformBuffer defines the current uniform buffer.
  119856. */
  119857. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119858. /**
  119859. * Add the required samplers to the current list.
  119860. * @param samplers defines the current sampler list.
  119861. */
  119862. static AddSamplers(samplers: string[]): void;
  119863. /**
  119864. * Makes a duplicate of the current configuration into another one.
  119865. * @param anisotropicConfiguration define the config where to copy the info
  119866. */
  119867. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119868. /**
  119869. * Serializes this anisotropy configuration.
  119870. * @returns - An object with the serialized config.
  119871. */
  119872. serialize(): any;
  119873. /**
  119874. * Parses a anisotropy Configuration from a serialized object.
  119875. * @param source - Serialized object.
  119876. * @param scene Defines the scene we are parsing for
  119877. * @param rootUrl Defines the rootUrl to load from
  119878. */
  119879. parse(source: any, scene: Scene, rootUrl: string): void;
  119880. }
  119881. }
  119882. declare module BABYLON {
  119883. /**
  119884. * @hidden
  119885. */
  119886. export interface IMaterialBRDFDefines {
  119887. BRDF_V_HEIGHT_CORRELATED: boolean;
  119888. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119889. SPHERICAL_HARMONICS: boolean;
  119890. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119891. /** @hidden */
  119892. _areMiscDirty: boolean;
  119893. }
  119894. /**
  119895. * Define the code related to the BRDF parameters of the pbr material.
  119896. */
  119897. export class PBRBRDFConfiguration {
  119898. /**
  119899. * Default value used for the energy conservation.
  119900. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119901. */
  119902. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119903. /**
  119904. * Default value used for the Smith Visibility Height Correlated mode.
  119905. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119906. */
  119907. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119908. /**
  119909. * Default value used for the IBL diffuse part.
  119910. * This can help switching back to the polynomials mode globally which is a tiny bit
  119911. * less GPU intensive at the drawback of a lower quality.
  119912. */
  119913. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119914. /**
  119915. * Default value used for activating energy conservation for the specular workflow.
  119916. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119917. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119918. */
  119919. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119920. private _useEnergyConservation;
  119921. /**
  119922. * Defines if the material uses energy conservation.
  119923. */
  119924. useEnergyConservation: boolean;
  119925. private _useSmithVisibilityHeightCorrelated;
  119926. /**
  119927. * LEGACY Mode set to false
  119928. * Defines if the material uses height smith correlated visibility term.
  119929. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119930. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119931. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119932. * Not relying on height correlated will also disable energy conservation.
  119933. */
  119934. useSmithVisibilityHeightCorrelated: boolean;
  119935. private _useSphericalHarmonics;
  119936. /**
  119937. * LEGACY Mode set to false
  119938. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119939. * diffuse part of the IBL.
  119940. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119941. * to the ground truth.
  119942. */
  119943. useSphericalHarmonics: boolean;
  119944. private _useSpecularGlossinessInputEnergyConservation;
  119945. /**
  119946. * Defines if the material uses energy conservation, when the specular workflow is active.
  119947. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119948. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119949. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119950. */
  119951. useSpecularGlossinessInputEnergyConservation: boolean;
  119952. /** @hidden */
  119953. private _internalMarkAllSubMeshesAsMiscDirty;
  119954. /** @hidden */
  119955. _markAllSubMeshesAsMiscDirty(): void;
  119956. /**
  119957. * Instantiate a new istance of clear coat configuration.
  119958. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119959. */
  119960. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119961. /**
  119962. * Checks to see if a texture is used in the material.
  119963. * @param defines the list of "defines" to update.
  119964. */
  119965. prepareDefines(defines: IMaterialBRDFDefines): void;
  119966. /**
  119967. * Get the current class name of the texture useful for serialization or dynamic coding.
  119968. * @returns "PBRClearCoatConfiguration"
  119969. */
  119970. getClassName(): string;
  119971. /**
  119972. * Makes a duplicate of the current configuration into another one.
  119973. * @param brdfConfiguration define the config where to copy the info
  119974. */
  119975. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119976. /**
  119977. * Serializes this BRDF configuration.
  119978. * @returns - An object with the serialized config.
  119979. */
  119980. serialize(): any;
  119981. /**
  119982. * Parses a anisotropy Configuration from a serialized object.
  119983. * @param source - Serialized object.
  119984. * @param scene Defines the scene we are parsing for
  119985. * @param rootUrl Defines the rootUrl to load from
  119986. */
  119987. parse(source: any, scene: Scene, rootUrl: string): void;
  119988. }
  119989. }
  119990. declare module BABYLON {
  119991. /**
  119992. * @hidden
  119993. */
  119994. export interface IMaterialSheenDefines {
  119995. SHEEN: boolean;
  119996. SHEEN_TEXTURE: boolean;
  119997. SHEEN_TEXTUREDIRECTUV: number;
  119998. SHEEN_LINKWITHALBEDO: boolean;
  119999. /** @hidden */
  120000. _areTexturesDirty: boolean;
  120001. }
  120002. /**
  120003. * Define the code related to the Sheen parameters of the pbr material.
  120004. */
  120005. export class PBRSheenConfiguration {
  120006. private _isEnabled;
  120007. /**
  120008. * Defines if the material uses sheen.
  120009. */
  120010. isEnabled: boolean;
  120011. private _linkSheenWithAlbedo;
  120012. /**
  120013. * Defines if the sheen is linked to the sheen color.
  120014. */
  120015. linkSheenWithAlbedo: boolean;
  120016. /**
  120017. * Defines the sheen intensity.
  120018. */
  120019. intensity: number;
  120020. /**
  120021. * Defines the sheen color.
  120022. */
  120023. color: Color3;
  120024. private _texture;
  120025. /**
  120026. * Stores the sheen tint values in a texture.
  120027. * rgb is tint
  120028. * a is a intensity
  120029. */
  120030. texture: Nullable<BaseTexture>;
  120031. /** @hidden */
  120032. private _internalMarkAllSubMeshesAsTexturesDirty;
  120033. /** @hidden */
  120034. _markAllSubMeshesAsTexturesDirty(): void;
  120035. /**
  120036. * Instantiate a new istance of clear coat configuration.
  120037. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120038. */
  120039. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120040. /**
  120041. * Specifies that the submesh is ready to be used.
  120042. * @param defines the list of "defines" to update.
  120043. * @param scene defines the scene the material belongs to.
  120044. * @returns - boolean indicating that the submesh is ready or not.
  120045. */
  120046. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  120047. /**
  120048. * Checks to see if a texture is used in the material.
  120049. * @param defines the list of "defines" to update.
  120050. * @param scene defines the scene the material belongs to.
  120051. */
  120052. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  120053. /**
  120054. * Binds the material data.
  120055. * @param uniformBuffer defines the Uniform buffer to fill in.
  120056. * @param scene defines the scene the material belongs to.
  120057. * @param isFrozen defines wether the material is frozen or not.
  120058. */
  120059. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  120060. /**
  120061. * Checks to see if a texture is used in the material.
  120062. * @param texture - Base texture to use.
  120063. * @returns - Boolean specifying if a texture is used in the material.
  120064. */
  120065. hasTexture(texture: BaseTexture): boolean;
  120066. /**
  120067. * Returns an array of the actively used textures.
  120068. * @param activeTextures Array of BaseTextures
  120069. */
  120070. getActiveTextures(activeTextures: BaseTexture[]): void;
  120071. /**
  120072. * Returns the animatable textures.
  120073. * @param animatables Array of animatable textures.
  120074. */
  120075. getAnimatables(animatables: IAnimatable[]): void;
  120076. /**
  120077. * Disposes the resources of the material.
  120078. * @param forceDisposeTextures - Forces the disposal of all textures.
  120079. */
  120080. dispose(forceDisposeTextures?: boolean): void;
  120081. /**
  120082. * Get the current class name of the texture useful for serialization or dynamic coding.
  120083. * @returns "PBRSheenConfiguration"
  120084. */
  120085. getClassName(): string;
  120086. /**
  120087. * Add fallbacks to the effect fallbacks list.
  120088. * @param defines defines the Base texture to use.
  120089. * @param fallbacks defines the current fallback list.
  120090. * @param currentRank defines the current fallback rank.
  120091. * @returns the new fallback rank.
  120092. */
  120093. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120094. /**
  120095. * Add the required uniforms to the current list.
  120096. * @param uniforms defines the current uniform list.
  120097. */
  120098. static AddUniforms(uniforms: string[]): void;
  120099. /**
  120100. * Add the required uniforms to the current buffer.
  120101. * @param uniformBuffer defines the current uniform buffer.
  120102. */
  120103. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120104. /**
  120105. * Add the required samplers to the current list.
  120106. * @param samplers defines the current sampler list.
  120107. */
  120108. static AddSamplers(samplers: string[]): void;
  120109. /**
  120110. * Makes a duplicate of the current configuration into another one.
  120111. * @param sheenConfiguration define the config where to copy the info
  120112. */
  120113. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  120114. /**
  120115. * Serializes this BRDF configuration.
  120116. * @returns - An object with the serialized config.
  120117. */
  120118. serialize(): any;
  120119. /**
  120120. * Parses a anisotropy Configuration from a serialized object.
  120121. * @param source - Serialized object.
  120122. * @param scene Defines the scene we are parsing for
  120123. * @param rootUrl Defines the rootUrl to load from
  120124. */
  120125. parse(source: any, scene: Scene, rootUrl: string): void;
  120126. }
  120127. }
  120128. declare module BABYLON {
  120129. /**
  120130. * @hidden
  120131. */
  120132. export interface IMaterialSubSurfaceDefines {
  120133. SUBSURFACE: boolean;
  120134. SS_REFRACTION: boolean;
  120135. SS_TRANSLUCENCY: boolean;
  120136. SS_SCATERRING: boolean;
  120137. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120138. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120139. SS_REFRACTIONMAP_3D: boolean;
  120140. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120141. SS_LODINREFRACTIONALPHA: boolean;
  120142. SS_GAMMAREFRACTION: boolean;
  120143. SS_RGBDREFRACTION: boolean;
  120144. SS_LINEARSPECULARREFRACTION: boolean;
  120145. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120146. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120147. /** @hidden */
  120148. _areTexturesDirty: boolean;
  120149. }
  120150. /**
  120151. * Define the code related to the sub surface parameters of the pbr material.
  120152. */
  120153. export class PBRSubSurfaceConfiguration {
  120154. private _isRefractionEnabled;
  120155. /**
  120156. * Defines if the refraction is enabled in the material.
  120157. */
  120158. isRefractionEnabled: boolean;
  120159. private _isTranslucencyEnabled;
  120160. /**
  120161. * Defines if the translucency is enabled in the material.
  120162. */
  120163. isTranslucencyEnabled: boolean;
  120164. private _isScatteringEnabled;
  120165. /**
  120166. * Defines the refraction intensity of the material.
  120167. * The refraction when enabled replaces the Diffuse part of the material.
  120168. * The intensity helps transitionning between diffuse and refraction.
  120169. */
  120170. refractionIntensity: number;
  120171. /**
  120172. * Defines the translucency intensity of the material.
  120173. * When translucency has been enabled, this defines how much of the "translucency"
  120174. * is addded to the diffuse part of the material.
  120175. */
  120176. translucencyIntensity: number;
  120177. /**
  120178. * Defines the scattering intensity of the material.
  120179. * When scattering has been enabled, this defines how much of the "scattered light"
  120180. * is addded to the diffuse part of the material.
  120181. */
  120182. scatteringIntensity: number;
  120183. private _thicknessTexture;
  120184. /**
  120185. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  120186. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  120187. * 0 would mean minimumThickness
  120188. * 1 would mean maximumThickness
  120189. * The other channels might be use as a mask to vary the different effects intensity.
  120190. */
  120191. thicknessTexture: Nullable<BaseTexture>;
  120192. private _refractionTexture;
  120193. /**
  120194. * Defines the texture to use for refraction.
  120195. */
  120196. refractionTexture: Nullable<BaseTexture>;
  120197. private _indexOfRefraction;
  120198. /**
  120199. * Defines the index of refraction used in the material.
  120200. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  120201. */
  120202. indexOfRefraction: number;
  120203. private _invertRefractionY;
  120204. /**
  120205. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120206. */
  120207. invertRefractionY: boolean;
  120208. private _linkRefractionWithTransparency;
  120209. /**
  120210. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120211. * Materials half opaque for instance using refraction could benefit from this control.
  120212. */
  120213. linkRefractionWithTransparency: boolean;
  120214. /**
  120215. * Defines the minimum thickness stored in the thickness map.
  120216. * If no thickness map is defined, this value will be used to simulate thickness.
  120217. */
  120218. minimumThickness: number;
  120219. /**
  120220. * Defines the maximum thickness stored in the thickness map.
  120221. */
  120222. maximumThickness: number;
  120223. /**
  120224. * Defines the volume tint of the material.
  120225. * This is used for both translucency and scattering.
  120226. */
  120227. tintColor: Color3;
  120228. /**
  120229. * Defines the distance at which the tint color should be found in the media.
  120230. * This is used for refraction only.
  120231. */
  120232. tintColorAtDistance: number;
  120233. /**
  120234. * Defines how far each channel transmit through the media.
  120235. * It is defined as a color to simplify it selection.
  120236. */
  120237. diffusionDistance: Color3;
  120238. private _useMaskFromThicknessTexture;
  120239. /**
  120240. * Stores the intensity of the different subsurface effects in the thickness texture.
  120241. * * the green channel is the translucency intensity.
  120242. * * the blue channel is the scattering intensity.
  120243. * * the alpha channel is the refraction intensity.
  120244. */
  120245. useMaskFromThicknessTexture: boolean;
  120246. /** @hidden */
  120247. private _internalMarkAllSubMeshesAsTexturesDirty;
  120248. /** @hidden */
  120249. _markAllSubMeshesAsTexturesDirty(): void;
  120250. /**
  120251. * Instantiate a new istance of sub surface configuration.
  120252. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120253. */
  120254. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120255. /**
  120256. * Gets wehter the submesh is ready to be used or not.
  120257. * @param defines the list of "defines" to update.
  120258. * @param scene defines the scene the material belongs to.
  120259. * @returns - boolean indicating that the submesh is ready or not.
  120260. */
  120261. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120262. /**
  120263. * Checks to see if a texture is used in the material.
  120264. * @param defines the list of "defines" to update.
  120265. * @param scene defines the scene to the material belongs to.
  120266. */
  120267. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120268. /**
  120269. * Binds the material data.
  120270. * @param uniformBuffer defines the Uniform buffer to fill in.
  120271. * @param scene defines the scene the material belongs to.
  120272. * @param engine defines the engine the material belongs to.
  120273. * @param isFrozen defines wether the material is frozen or not.
  120274. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120275. */
  120276. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120277. /**
  120278. * Unbinds the material from the mesh.
  120279. * @param activeEffect defines the effect that should be unbound from.
  120280. * @returns true if unbound, otherwise false
  120281. */
  120282. unbind(activeEffect: Effect): boolean;
  120283. /**
  120284. * Returns the texture used for refraction or null if none is used.
  120285. * @param scene defines the scene the material belongs to.
  120286. * @returns - Refraction texture if present. If no refraction texture and refraction
  120287. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120288. */
  120289. private _getRefractionTexture;
  120290. /**
  120291. * Returns true if alpha blending should be disabled.
  120292. */
  120293. get disableAlphaBlending(): boolean;
  120294. /**
  120295. * Fills the list of render target textures.
  120296. * @param renderTargets the list of render targets to update
  120297. */
  120298. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120299. /**
  120300. * Checks to see if a texture is used in the material.
  120301. * @param texture - Base texture to use.
  120302. * @returns - Boolean specifying if a texture is used in the material.
  120303. */
  120304. hasTexture(texture: BaseTexture): boolean;
  120305. /**
  120306. * Gets a boolean indicating that current material needs to register RTT
  120307. * @returns true if this uses a render target otherwise false.
  120308. */
  120309. hasRenderTargetTextures(): boolean;
  120310. /**
  120311. * Returns an array of the actively used textures.
  120312. * @param activeTextures Array of BaseTextures
  120313. */
  120314. getActiveTextures(activeTextures: BaseTexture[]): void;
  120315. /**
  120316. * Returns the animatable textures.
  120317. * @param animatables Array of animatable textures.
  120318. */
  120319. getAnimatables(animatables: IAnimatable[]): void;
  120320. /**
  120321. * Disposes the resources of the material.
  120322. * @param forceDisposeTextures - Forces the disposal of all textures.
  120323. */
  120324. dispose(forceDisposeTextures?: boolean): void;
  120325. /**
  120326. * Get the current class name of the texture useful for serialization or dynamic coding.
  120327. * @returns "PBRSubSurfaceConfiguration"
  120328. */
  120329. getClassName(): string;
  120330. /**
  120331. * Add fallbacks to the effect fallbacks list.
  120332. * @param defines defines the Base texture to use.
  120333. * @param fallbacks defines the current fallback list.
  120334. * @param currentRank defines the current fallback rank.
  120335. * @returns the new fallback rank.
  120336. */
  120337. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120338. /**
  120339. * Add the required uniforms to the current list.
  120340. * @param uniforms defines the current uniform list.
  120341. */
  120342. static AddUniforms(uniforms: string[]): void;
  120343. /**
  120344. * Add the required samplers to the current list.
  120345. * @param samplers defines the current sampler list.
  120346. */
  120347. static AddSamplers(samplers: string[]): void;
  120348. /**
  120349. * Add the required uniforms to the current buffer.
  120350. * @param uniformBuffer defines the current uniform buffer.
  120351. */
  120352. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120353. /**
  120354. * Makes a duplicate of the current configuration into another one.
  120355. * @param configuration define the config where to copy the info
  120356. */
  120357. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120358. /**
  120359. * Serializes this Sub Surface configuration.
  120360. * @returns - An object with the serialized config.
  120361. */
  120362. serialize(): any;
  120363. /**
  120364. * Parses a anisotropy Configuration from a serialized object.
  120365. * @param source - Serialized object.
  120366. * @param scene Defines the scene we are parsing for
  120367. * @param rootUrl Defines the rootUrl to load from
  120368. */
  120369. parse(source: any, scene: Scene, rootUrl: string): void;
  120370. }
  120371. }
  120372. declare module BABYLON {
  120373. /** @hidden */
  120374. export var pbrFragmentDeclaration: {
  120375. name: string;
  120376. shader: string;
  120377. };
  120378. }
  120379. declare module BABYLON {
  120380. /** @hidden */
  120381. export var pbrUboDeclaration: {
  120382. name: string;
  120383. shader: string;
  120384. };
  120385. }
  120386. declare module BABYLON {
  120387. /** @hidden */
  120388. export var pbrFragmentExtraDeclaration: {
  120389. name: string;
  120390. shader: string;
  120391. };
  120392. }
  120393. declare module BABYLON {
  120394. /** @hidden */
  120395. export var pbrFragmentSamplersDeclaration: {
  120396. name: string;
  120397. shader: string;
  120398. };
  120399. }
  120400. declare module BABYLON {
  120401. /** @hidden */
  120402. export var pbrHelperFunctions: {
  120403. name: string;
  120404. shader: string;
  120405. };
  120406. }
  120407. declare module BABYLON {
  120408. /** @hidden */
  120409. export var harmonicsFunctions: {
  120410. name: string;
  120411. shader: string;
  120412. };
  120413. }
  120414. declare module BABYLON {
  120415. /** @hidden */
  120416. export var pbrDirectLightingSetupFunctions: {
  120417. name: string;
  120418. shader: string;
  120419. };
  120420. }
  120421. declare module BABYLON {
  120422. /** @hidden */
  120423. export var pbrDirectLightingFalloffFunctions: {
  120424. name: string;
  120425. shader: string;
  120426. };
  120427. }
  120428. declare module BABYLON {
  120429. /** @hidden */
  120430. export var pbrBRDFFunctions: {
  120431. name: string;
  120432. shader: string;
  120433. };
  120434. }
  120435. declare module BABYLON {
  120436. /** @hidden */
  120437. export var pbrDirectLightingFunctions: {
  120438. name: string;
  120439. shader: string;
  120440. };
  120441. }
  120442. declare module BABYLON {
  120443. /** @hidden */
  120444. export var pbrIBLFunctions: {
  120445. name: string;
  120446. shader: string;
  120447. };
  120448. }
  120449. declare module BABYLON {
  120450. /** @hidden */
  120451. export var pbrDebug: {
  120452. name: string;
  120453. shader: string;
  120454. };
  120455. }
  120456. declare module BABYLON {
  120457. /** @hidden */
  120458. export var pbrPixelShader: {
  120459. name: string;
  120460. shader: string;
  120461. };
  120462. }
  120463. declare module BABYLON {
  120464. /** @hidden */
  120465. export var pbrVertexDeclaration: {
  120466. name: string;
  120467. shader: string;
  120468. };
  120469. }
  120470. declare module BABYLON {
  120471. /** @hidden */
  120472. export var pbrVertexShader: {
  120473. name: string;
  120474. shader: string;
  120475. };
  120476. }
  120477. declare module BABYLON {
  120478. /**
  120479. * Manages the defines for the PBR Material.
  120480. * @hidden
  120481. */
  120482. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120483. PBR: boolean;
  120484. MAINUV1: boolean;
  120485. MAINUV2: boolean;
  120486. UV1: boolean;
  120487. UV2: boolean;
  120488. ALBEDO: boolean;
  120489. ALBEDODIRECTUV: number;
  120490. VERTEXCOLOR: boolean;
  120491. AMBIENT: boolean;
  120492. AMBIENTDIRECTUV: number;
  120493. AMBIENTINGRAYSCALE: boolean;
  120494. OPACITY: boolean;
  120495. VERTEXALPHA: boolean;
  120496. OPACITYDIRECTUV: number;
  120497. OPACITYRGB: boolean;
  120498. ALPHATEST: boolean;
  120499. DEPTHPREPASS: boolean;
  120500. ALPHABLEND: boolean;
  120501. ALPHAFROMALBEDO: boolean;
  120502. ALPHATESTVALUE: string;
  120503. SPECULAROVERALPHA: boolean;
  120504. RADIANCEOVERALPHA: boolean;
  120505. ALPHAFRESNEL: boolean;
  120506. LINEARALPHAFRESNEL: boolean;
  120507. PREMULTIPLYALPHA: boolean;
  120508. EMISSIVE: boolean;
  120509. EMISSIVEDIRECTUV: number;
  120510. REFLECTIVITY: boolean;
  120511. REFLECTIVITYDIRECTUV: number;
  120512. SPECULARTERM: boolean;
  120513. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120514. MICROSURFACEAUTOMATIC: boolean;
  120515. LODBASEDMICROSFURACE: boolean;
  120516. MICROSURFACEMAP: boolean;
  120517. MICROSURFACEMAPDIRECTUV: number;
  120518. METALLICWORKFLOW: boolean;
  120519. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120520. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120521. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120522. AOSTOREINMETALMAPRED: boolean;
  120523. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120524. ENVIRONMENTBRDF: boolean;
  120525. ENVIRONMENTBRDF_RGBD: boolean;
  120526. NORMAL: boolean;
  120527. TANGENT: boolean;
  120528. BUMP: boolean;
  120529. BUMPDIRECTUV: number;
  120530. OBJECTSPACE_NORMALMAP: boolean;
  120531. PARALLAX: boolean;
  120532. PARALLAXOCCLUSION: boolean;
  120533. NORMALXYSCALE: boolean;
  120534. LIGHTMAP: boolean;
  120535. LIGHTMAPDIRECTUV: number;
  120536. USELIGHTMAPASSHADOWMAP: boolean;
  120537. GAMMALIGHTMAP: boolean;
  120538. RGBDLIGHTMAP: boolean;
  120539. REFLECTION: boolean;
  120540. REFLECTIONMAP_3D: boolean;
  120541. REFLECTIONMAP_SPHERICAL: boolean;
  120542. REFLECTIONMAP_PLANAR: boolean;
  120543. REFLECTIONMAP_CUBIC: boolean;
  120544. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120545. REFLECTIONMAP_PROJECTION: boolean;
  120546. REFLECTIONMAP_SKYBOX: boolean;
  120547. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120548. REFLECTIONMAP_EXPLICIT: boolean;
  120549. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120550. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120551. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120552. INVERTCUBICMAP: boolean;
  120553. USESPHERICALFROMREFLECTIONMAP: boolean;
  120554. USEIRRADIANCEMAP: boolean;
  120555. SPHERICAL_HARMONICS: boolean;
  120556. USESPHERICALINVERTEX: boolean;
  120557. REFLECTIONMAP_OPPOSITEZ: boolean;
  120558. LODINREFLECTIONALPHA: boolean;
  120559. GAMMAREFLECTION: boolean;
  120560. RGBDREFLECTION: boolean;
  120561. LINEARSPECULARREFLECTION: boolean;
  120562. RADIANCEOCCLUSION: boolean;
  120563. HORIZONOCCLUSION: boolean;
  120564. INSTANCES: boolean;
  120565. NUM_BONE_INFLUENCERS: number;
  120566. BonesPerMesh: number;
  120567. BONETEXTURE: boolean;
  120568. NONUNIFORMSCALING: boolean;
  120569. MORPHTARGETS: boolean;
  120570. MORPHTARGETS_NORMAL: boolean;
  120571. MORPHTARGETS_TANGENT: boolean;
  120572. MORPHTARGETS_UV: boolean;
  120573. NUM_MORPH_INFLUENCERS: number;
  120574. IMAGEPROCESSING: boolean;
  120575. VIGNETTE: boolean;
  120576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120577. VIGNETTEBLENDMODEOPAQUE: boolean;
  120578. TONEMAPPING: boolean;
  120579. TONEMAPPING_ACES: boolean;
  120580. CONTRAST: boolean;
  120581. COLORCURVES: boolean;
  120582. COLORGRADING: boolean;
  120583. COLORGRADING3D: boolean;
  120584. SAMPLER3DGREENDEPTH: boolean;
  120585. SAMPLER3DBGRMAP: boolean;
  120586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120587. EXPOSURE: boolean;
  120588. MULTIVIEW: boolean;
  120589. USEPHYSICALLIGHTFALLOFF: boolean;
  120590. USEGLTFLIGHTFALLOFF: boolean;
  120591. TWOSIDEDLIGHTING: boolean;
  120592. SHADOWFLOAT: boolean;
  120593. CLIPPLANE: boolean;
  120594. CLIPPLANE2: boolean;
  120595. CLIPPLANE3: boolean;
  120596. CLIPPLANE4: boolean;
  120597. CLIPPLANE5: boolean;
  120598. CLIPPLANE6: boolean;
  120599. POINTSIZE: boolean;
  120600. FOG: boolean;
  120601. LOGARITHMICDEPTH: boolean;
  120602. FORCENORMALFORWARD: boolean;
  120603. SPECULARAA: boolean;
  120604. CLEARCOAT: boolean;
  120605. CLEARCOAT_DEFAULTIOR: boolean;
  120606. CLEARCOAT_TEXTURE: boolean;
  120607. CLEARCOAT_TEXTUREDIRECTUV: number;
  120608. CLEARCOAT_BUMP: boolean;
  120609. CLEARCOAT_BUMPDIRECTUV: number;
  120610. CLEARCOAT_TINT: boolean;
  120611. CLEARCOAT_TINT_TEXTURE: boolean;
  120612. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120613. ANISOTROPIC: boolean;
  120614. ANISOTROPIC_TEXTURE: boolean;
  120615. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120616. BRDF_V_HEIGHT_CORRELATED: boolean;
  120617. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120618. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120619. SHEEN: boolean;
  120620. SHEEN_TEXTURE: boolean;
  120621. SHEEN_TEXTUREDIRECTUV: number;
  120622. SHEEN_LINKWITHALBEDO: boolean;
  120623. SUBSURFACE: boolean;
  120624. SS_REFRACTION: boolean;
  120625. SS_TRANSLUCENCY: boolean;
  120626. SS_SCATERRING: boolean;
  120627. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120628. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120629. SS_REFRACTIONMAP_3D: boolean;
  120630. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120631. SS_LODINREFRACTIONALPHA: boolean;
  120632. SS_GAMMAREFRACTION: boolean;
  120633. SS_RGBDREFRACTION: boolean;
  120634. SS_LINEARSPECULARREFRACTION: boolean;
  120635. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120636. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120637. UNLIT: boolean;
  120638. DEBUGMODE: number;
  120639. /**
  120640. * Initializes the PBR Material defines.
  120641. */
  120642. constructor();
  120643. /**
  120644. * Resets the PBR Material defines.
  120645. */
  120646. reset(): void;
  120647. }
  120648. /**
  120649. * The Physically based material base class of BJS.
  120650. *
  120651. * This offers the main features of a standard PBR material.
  120652. * For more information, please refer to the documentation :
  120653. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120654. */
  120655. export abstract class PBRBaseMaterial extends PushMaterial {
  120656. /**
  120657. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120658. */
  120659. static readonly PBRMATERIAL_OPAQUE: number;
  120660. /**
  120661. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120662. */
  120663. static readonly PBRMATERIAL_ALPHATEST: number;
  120664. /**
  120665. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120666. */
  120667. static readonly PBRMATERIAL_ALPHABLEND: number;
  120668. /**
  120669. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120670. * They are also discarded below the alpha cutoff threshold to improve performances.
  120671. */
  120672. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120673. /**
  120674. * Defines the default value of how much AO map is occluding the analytical lights
  120675. * (point spot...).
  120676. */
  120677. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120678. /**
  120679. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120680. */
  120681. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120682. /**
  120683. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120684. * to enhance interoperability with other engines.
  120685. */
  120686. static readonly LIGHTFALLOFF_GLTF: number;
  120687. /**
  120688. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120689. * to enhance interoperability with other materials.
  120690. */
  120691. static readonly LIGHTFALLOFF_STANDARD: number;
  120692. /**
  120693. * Intensity of the direct lights e.g. the four lights available in your scene.
  120694. * This impacts both the direct diffuse and specular highlights.
  120695. */
  120696. protected _directIntensity: number;
  120697. /**
  120698. * Intensity of the emissive part of the material.
  120699. * This helps controlling the emissive effect without modifying the emissive color.
  120700. */
  120701. protected _emissiveIntensity: number;
  120702. /**
  120703. * Intensity of the environment e.g. how much the environment will light the object
  120704. * either through harmonics for rough material or through the refelction for shiny ones.
  120705. */
  120706. protected _environmentIntensity: number;
  120707. /**
  120708. * This is a special control allowing the reduction of the specular highlights coming from the
  120709. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120710. */
  120711. protected _specularIntensity: number;
  120712. /**
  120713. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120714. */
  120715. private _lightingInfos;
  120716. /**
  120717. * Debug Control allowing disabling the bump map on this material.
  120718. */
  120719. protected _disableBumpMap: boolean;
  120720. /**
  120721. * AKA Diffuse Texture in standard nomenclature.
  120722. */
  120723. protected _albedoTexture: Nullable<BaseTexture>;
  120724. /**
  120725. * AKA Occlusion Texture in other nomenclature.
  120726. */
  120727. protected _ambientTexture: Nullable<BaseTexture>;
  120728. /**
  120729. * AKA Occlusion Texture Intensity in other nomenclature.
  120730. */
  120731. protected _ambientTextureStrength: number;
  120732. /**
  120733. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120734. * 1 means it completely occludes it
  120735. * 0 mean it has no impact
  120736. */
  120737. protected _ambientTextureImpactOnAnalyticalLights: number;
  120738. /**
  120739. * Stores the alpha values in a texture.
  120740. */
  120741. protected _opacityTexture: Nullable<BaseTexture>;
  120742. /**
  120743. * Stores the reflection values in a texture.
  120744. */
  120745. protected _reflectionTexture: Nullable<BaseTexture>;
  120746. /**
  120747. * Stores the emissive values in a texture.
  120748. */
  120749. protected _emissiveTexture: Nullable<BaseTexture>;
  120750. /**
  120751. * AKA Specular texture in other nomenclature.
  120752. */
  120753. protected _reflectivityTexture: Nullable<BaseTexture>;
  120754. /**
  120755. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120756. */
  120757. protected _metallicTexture: Nullable<BaseTexture>;
  120758. /**
  120759. * Specifies the metallic scalar of the metallic/roughness workflow.
  120760. * Can also be used to scale the metalness values of the metallic texture.
  120761. */
  120762. protected _metallic: Nullable<number>;
  120763. /**
  120764. * Specifies the roughness scalar of the metallic/roughness workflow.
  120765. * Can also be used to scale the roughness values of the metallic texture.
  120766. */
  120767. protected _roughness: Nullable<number>;
  120768. /**
  120769. * Specifies the an F0 factor to help configuring the material F0.
  120770. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120771. * to 0.5 the previously hard coded value stays the same.
  120772. * Can also be used to scale the F0 values of the metallic texture.
  120773. */
  120774. protected _metallicF0Factor: number;
  120775. /**
  120776. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120777. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120778. * your expectation as it multiplies with the texture data.
  120779. */
  120780. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120781. /**
  120782. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120783. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120784. */
  120785. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120786. /**
  120787. * Stores surface normal data used to displace a mesh in a texture.
  120788. */
  120789. protected _bumpTexture: Nullable<BaseTexture>;
  120790. /**
  120791. * Stores the pre-calculated light information of a mesh in a texture.
  120792. */
  120793. protected _lightmapTexture: Nullable<BaseTexture>;
  120794. /**
  120795. * The color of a material in ambient lighting.
  120796. */
  120797. protected _ambientColor: Color3;
  120798. /**
  120799. * AKA Diffuse Color in other nomenclature.
  120800. */
  120801. protected _albedoColor: Color3;
  120802. /**
  120803. * AKA Specular Color in other nomenclature.
  120804. */
  120805. protected _reflectivityColor: Color3;
  120806. /**
  120807. * The color applied when light is reflected from a material.
  120808. */
  120809. protected _reflectionColor: Color3;
  120810. /**
  120811. * The color applied when light is emitted from a material.
  120812. */
  120813. protected _emissiveColor: Color3;
  120814. /**
  120815. * AKA Glossiness in other nomenclature.
  120816. */
  120817. protected _microSurface: number;
  120818. /**
  120819. * Specifies that the material will use the light map as a show map.
  120820. */
  120821. protected _useLightmapAsShadowmap: boolean;
  120822. /**
  120823. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120824. * makes the reflect vector face the model (under horizon).
  120825. */
  120826. protected _useHorizonOcclusion: boolean;
  120827. /**
  120828. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120829. * too much the area relying on ambient texture to define their ambient occlusion.
  120830. */
  120831. protected _useRadianceOcclusion: boolean;
  120832. /**
  120833. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120834. */
  120835. protected _useAlphaFromAlbedoTexture: boolean;
  120836. /**
  120837. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120838. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120839. */
  120840. protected _useSpecularOverAlpha: boolean;
  120841. /**
  120842. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120843. */
  120844. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120845. /**
  120846. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120847. */
  120848. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120849. /**
  120850. * Specifies if the metallic texture contains the roughness information in its green channel.
  120851. */
  120852. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120853. /**
  120854. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120855. */
  120856. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120857. /**
  120858. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120859. */
  120860. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120861. /**
  120862. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120863. */
  120864. protected _useAmbientInGrayScale: boolean;
  120865. /**
  120866. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120867. * The material will try to infer what glossiness each pixel should be.
  120868. */
  120869. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120870. /**
  120871. * Defines the falloff type used in this material.
  120872. * It by default is Physical.
  120873. */
  120874. protected _lightFalloff: number;
  120875. /**
  120876. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120877. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120878. */
  120879. protected _useRadianceOverAlpha: boolean;
  120880. /**
  120881. * Allows using an object space normal map (instead of tangent space).
  120882. */
  120883. protected _useObjectSpaceNormalMap: boolean;
  120884. /**
  120885. * Allows using the bump map in parallax mode.
  120886. */
  120887. protected _useParallax: boolean;
  120888. /**
  120889. * Allows using the bump map in parallax occlusion mode.
  120890. */
  120891. protected _useParallaxOcclusion: boolean;
  120892. /**
  120893. * Controls the scale bias of the parallax mode.
  120894. */
  120895. protected _parallaxScaleBias: number;
  120896. /**
  120897. * If sets to true, disables all the lights affecting the material.
  120898. */
  120899. protected _disableLighting: boolean;
  120900. /**
  120901. * Number of Simultaneous lights allowed on the material.
  120902. */
  120903. protected _maxSimultaneousLights: number;
  120904. /**
  120905. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120906. */
  120907. protected _invertNormalMapX: boolean;
  120908. /**
  120909. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120910. */
  120911. protected _invertNormalMapY: boolean;
  120912. /**
  120913. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120914. */
  120915. protected _twoSidedLighting: boolean;
  120916. /**
  120917. * Defines the alpha limits in alpha test mode.
  120918. */
  120919. protected _alphaCutOff: number;
  120920. /**
  120921. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120922. */
  120923. protected _forceAlphaTest: boolean;
  120924. /**
  120925. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120926. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120927. */
  120928. protected _useAlphaFresnel: boolean;
  120929. /**
  120930. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120931. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120932. */
  120933. protected _useLinearAlphaFresnel: boolean;
  120934. /**
  120935. * The transparency mode of the material.
  120936. */
  120937. protected _transparencyMode: Nullable<number>;
  120938. /**
  120939. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120940. * from cos thetav and roughness:
  120941. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120942. */
  120943. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120944. /**
  120945. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120946. */
  120947. protected _forceIrradianceInFragment: boolean;
  120948. /**
  120949. * Force normal to face away from face.
  120950. */
  120951. protected _forceNormalForward: boolean;
  120952. /**
  120953. * Enables specular anti aliasing in the PBR shader.
  120954. * It will both interacts on the Geometry for analytical and IBL lighting.
  120955. * It also prefilter the roughness map based on the bump values.
  120956. */
  120957. protected _enableSpecularAntiAliasing: boolean;
  120958. /**
  120959. * Default configuration related to image processing available in the PBR Material.
  120960. */
  120961. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120962. /**
  120963. * Keep track of the image processing observer to allow dispose and replace.
  120964. */
  120965. private _imageProcessingObserver;
  120966. /**
  120967. * Attaches a new image processing configuration to the PBR Material.
  120968. * @param configuration
  120969. */
  120970. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120971. /**
  120972. * Stores the available render targets.
  120973. */
  120974. private _renderTargets;
  120975. /**
  120976. * Sets the global ambient color for the material used in lighting calculations.
  120977. */
  120978. private _globalAmbientColor;
  120979. /**
  120980. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120981. */
  120982. private _useLogarithmicDepth;
  120983. /**
  120984. * If set to true, no lighting calculations will be applied.
  120985. */
  120986. private _unlit;
  120987. private _debugMode;
  120988. /**
  120989. * @hidden
  120990. * This is reserved for the inspector.
  120991. * Defines the material debug mode.
  120992. * It helps seeing only some components of the material while troubleshooting.
  120993. */
  120994. debugMode: number;
  120995. /**
  120996. * @hidden
  120997. * This is reserved for the inspector.
  120998. * Specify from where on screen the debug mode should start.
  120999. * The value goes from -1 (full screen) to 1 (not visible)
  121000. * It helps with side by side comparison against the final render
  121001. * This defaults to -1
  121002. */
  121003. private debugLimit;
  121004. /**
  121005. * @hidden
  121006. * This is reserved for the inspector.
  121007. * As the default viewing range might not be enough (if the ambient is really small for instance)
  121008. * You can use the factor to better multiply the final value.
  121009. */
  121010. private debugFactor;
  121011. /**
  121012. * Defines the clear coat layer parameters for the material.
  121013. */
  121014. readonly clearCoat: PBRClearCoatConfiguration;
  121015. /**
  121016. * Defines the anisotropic parameters for the material.
  121017. */
  121018. readonly anisotropy: PBRAnisotropicConfiguration;
  121019. /**
  121020. * Defines the BRDF parameters for the material.
  121021. */
  121022. readonly brdf: PBRBRDFConfiguration;
  121023. /**
  121024. * Defines the Sheen parameters for the material.
  121025. */
  121026. readonly sheen: PBRSheenConfiguration;
  121027. /**
  121028. * Defines the SubSurface parameters for the material.
  121029. */
  121030. readonly subSurface: PBRSubSurfaceConfiguration;
  121031. /**
  121032. * Custom callback helping to override the default shader used in the material.
  121033. */
  121034. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  121035. protected _rebuildInParallel: boolean;
  121036. /**
  121037. * Instantiates a new PBRMaterial instance.
  121038. *
  121039. * @param name The material name
  121040. * @param scene The scene the material will be use in.
  121041. */
  121042. constructor(name: string, scene: Scene);
  121043. /**
  121044. * Gets a boolean indicating that current material needs to register RTT
  121045. */
  121046. get hasRenderTargetTextures(): boolean;
  121047. /**
  121048. * Gets the name of the material class.
  121049. */
  121050. getClassName(): string;
  121051. /**
  121052. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  121053. */
  121054. get useLogarithmicDepth(): boolean;
  121055. /**
  121056. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  121057. */
  121058. set useLogarithmicDepth(value: boolean);
  121059. /**
  121060. * Gets the current transparency mode.
  121061. */
  121062. get transparencyMode(): Nullable<number>;
  121063. /**
  121064. * Sets the transparency mode of the material.
  121065. *
  121066. * | Value | Type | Description |
  121067. * | ----- | ----------------------------------- | ----------- |
  121068. * | 0 | OPAQUE | |
  121069. * | 1 | ALPHATEST | |
  121070. * | 2 | ALPHABLEND | |
  121071. * | 3 | ALPHATESTANDBLEND | |
  121072. *
  121073. */
  121074. set transparencyMode(value: Nullable<number>);
  121075. /**
  121076. * Returns true if alpha blending should be disabled.
  121077. */
  121078. private get _disableAlphaBlending();
  121079. /**
  121080. * Specifies whether or not this material should be rendered in alpha blend mode.
  121081. */
  121082. needAlphaBlending(): boolean;
  121083. /**
  121084. * Specifies if the mesh will require alpha blending.
  121085. * @param mesh - BJS mesh.
  121086. */
  121087. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  121088. /**
  121089. * Specifies whether or not this material should be rendered in alpha test mode.
  121090. */
  121091. needAlphaTesting(): boolean;
  121092. /**
  121093. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  121094. */
  121095. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  121096. /**
  121097. * Gets the texture used for the alpha test.
  121098. */
  121099. getAlphaTestTexture(): Nullable<BaseTexture>;
  121100. /**
  121101. * Specifies that the submesh is ready to be used.
  121102. * @param mesh - BJS mesh.
  121103. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  121104. * @param useInstances - Specifies that instances should be used.
  121105. * @returns - boolean indicating that the submesh is ready or not.
  121106. */
  121107. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121108. /**
  121109. * Specifies if the material uses metallic roughness workflow.
  121110. * @returns boolean specifiying if the material uses metallic roughness workflow.
  121111. */
  121112. isMetallicWorkflow(): boolean;
  121113. private _prepareEffect;
  121114. private _prepareDefines;
  121115. /**
  121116. * Force shader compilation
  121117. */
  121118. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  121119. /**
  121120. * Initializes the uniform buffer layout for the shader.
  121121. */
  121122. buildUniformLayout(): void;
  121123. /**
  121124. * Unbinds the material from the mesh
  121125. */
  121126. unbind(): void;
  121127. /**
  121128. * Binds the submesh data.
  121129. * @param world - The world matrix.
  121130. * @param mesh - The BJS mesh.
  121131. * @param subMesh - A submesh of the BJS mesh.
  121132. */
  121133. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121134. /**
  121135. * Returns the animatable textures.
  121136. * @returns - Array of animatable textures.
  121137. */
  121138. getAnimatables(): IAnimatable[];
  121139. /**
  121140. * Returns the texture used for reflections.
  121141. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  121142. */
  121143. private _getReflectionTexture;
  121144. /**
  121145. * Returns an array of the actively used textures.
  121146. * @returns - Array of BaseTextures
  121147. */
  121148. getActiveTextures(): BaseTexture[];
  121149. /**
  121150. * Checks to see if a texture is used in the material.
  121151. * @param texture - Base texture to use.
  121152. * @returns - Boolean specifying if a texture is used in the material.
  121153. */
  121154. hasTexture(texture: BaseTexture): boolean;
  121155. /**
  121156. * Disposes the resources of the material.
  121157. * @param forceDisposeEffect - Forces the disposal of effects.
  121158. * @param forceDisposeTextures - Forces the disposal of all textures.
  121159. */
  121160. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  121161. }
  121162. }
  121163. declare module BABYLON {
  121164. /**
  121165. * The Physically based material of BJS.
  121166. *
  121167. * This offers the main features of a standard PBR material.
  121168. * For more information, please refer to the documentation :
  121169. * https://doc.babylonjs.com/how_to/physically_based_rendering
  121170. */
  121171. export class PBRMaterial extends PBRBaseMaterial {
  121172. /**
  121173. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  121174. */
  121175. static readonly PBRMATERIAL_OPAQUE: number;
  121176. /**
  121177. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  121178. */
  121179. static readonly PBRMATERIAL_ALPHATEST: number;
  121180. /**
  121181. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121182. */
  121183. static readonly PBRMATERIAL_ALPHABLEND: number;
  121184. /**
  121185. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121186. * They are also discarded below the alpha cutoff threshold to improve performances.
  121187. */
  121188. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  121189. /**
  121190. * Defines the default value of how much AO map is occluding the analytical lights
  121191. * (point spot...).
  121192. */
  121193. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  121194. /**
  121195. * Intensity of the direct lights e.g. the four lights available in your scene.
  121196. * This impacts both the direct diffuse and specular highlights.
  121197. */
  121198. directIntensity: number;
  121199. /**
  121200. * Intensity of the emissive part of the material.
  121201. * This helps controlling the emissive effect without modifying the emissive color.
  121202. */
  121203. emissiveIntensity: number;
  121204. /**
  121205. * Intensity of the environment e.g. how much the environment will light the object
  121206. * either through harmonics for rough material or through the refelction for shiny ones.
  121207. */
  121208. environmentIntensity: number;
  121209. /**
  121210. * This is a special control allowing the reduction of the specular highlights coming from the
  121211. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  121212. */
  121213. specularIntensity: number;
  121214. /**
  121215. * Debug Control allowing disabling the bump map on this material.
  121216. */
  121217. disableBumpMap: boolean;
  121218. /**
  121219. * AKA Diffuse Texture in standard nomenclature.
  121220. */
  121221. albedoTexture: BaseTexture;
  121222. /**
  121223. * AKA Occlusion Texture in other nomenclature.
  121224. */
  121225. ambientTexture: BaseTexture;
  121226. /**
  121227. * AKA Occlusion Texture Intensity in other nomenclature.
  121228. */
  121229. ambientTextureStrength: number;
  121230. /**
  121231. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121232. * 1 means it completely occludes it
  121233. * 0 mean it has no impact
  121234. */
  121235. ambientTextureImpactOnAnalyticalLights: number;
  121236. /**
  121237. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121238. */
  121239. opacityTexture: BaseTexture;
  121240. /**
  121241. * Stores the reflection values in a texture.
  121242. */
  121243. reflectionTexture: Nullable<BaseTexture>;
  121244. /**
  121245. * Stores the emissive values in a texture.
  121246. */
  121247. emissiveTexture: BaseTexture;
  121248. /**
  121249. * AKA Specular texture in other nomenclature.
  121250. */
  121251. reflectivityTexture: BaseTexture;
  121252. /**
  121253. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121254. */
  121255. metallicTexture: BaseTexture;
  121256. /**
  121257. * Specifies the metallic scalar of the metallic/roughness workflow.
  121258. * Can also be used to scale the metalness values of the metallic texture.
  121259. */
  121260. metallic: Nullable<number>;
  121261. /**
  121262. * Specifies the roughness scalar of the metallic/roughness workflow.
  121263. * Can also be used to scale the roughness values of the metallic texture.
  121264. */
  121265. roughness: Nullable<number>;
  121266. /**
  121267. * Specifies the an F0 factor to help configuring the material F0.
  121268. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121269. * to 0.5 the previously hard coded value stays the same.
  121270. * Can also be used to scale the F0 values of the metallic texture.
  121271. */
  121272. metallicF0Factor: number;
  121273. /**
  121274. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121275. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121276. * your expectation as it multiplies with the texture data.
  121277. */
  121278. useMetallicF0FactorFromMetallicTexture: boolean;
  121279. /**
  121280. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121281. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121282. */
  121283. microSurfaceTexture: BaseTexture;
  121284. /**
  121285. * Stores surface normal data used to displace a mesh in a texture.
  121286. */
  121287. bumpTexture: BaseTexture;
  121288. /**
  121289. * Stores the pre-calculated light information of a mesh in a texture.
  121290. */
  121291. lightmapTexture: BaseTexture;
  121292. /**
  121293. * Stores the refracted light information in a texture.
  121294. */
  121295. get refractionTexture(): Nullable<BaseTexture>;
  121296. set refractionTexture(value: Nullable<BaseTexture>);
  121297. /**
  121298. * The color of a material in ambient lighting.
  121299. */
  121300. ambientColor: Color3;
  121301. /**
  121302. * AKA Diffuse Color in other nomenclature.
  121303. */
  121304. albedoColor: Color3;
  121305. /**
  121306. * AKA Specular Color in other nomenclature.
  121307. */
  121308. reflectivityColor: Color3;
  121309. /**
  121310. * The color reflected from the material.
  121311. */
  121312. reflectionColor: Color3;
  121313. /**
  121314. * The color emitted from the material.
  121315. */
  121316. emissiveColor: Color3;
  121317. /**
  121318. * AKA Glossiness in other nomenclature.
  121319. */
  121320. microSurface: number;
  121321. /**
  121322. * source material index of refraction (IOR)' / 'destination material IOR.
  121323. */
  121324. get indexOfRefraction(): number;
  121325. set indexOfRefraction(value: number);
  121326. /**
  121327. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121328. */
  121329. get invertRefractionY(): boolean;
  121330. set invertRefractionY(value: boolean);
  121331. /**
  121332. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121333. * Materials half opaque for instance using refraction could benefit from this control.
  121334. */
  121335. get linkRefractionWithTransparency(): boolean;
  121336. set linkRefractionWithTransparency(value: boolean);
  121337. /**
  121338. * If true, the light map contains occlusion information instead of lighting info.
  121339. */
  121340. useLightmapAsShadowmap: boolean;
  121341. /**
  121342. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121343. */
  121344. useAlphaFromAlbedoTexture: boolean;
  121345. /**
  121346. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121347. */
  121348. forceAlphaTest: boolean;
  121349. /**
  121350. * Defines the alpha limits in alpha test mode.
  121351. */
  121352. alphaCutOff: number;
  121353. /**
  121354. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121355. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121356. */
  121357. useSpecularOverAlpha: boolean;
  121358. /**
  121359. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121360. */
  121361. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121362. /**
  121363. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121364. */
  121365. useRoughnessFromMetallicTextureAlpha: boolean;
  121366. /**
  121367. * Specifies if the metallic texture contains the roughness information in its green channel.
  121368. */
  121369. useRoughnessFromMetallicTextureGreen: boolean;
  121370. /**
  121371. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121372. */
  121373. useMetallnessFromMetallicTextureBlue: boolean;
  121374. /**
  121375. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121376. */
  121377. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121378. /**
  121379. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121380. */
  121381. useAmbientInGrayScale: boolean;
  121382. /**
  121383. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121384. * The material will try to infer what glossiness each pixel should be.
  121385. */
  121386. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121387. /**
  121388. * BJS is using an harcoded light falloff based on a manually sets up range.
  121389. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121390. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121391. */
  121392. get usePhysicalLightFalloff(): boolean;
  121393. /**
  121394. * BJS is using an harcoded light falloff based on a manually sets up range.
  121395. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121396. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121397. */
  121398. set usePhysicalLightFalloff(value: boolean);
  121399. /**
  121400. * In order to support the falloff compatibility with gltf, a special mode has been added
  121401. * to reproduce the gltf light falloff.
  121402. */
  121403. get useGLTFLightFalloff(): boolean;
  121404. /**
  121405. * In order to support the falloff compatibility with gltf, a special mode has been added
  121406. * to reproduce the gltf light falloff.
  121407. */
  121408. set useGLTFLightFalloff(value: boolean);
  121409. /**
  121410. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121411. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121412. */
  121413. useRadianceOverAlpha: boolean;
  121414. /**
  121415. * Allows using an object space normal map (instead of tangent space).
  121416. */
  121417. useObjectSpaceNormalMap: boolean;
  121418. /**
  121419. * Allows using the bump map in parallax mode.
  121420. */
  121421. useParallax: boolean;
  121422. /**
  121423. * Allows using the bump map in parallax occlusion mode.
  121424. */
  121425. useParallaxOcclusion: boolean;
  121426. /**
  121427. * Controls the scale bias of the parallax mode.
  121428. */
  121429. parallaxScaleBias: number;
  121430. /**
  121431. * If sets to true, disables all the lights affecting the material.
  121432. */
  121433. disableLighting: boolean;
  121434. /**
  121435. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121436. */
  121437. forceIrradianceInFragment: boolean;
  121438. /**
  121439. * Number of Simultaneous lights allowed on the material.
  121440. */
  121441. maxSimultaneousLights: number;
  121442. /**
  121443. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121444. */
  121445. invertNormalMapX: boolean;
  121446. /**
  121447. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121448. */
  121449. invertNormalMapY: boolean;
  121450. /**
  121451. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121452. */
  121453. twoSidedLighting: boolean;
  121454. /**
  121455. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121456. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121457. */
  121458. useAlphaFresnel: boolean;
  121459. /**
  121460. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121461. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121462. */
  121463. useLinearAlphaFresnel: boolean;
  121464. /**
  121465. * Let user defines the brdf lookup texture used for IBL.
  121466. * A default 8bit version is embedded but you could point at :
  121467. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121468. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121469. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121470. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121471. */
  121472. environmentBRDFTexture: Nullable<BaseTexture>;
  121473. /**
  121474. * Force normal to face away from face.
  121475. */
  121476. forceNormalForward: boolean;
  121477. /**
  121478. * Enables specular anti aliasing in the PBR shader.
  121479. * It will both interacts on the Geometry for analytical and IBL lighting.
  121480. * It also prefilter the roughness map based on the bump values.
  121481. */
  121482. enableSpecularAntiAliasing: boolean;
  121483. /**
  121484. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121485. * makes the reflect vector face the model (under horizon).
  121486. */
  121487. useHorizonOcclusion: boolean;
  121488. /**
  121489. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121490. * too much the area relying on ambient texture to define their ambient occlusion.
  121491. */
  121492. useRadianceOcclusion: boolean;
  121493. /**
  121494. * If set to true, no lighting calculations will be applied.
  121495. */
  121496. unlit: boolean;
  121497. /**
  121498. * Gets the image processing configuration used either in this material.
  121499. */
  121500. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121501. /**
  121502. * Sets the Default image processing configuration used either in the this material.
  121503. *
  121504. * If sets to null, the scene one is in use.
  121505. */
  121506. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121507. /**
  121508. * Gets wether the color curves effect is enabled.
  121509. */
  121510. get cameraColorCurvesEnabled(): boolean;
  121511. /**
  121512. * Sets wether the color curves effect is enabled.
  121513. */
  121514. set cameraColorCurvesEnabled(value: boolean);
  121515. /**
  121516. * Gets wether the color grading effect is enabled.
  121517. */
  121518. get cameraColorGradingEnabled(): boolean;
  121519. /**
  121520. * Gets wether the color grading effect is enabled.
  121521. */
  121522. set cameraColorGradingEnabled(value: boolean);
  121523. /**
  121524. * Gets wether tonemapping is enabled or not.
  121525. */
  121526. get cameraToneMappingEnabled(): boolean;
  121527. /**
  121528. * Sets wether tonemapping is enabled or not
  121529. */
  121530. set cameraToneMappingEnabled(value: boolean);
  121531. /**
  121532. * The camera exposure used on this material.
  121533. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121534. * This corresponds to a photographic exposure.
  121535. */
  121536. get cameraExposure(): number;
  121537. /**
  121538. * The camera exposure used on this material.
  121539. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121540. * This corresponds to a photographic exposure.
  121541. */
  121542. set cameraExposure(value: number);
  121543. /**
  121544. * Gets The camera contrast used on this material.
  121545. */
  121546. get cameraContrast(): number;
  121547. /**
  121548. * Sets The camera contrast used on this material.
  121549. */
  121550. set cameraContrast(value: number);
  121551. /**
  121552. * Gets the Color Grading 2D Lookup Texture.
  121553. */
  121554. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121555. /**
  121556. * Sets the Color Grading 2D Lookup Texture.
  121557. */
  121558. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121559. /**
  121560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121562. * 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;
  121563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121564. */
  121565. get cameraColorCurves(): Nullable<ColorCurves>;
  121566. /**
  121567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121569. * 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;
  121570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121571. */
  121572. set cameraColorCurves(value: Nullable<ColorCurves>);
  121573. /**
  121574. * Instantiates a new PBRMaterial instance.
  121575. *
  121576. * @param name The material name
  121577. * @param scene The scene the material will be use in.
  121578. */
  121579. constructor(name: string, scene: Scene);
  121580. /**
  121581. * Returns the name of this material class.
  121582. */
  121583. getClassName(): string;
  121584. /**
  121585. * Makes a duplicate of the current material.
  121586. * @param name - name to use for the new material.
  121587. */
  121588. clone(name: string): PBRMaterial;
  121589. /**
  121590. * Serializes this PBR Material.
  121591. * @returns - An object with the serialized material.
  121592. */
  121593. serialize(): any;
  121594. /**
  121595. * Parses a PBR Material from a serialized object.
  121596. * @param source - Serialized object.
  121597. * @param scene - BJS scene instance.
  121598. * @param rootUrl - url for the scene object
  121599. * @returns - PBRMaterial
  121600. */
  121601. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121602. }
  121603. }
  121604. declare module BABYLON {
  121605. /**
  121606. * Direct draw surface info
  121607. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121608. */
  121609. export interface DDSInfo {
  121610. /**
  121611. * Width of the texture
  121612. */
  121613. width: number;
  121614. /**
  121615. * Width of the texture
  121616. */
  121617. height: number;
  121618. /**
  121619. * Number of Mipmaps for the texture
  121620. * @see https://en.wikipedia.org/wiki/Mipmap
  121621. */
  121622. mipmapCount: number;
  121623. /**
  121624. * If the textures format is a known fourCC format
  121625. * @see https://www.fourcc.org/
  121626. */
  121627. isFourCC: boolean;
  121628. /**
  121629. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121630. */
  121631. isRGB: boolean;
  121632. /**
  121633. * If the texture is a lumincance format
  121634. */
  121635. isLuminance: boolean;
  121636. /**
  121637. * If this is a cube texture
  121638. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121639. */
  121640. isCube: boolean;
  121641. /**
  121642. * If the texture is a compressed format eg. FOURCC_DXT1
  121643. */
  121644. isCompressed: boolean;
  121645. /**
  121646. * The dxgiFormat of the texture
  121647. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121648. */
  121649. dxgiFormat: number;
  121650. /**
  121651. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121652. */
  121653. textureType: number;
  121654. /**
  121655. * Sphericle polynomial created for the dds texture
  121656. */
  121657. sphericalPolynomial?: SphericalPolynomial;
  121658. }
  121659. /**
  121660. * Class used to provide DDS decompression tools
  121661. */
  121662. export class DDSTools {
  121663. /**
  121664. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121665. */
  121666. static StoreLODInAlphaChannel: boolean;
  121667. /**
  121668. * Gets DDS information from an array buffer
  121669. * @param arrayBuffer defines the array buffer to read data from
  121670. * @returns the DDS information
  121671. */
  121672. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121673. private static _FloatView;
  121674. private static _Int32View;
  121675. private static _ToHalfFloat;
  121676. private static _FromHalfFloat;
  121677. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121678. private static _GetHalfFloatRGBAArrayBuffer;
  121679. private static _GetFloatRGBAArrayBuffer;
  121680. private static _GetFloatAsUIntRGBAArrayBuffer;
  121681. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121682. private static _GetRGBAArrayBuffer;
  121683. private static _ExtractLongWordOrder;
  121684. private static _GetRGBArrayBuffer;
  121685. private static _GetLuminanceArrayBuffer;
  121686. /**
  121687. * Uploads DDS Levels to a Babylon Texture
  121688. * @hidden
  121689. */
  121690. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121691. }
  121692. interface ThinEngine {
  121693. /**
  121694. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121695. * @param rootUrl defines the url where the file to load is located
  121696. * @param scene defines the current scene
  121697. * @param lodScale defines scale to apply to the mip map selection
  121698. * @param lodOffset defines offset to apply to the mip map selection
  121699. * @param onLoad defines an optional callback raised when the texture is loaded
  121700. * @param onError defines an optional callback raised if there is an issue to load the texture
  121701. * @param format defines the format of the data
  121702. * @param forcedExtension defines the extension to use to pick the right loader
  121703. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121704. * @returns the cube texture as an InternalTexture
  121705. */
  121706. 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;
  121707. }
  121708. }
  121709. declare module BABYLON {
  121710. /**
  121711. * Implementation of the DDS Texture Loader.
  121712. * @hidden
  121713. */
  121714. export class _DDSTextureLoader implements IInternalTextureLoader {
  121715. /**
  121716. * Defines wether the loader supports cascade loading the different faces.
  121717. */
  121718. readonly supportCascades: boolean;
  121719. /**
  121720. * This returns if the loader support the current file information.
  121721. * @param extension defines the file extension of the file being loaded
  121722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121723. * @param fallback defines the fallback internal texture if any
  121724. * @param isBase64 defines whether the texture is encoded as a base64
  121725. * @param isBuffer defines whether the texture data are stored as a buffer
  121726. * @returns true if the loader can load the specified file
  121727. */
  121728. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121729. /**
  121730. * Transform the url before loading if required.
  121731. * @param rootUrl the url of the texture
  121732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121733. * @returns the transformed texture
  121734. */
  121735. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121736. /**
  121737. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121738. * @param rootUrl the url of the texture
  121739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121740. * @returns the fallback texture
  121741. */
  121742. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121743. /**
  121744. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121745. * @param data contains the texture data
  121746. * @param texture defines the BabylonJS internal texture
  121747. * @param createPolynomials will be true if polynomials have been requested
  121748. * @param onLoad defines the callback to trigger once the texture is ready
  121749. * @param onError defines the callback to trigger in case of error
  121750. */
  121751. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121752. /**
  121753. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121754. * @param data contains the texture data
  121755. * @param texture defines the BabylonJS internal texture
  121756. * @param callback defines the method to call once ready to upload
  121757. */
  121758. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121759. }
  121760. }
  121761. declare module BABYLON {
  121762. /**
  121763. * Implementation of the ENV Texture Loader.
  121764. * @hidden
  121765. */
  121766. export class _ENVTextureLoader implements IInternalTextureLoader {
  121767. /**
  121768. * Defines wether the loader supports cascade loading the different faces.
  121769. */
  121770. readonly supportCascades: boolean;
  121771. /**
  121772. * This returns if the loader support the current file information.
  121773. * @param extension defines the file extension of the file being loaded
  121774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121775. * @param fallback defines the fallback internal texture if any
  121776. * @param isBase64 defines whether the texture is encoded as a base64
  121777. * @param isBuffer defines whether the texture data are stored as a buffer
  121778. * @returns true if the loader can load the specified file
  121779. */
  121780. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121781. /**
  121782. * Transform the url before loading if required.
  121783. * @param rootUrl the url of the texture
  121784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121785. * @returns the transformed texture
  121786. */
  121787. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121788. /**
  121789. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121790. * @param rootUrl the url of the texture
  121791. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121792. * @returns the fallback texture
  121793. */
  121794. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121795. /**
  121796. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121797. * @param data contains the texture data
  121798. * @param texture defines the BabylonJS internal texture
  121799. * @param createPolynomials will be true if polynomials have been requested
  121800. * @param onLoad defines the callback to trigger once the texture is ready
  121801. * @param onError defines the callback to trigger in case of error
  121802. */
  121803. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121804. /**
  121805. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121806. * @param data contains the texture data
  121807. * @param texture defines the BabylonJS internal texture
  121808. * @param callback defines the method to call once ready to upload
  121809. */
  121810. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121811. }
  121812. }
  121813. declare module BABYLON {
  121814. /**
  121815. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121816. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121817. */
  121818. export class KhronosTextureContainer {
  121819. /** contents of the KTX container file */
  121820. arrayBuffer: any;
  121821. private static HEADER_LEN;
  121822. private static COMPRESSED_2D;
  121823. private static COMPRESSED_3D;
  121824. private static TEX_2D;
  121825. private static TEX_3D;
  121826. /**
  121827. * Gets the openGL type
  121828. */
  121829. glType: number;
  121830. /**
  121831. * Gets the openGL type size
  121832. */
  121833. glTypeSize: number;
  121834. /**
  121835. * Gets the openGL format
  121836. */
  121837. glFormat: number;
  121838. /**
  121839. * Gets the openGL internal format
  121840. */
  121841. glInternalFormat: number;
  121842. /**
  121843. * Gets the base internal format
  121844. */
  121845. glBaseInternalFormat: number;
  121846. /**
  121847. * Gets image width in pixel
  121848. */
  121849. pixelWidth: number;
  121850. /**
  121851. * Gets image height in pixel
  121852. */
  121853. pixelHeight: number;
  121854. /**
  121855. * Gets image depth in pixels
  121856. */
  121857. pixelDepth: number;
  121858. /**
  121859. * Gets the number of array elements
  121860. */
  121861. numberOfArrayElements: number;
  121862. /**
  121863. * Gets the number of faces
  121864. */
  121865. numberOfFaces: number;
  121866. /**
  121867. * Gets the number of mipmap levels
  121868. */
  121869. numberOfMipmapLevels: number;
  121870. /**
  121871. * Gets the bytes of key value data
  121872. */
  121873. bytesOfKeyValueData: number;
  121874. /**
  121875. * Gets the load type
  121876. */
  121877. loadType: number;
  121878. /**
  121879. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121880. */
  121881. isInvalid: boolean;
  121882. /**
  121883. * Creates a new KhronosTextureContainer
  121884. * @param arrayBuffer contents of the KTX container file
  121885. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121886. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121887. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121888. */
  121889. constructor(
  121890. /** contents of the KTX container file */
  121891. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121892. /**
  121893. * Uploads KTX content to a Babylon Texture.
  121894. * It is assumed that the texture has already been created & is currently bound
  121895. * @hidden
  121896. */
  121897. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121898. private _upload2DCompressedLevels;
  121899. }
  121900. }
  121901. declare module BABYLON {
  121902. /**
  121903. * Implementation of the KTX Texture Loader.
  121904. * @hidden
  121905. */
  121906. export class _KTXTextureLoader implements IInternalTextureLoader {
  121907. /**
  121908. * Defines wether the loader supports cascade loading the different faces.
  121909. */
  121910. readonly supportCascades: boolean;
  121911. /**
  121912. * This returns if the loader support the current file information.
  121913. * @param extension defines the file extension of the file being loaded
  121914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121915. * @param fallback defines the fallback internal texture if any
  121916. * @param isBase64 defines whether the texture is encoded as a base64
  121917. * @param isBuffer defines whether the texture data are stored as a buffer
  121918. * @returns true if the loader can load the specified file
  121919. */
  121920. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121921. /**
  121922. * Transform the url before loading if required.
  121923. * @param rootUrl the url of the texture
  121924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121925. * @returns the transformed texture
  121926. */
  121927. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121928. /**
  121929. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121930. * @param rootUrl the url of the texture
  121931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121932. * @returns the fallback texture
  121933. */
  121934. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121935. /**
  121936. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121937. * @param data contains the texture data
  121938. * @param texture defines the BabylonJS internal texture
  121939. * @param createPolynomials will be true if polynomials have been requested
  121940. * @param onLoad defines the callback to trigger once the texture is ready
  121941. * @param onError defines the callback to trigger in case of error
  121942. */
  121943. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121944. /**
  121945. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121946. * @param data contains the texture data
  121947. * @param texture defines the BabylonJS internal texture
  121948. * @param callback defines the method to call once ready to upload
  121949. */
  121950. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121951. }
  121952. }
  121953. declare module BABYLON {
  121954. /** @hidden */
  121955. export var _forceSceneHelpersToBundle: boolean;
  121956. interface Scene {
  121957. /**
  121958. * Creates a default light for the scene.
  121959. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121960. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121961. */
  121962. createDefaultLight(replace?: boolean): void;
  121963. /**
  121964. * Creates a default camera for the scene.
  121965. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121966. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121967. * @param replace has default false, when true replaces the active camera in the scene
  121968. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121969. */
  121970. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121971. /**
  121972. * Creates a default camera and a default light.
  121973. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121974. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121975. * @param replace has the default false, when true replaces the active camera/light in the scene
  121976. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121977. */
  121978. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121979. /**
  121980. * Creates a new sky box
  121981. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121982. * @param environmentTexture defines the texture to use as environment texture
  121983. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121984. * @param scale defines the overall scale of the skybox
  121985. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121986. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121987. * @returns a new mesh holding the sky box
  121988. */
  121989. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121990. /**
  121991. * Creates a new environment
  121992. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121993. * @param options defines the options you can use to configure the environment
  121994. * @returns the new EnvironmentHelper
  121995. */
  121996. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121997. /**
  121998. * Creates a new VREXperienceHelper
  121999. * @see http://doc.babylonjs.com/how_to/webvr_helper
  122000. * @param webVROptions defines the options used to create the new VREXperienceHelper
  122001. * @returns a new VREXperienceHelper
  122002. */
  122003. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  122004. /**
  122005. * Creates a new WebXRDefaultExperience
  122006. * @see http://doc.babylonjs.com/how_to/webxr
  122007. * @param options experience options
  122008. * @returns a promise for a new WebXRDefaultExperience
  122009. */
  122010. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. /**
  122015. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  122016. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  122017. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  122018. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122019. */
  122020. export class VideoDome extends TransformNode {
  122021. /**
  122022. * Define the video source as a Monoscopic panoramic 360 video.
  122023. */
  122024. static readonly MODE_MONOSCOPIC: number;
  122025. /**
  122026. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  122027. */
  122028. static readonly MODE_TOPBOTTOM: number;
  122029. /**
  122030. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  122031. */
  122032. static readonly MODE_SIDEBYSIDE: number;
  122033. private _halfDome;
  122034. private _useDirectMapping;
  122035. /**
  122036. * The video texture being displayed on the sphere
  122037. */
  122038. protected _videoTexture: VideoTexture;
  122039. /**
  122040. * Gets the video texture being displayed on the sphere
  122041. */
  122042. get videoTexture(): VideoTexture;
  122043. /**
  122044. * The skybox material
  122045. */
  122046. protected _material: BackgroundMaterial;
  122047. /**
  122048. * The surface used for the skybox
  122049. */
  122050. protected _mesh: Mesh;
  122051. /**
  122052. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  122053. */
  122054. private _halfDomeMask;
  122055. /**
  122056. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122057. * Also see the options.resolution property.
  122058. */
  122059. get fovMultiplier(): number;
  122060. set fovMultiplier(value: number);
  122061. private _videoMode;
  122062. /**
  122063. * Gets or set the current video mode for the video. It can be:
  122064. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  122065. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  122066. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  122067. */
  122068. get videoMode(): number;
  122069. set videoMode(value: number);
  122070. /**
  122071. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  122072. *
  122073. */
  122074. get halfDome(): boolean;
  122075. /**
  122076. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  122077. */
  122078. set halfDome(enabled: boolean);
  122079. /**
  122080. * Oberserver used in Stereoscopic VR Mode.
  122081. */
  122082. private _onBeforeCameraRenderObserver;
  122083. /**
  122084. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  122085. * @param name Element's name, child elements will append suffixes for their own names.
  122086. * @param urlsOrVideo defines the url(s) or the video element to use
  122087. * @param options An object containing optional or exposed sub element properties
  122088. */
  122089. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  122090. resolution?: number;
  122091. clickToPlay?: boolean;
  122092. autoPlay?: boolean;
  122093. loop?: boolean;
  122094. size?: number;
  122095. poster?: string;
  122096. faceForward?: boolean;
  122097. useDirectMapping?: boolean;
  122098. halfDomeMode?: boolean;
  122099. }, scene: Scene);
  122100. private _changeVideoMode;
  122101. /**
  122102. * Releases resources associated with this node.
  122103. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122104. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122105. */
  122106. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122107. }
  122108. }
  122109. declare module BABYLON {
  122110. /**
  122111. * This class can be used to get instrumentation data from a Babylon engine
  122112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122113. */
  122114. export class EngineInstrumentation implements IDisposable {
  122115. /**
  122116. * Define the instrumented engine.
  122117. */
  122118. engine: Engine;
  122119. private _captureGPUFrameTime;
  122120. private _gpuFrameTimeToken;
  122121. private _gpuFrameTime;
  122122. private _captureShaderCompilationTime;
  122123. private _shaderCompilationTime;
  122124. private _onBeginFrameObserver;
  122125. private _onEndFrameObserver;
  122126. private _onBeforeShaderCompilationObserver;
  122127. private _onAfterShaderCompilationObserver;
  122128. /**
  122129. * Gets the perf counter used for GPU frame time
  122130. */
  122131. get gpuFrameTimeCounter(): PerfCounter;
  122132. /**
  122133. * Gets the GPU frame time capture status
  122134. */
  122135. get captureGPUFrameTime(): boolean;
  122136. /**
  122137. * Enable or disable the GPU frame time capture
  122138. */
  122139. set captureGPUFrameTime(value: boolean);
  122140. /**
  122141. * Gets the perf counter used for shader compilation time
  122142. */
  122143. get shaderCompilationTimeCounter(): PerfCounter;
  122144. /**
  122145. * Gets the shader compilation time capture status
  122146. */
  122147. get captureShaderCompilationTime(): boolean;
  122148. /**
  122149. * Enable or disable the shader compilation time capture
  122150. */
  122151. set captureShaderCompilationTime(value: boolean);
  122152. /**
  122153. * Instantiates a new engine instrumentation.
  122154. * This class can be used to get instrumentation data from a Babylon engine
  122155. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122156. * @param engine Defines the engine to instrument
  122157. */
  122158. constructor(
  122159. /**
  122160. * Define the instrumented engine.
  122161. */
  122162. engine: Engine);
  122163. /**
  122164. * Dispose and release associated resources.
  122165. */
  122166. dispose(): void;
  122167. }
  122168. }
  122169. declare module BABYLON {
  122170. /**
  122171. * This class can be used to get instrumentation data from a Babylon engine
  122172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122173. */
  122174. export class SceneInstrumentation implements IDisposable {
  122175. /**
  122176. * Defines the scene to instrument
  122177. */
  122178. scene: Scene;
  122179. private _captureActiveMeshesEvaluationTime;
  122180. private _activeMeshesEvaluationTime;
  122181. private _captureRenderTargetsRenderTime;
  122182. private _renderTargetsRenderTime;
  122183. private _captureFrameTime;
  122184. private _frameTime;
  122185. private _captureRenderTime;
  122186. private _renderTime;
  122187. private _captureInterFrameTime;
  122188. private _interFrameTime;
  122189. private _captureParticlesRenderTime;
  122190. private _particlesRenderTime;
  122191. private _captureSpritesRenderTime;
  122192. private _spritesRenderTime;
  122193. private _capturePhysicsTime;
  122194. private _physicsTime;
  122195. private _captureAnimationsTime;
  122196. private _animationsTime;
  122197. private _captureCameraRenderTime;
  122198. private _cameraRenderTime;
  122199. private _onBeforeActiveMeshesEvaluationObserver;
  122200. private _onAfterActiveMeshesEvaluationObserver;
  122201. private _onBeforeRenderTargetsRenderObserver;
  122202. private _onAfterRenderTargetsRenderObserver;
  122203. private _onAfterRenderObserver;
  122204. private _onBeforeDrawPhaseObserver;
  122205. private _onAfterDrawPhaseObserver;
  122206. private _onBeforeAnimationsObserver;
  122207. private _onBeforeParticlesRenderingObserver;
  122208. private _onAfterParticlesRenderingObserver;
  122209. private _onBeforeSpritesRenderingObserver;
  122210. private _onAfterSpritesRenderingObserver;
  122211. private _onBeforePhysicsObserver;
  122212. private _onAfterPhysicsObserver;
  122213. private _onAfterAnimationsObserver;
  122214. private _onBeforeCameraRenderObserver;
  122215. private _onAfterCameraRenderObserver;
  122216. /**
  122217. * Gets the perf counter used for active meshes evaluation time
  122218. */
  122219. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  122220. /**
  122221. * Gets the active meshes evaluation time capture status
  122222. */
  122223. get captureActiveMeshesEvaluationTime(): boolean;
  122224. /**
  122225. * Enable or disable the active meshes evaluation time capture
  122226. */
  122227. set captureActiveMeshesEvaluationTime(value: boolean);
  122228. /**
  122229. * Gets the perf counter used for render targets render time
  122230. */
  122231. get renderTargetsRenderTimeCounter(): PerfCounter;
  122232. /**
  122233. * Gets the render targets render time capture status
  122234. */
  122235. get captureRenderTargetsRenderTime(): boolean;
  122236. /**
  122237. * Enable or disable the render targets render time capture
  122238. */
  122239. set captureRenderTargetsRenderTime(value: boolean);
  122240. /**
  122241. * Gets the perf counter used for particles render time
  122242. */
  122243. get particlesRenderTimeCounter(): PerfCounter;
  122244. /**
  122245. * Gets the particles render time capture status
  122246. */
  122247. get captureParticlesRenderTime(): boolean;
  122248. /**
  122249. * Enable or disable the particles render time capture
  122250. */
  122251. set captureParticlesRenderTime(value: boolean);
  122252. /**
  122253. * Gets the perf counter used for sprites render time
  122254. */
  122255. get spritesRenderTimeCounter(): PerfCounter;
  122256. /**
  122257. * Gets the sprites render time capture status
  122258. */
  122259. get captureSpritesRenderTime(): boolean;
  122260. /**
  122261. * Enable or disable the sprites render time capture
  122262. */
  122263. set captureSpritesRenderTime(value: boolean);
  122264. /**
  122265. * Gets the perf counter used for physics time
  122266. */
  122267. get physicsTimeCounter(): PerfCounter;
  122268. /**
  122269. * Gets the physics time capture status
  122270. */
  122271. get capturePhysicsTime(): boolean;
  122272. /**
  122273. * Enable or disable the physics time capture
  122274. */
  122275. set capturePhysicsTime(value: boolean);
  122276. /**
  122277. * Gets the perf counter used for animations time
  122278. */
  122279. get animationsTimeCounter(): PerfCounter;
  122280. /**
  122281. * Gets the animations time capture status
  122282. */
  122283. get captureAnimationsTime(): boolean;
  122284. /**
  122285. * Enable or disable the animations time capture
  122286. */
  122287. set captureAnimationsTime(value: boolean);
  122288. /**
  122289. * Gets the perf counter used for frame time capture
  122290. */
  122291. get frameTimeCounter(): PerfCounter;
  122292. /**
  122293. * Gets the frame time capture status
  122294. */
  122295. get captureFrameTime(): boolean;
  122296. /**
  122297. * Enable or disable the frame time capture
  122298. */
  122299. set captureFrameTime(value: boolean);
  122300. /**
  122301. * Gets the perf counter used for inter-frames time capture
  122302. */
  122303. get interFrameTimeCounter(): PerfCounter;
  122304. /**
  122305. * Gets the inter-frames time capture status
  122306. */
  122307. get captureInterFrameTime(): boolean;
  122308. /**
  122309. * Enable or disable the inter-frames time capture
  122310. */
  122311. set captureInterFrameTime(value: boolean);
  122312. /**
  122313. * Gets the perf counter used for render time capture
  122314. */
  122315. get renderTimeCounter(): PerfCounter;
  122316. /**
  122317. * Gets the render time capture status
  122318. */
  122319. get captureRenderTime(): boolean;
  122320. /**
  122321. * Enable or disable the render time capture
  122322. */
  122323. set captureRenderTime(value: boolean);
  122324. /**
  122325. * Gets the perf counter used for camera render time capture
  122326. */
  122327. get cameraRenderTimeCounter(): PerfCounter;
  122328. /**
  122329. * Gets the camera render time capture status
  122330. */
  122331. get captureCameraRenderTime(): boolean;
  122332. /**
  122333. * Enable or disable the camera render time capture
  122334. */
  122335. set captureCameraRenderTime(value: boolean);
  122336. /**
  122337. * Gets the perf counter used for draw calls
  122338. */
  122339. get drawCallsCounter(): PerfCounter;
  122340. /**
  122341. * Instantiates a new scene instrumentation.
  122342. * This class can be used to get instrumentation data from a Babylon engine
  122343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122344. * @param scene Defines the scene to instrument
  122345. */
  122346. constructor(
  122347. /**
  122348. * Defines the scene to instrument
  122349. */
  122350. scene: Scene);
  122351. /**
  122352. * Dispose and release associated resources.
  122353. */
  122354. dispose(): void;
  122355. }
  122356. }
  122357. declare module BABYLON {
  122358. /** @hidden */
  122359. export var glowMapGenerationPixelShader: {
  122360. name: string;
  122361. shader: string;
  122362. };
  122363. }
  122364. declare module BABYLON {
  122365. /** @hidden */
  122366. export var glowMapGenerationVertexShader: {
  122367. name: string;
  122368. shader: string;
  122369. };
  122370. }
  122371. declare module BABYLON {
  122372. /**
  122373. * Effect layer options. This helps customizing the behaviour
  122374. * of the effect layer.
  122375. */
  122376. export interface IEffectLayerOptions {
  122377. /**
  122378. * Multiplication factor apply to the canvas size to compute the render target size
  122379. * used to generated the objects (the smaller the faster).
  122380. */
  122381. mainTextureRatio: number;
  122382. /**
  122383. * Enforces a fixed size texture to ensure effect stability across devices.
  122384. */
  122385. mainTextureFixedSize?: number;
  122386. /**
  122387. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122388. */
  122389. alphaBlendingMode: number;
  122390. /**
  122391. * The camera attached to the layer.
  122392. */
  122393. camera: Nullable<Camera>;
  122394. /**
  122395. * The rendering group to draw the layer in.
  122396. */
  122397. renderingGroupId: number;
  122398. }
  122399. /**
  122400. * The effect layer Helps adding post process effect blended with the main pass.
  122401. *
  122402. * This can be for instance use to generate glow or higlight effects on the scene.
  122403. *
  122404. * The effect layer class can not be used directly and is intented to inherited from to be
  122405. * customized per effects.
  122406. */
  122407. export abstract class EffectLayer {
  122408. private _vertexBuffers;
  122409. private _indexBuffer;
  122410. private _cachedDefines;
  122411. private _effectLayerMapGenerationEffect;
  122412. private _effectLayerOptions;
  122413. private _mergeEffect;
  122414. protected _scene: Scene;
  122415. protected _engine: Engine;
  122416. protected _maxSize: number;
  122417. protected _mainTextureDesiredSize: ISize;
  122418. protected _mainTexture: RenderTargetTexture;
  122419. protected _shouldRender: boolean;
  122420. protected _postProcesses: PostProcess[];
  122421. protected _textures: BaseTexture[];
  122422. protected _emissiveTextureAndColor: {
  122423. texture: Nullable<BaseTexture>;
  122424. color: Color4;
  122425. };
  122426. /**
  122427. * The name of the layer
  122428. */
  122429. name: string;
  122430. /**
  122431. * The clear color of the texture used to generate the glow map.
  122432. */
  122433. neutralColor: Color4;
  122434. /**
  122435. * Specifies wether the highlight layer is enabled or not.
  122436. */
  122437. isEnabled: boolean;
  122438. /**
  122439. * Gets the camera attached to the layer.
  122440. */
  122441. get camera(): Nullable<Camera>;
  122442. /**
  122443. * Gets the rendering group id the layer should render in.
  122444. */
  122445. get renderingGroupId(): number;
  122446. set renderingGroupId(renderingGroupId: number);
  122447. /**
  122448. * An event triggered when the effect layer has been disposed.
  122449. */
  122450. onDisposeObservable: Observable<EffectLayer>;
  122451. /**
  122452. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122453. */
  122454. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122455. /**
  122456. * An event triggered when the generated texture is being merged in the scene.
  122457. */
  122458. onBeforeComposeObservable: Observable<EffectLayer>;
  122459. /**
  122460. * An event triggered when the mesh is rendered into the effect render target.
  122461. */
  122462. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122463. /**
  122464. * An event triggered after the mesh has been rendered into the effect render target.
  122465. */
  122466. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122467. /**
  122468. * An event triggered when the generated texture has been merged in the scene.
  122469. */
  122470. onAfterComposeObservable: Observable<EffectLayer>;
  122471. /**
  122472. * An event triggered when the efffect layer changes its size.
  122473. */
  122474. onSizeChangedObservable: Observable<EffectLayer>;
  122475. /** @hidden */
  122476. static _SceneComponentInitialization: (scene: Scene) => void;
  122477. /**
  122478. * Instantiates a new effect Layer and references it in the scene.
  122479. * @param name The name of the layer
  122480. * @param scene The scene to use the layer in
  122481. */
  122482. constructor(
  122483. /** The Friendly of the effect in the scene */
  122484. name: string, scene: Scene);
  122485. /**
  122486. * Get the effect name of the layer.
  122487. * @return The effect name
  122488. */
  122489. abstract getEffectName(): string;
  122490. /**
  122491. * Checks for the readiness of the element composing the layer.
  122492. * @param subMesh the mesh to check for
  122493. * @param useInstances specify wether or not to use instances to render the mesh
  122494. * @return true if ready otherwise, false
  122495. */
  122496. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122497. /**
  122498. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122499. * @returns true if the effect requires stencil during the main canvas render pass.
  122500. */
  122501. abstract needStencil(): boolean;
  122502. /**
  122503. * Create the merge effect. This is the shader use to blit the information back
  122504. * to the main canvas at the end of the scene rendering.
  122505. * @returns The effect containing the shader used to merge the effect on the main canvas
  122506. */
  122507. protected abstract _createMergeEffect(): Effect;
  122508. /**
  122509. * Creates the render target textures and post processes used in the effect layer.
  122510. */
  122511. protected abstract _createTextureAndPostProcesses(): void;
  122512. /**
  122513. * Implementation specific of rendering the generating effect on the main canvas.
  122514. * @param effect The effect used to render through
  122515. */
  122516. protected abstract _internalRender(effect: Effect): void;
  122517. /**
  122518. * Sets the required values for both the emissive texture and and the main color.
  122519. */
  122520. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122521. /**
  122522. * Free any resources and references associated to a mesh.
  122523. * Internal use
  122524. * @param mesh The mesh to free.
  122525. */
  122526. abstract _disposeMesh(mesh: Mesh): void;
  122527. /**
  122528. * Serializes this layer (Glow or Highlight for example)
  122529. * @returns a serialized layer object
  122530. */
  122531. abstract serialize?(): any;
  122532. /**
  122533. * Initializes the effect layer with the required options.
  122534. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122535. */
  122536. protected _init(options: Partial<IEffectLayerOptions>): void;
  122537. /**
  122538. * Generates the index buffer of the full screen quad blending to the main canvas.
  122539. */
  122540. private _generateIndexBuffer;
  122541. /**
  122542. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122543. */
  122544. private _generateVertexBuffer;
  122545. /**
  122546. * Sets the main texture desired size which is the closest power of two
  122547. * of the engine canvas size.
  122548. */
  122549. private _setMainTextureSize;
  122550. /**
  122551. * Creates the main texture for the effect layer.
  122552. */
  122553. protected _createMainTexture(): void;
  122554. /**
  122555. * Adds specific effects defines.
  122556. * @param defines The defines to add specifics to.
  122557. */
  122558. protected _addCustomEffectDefines(defines: string[]): void;
  122559. /**
  122560. * Checks for the readiness of the element composing the layer.
  122561. * @param subMesh the mesh to check for
  122562. * @param useInstances specify wether or not to use instances to render the mesh
  122563. * @param emissiveTexture the associated emissive texture used to generate the glow
  122564. * @return true if ready otherwise, false
  122565. */
  122566. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122567. /**
  122568. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122569. */
  122570. render(): void;
  122571. /**
  122572. * Determine if a given mesh will be used in the current effect.
  122573. * @param mesh mesh to test
  122574. * @returns true if the mesh will be used
  122575. */
  122576. hasMesh(mesh: AbstractMesh): boolean;
  122577. /**
  122578. * Returns true if the layer contains information to display, otherwise false.
  122579. * @returns true if the glow layer should be rendered
  122580. */
  122581. shouldRender(): boolean;
  122582. /**
  122583. * Returns true if the mesh should render, otherwise false.
  122584. * @param mesh The mesh to render
  122585. * @returns true if it should render otherwise false
  122586. */
  122587. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122588. /**
  122589. * Returns true if the mesh can be rendered, otherwise false.
  122590. * @param mesh The mesh to render
  122591. * @param material The material used on the mesh
  122592. * @returns true if it can be rendered otherwise false
  122593. */
  122594. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122595. /**
  122596. * Returns true if the mesh should render, otherwise false.
  122597. * @param mesh The mesh to render
  122598. * @returns true if it should render otherwise false
  122599. */
  122600. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122601. /**
  122602. * Renders the submesh passed in parameter to the generation map.
  122603. */
  122604. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122605. /**
  122606. * Defines wether the current material of the mesh should be use to render the effect.
  122607. * @param mesh defines the current mesh to render
  122608. */
  122609. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122610. /**
  122611. * Rebuild the required buffers.
  122612. * @hidden Internal use only.
  122613. */
  122614. _rebuild(): void;
  122615. /**
  122616. * Dispose only the render target textures and post process.
  122617. */
  122618. private _disposeTextureAndPostProcesses;
  122619. /**
  122620. * Dispose the highlight layer and free resources.
  122621. */
  122622. dispose(): void;
  122623. /**
  122624. * Gets the class name of the effect layer
  122625. * @returns the string with the class name of the effect layer
  122626. */
  122627. getClassName(): string;
  122628. /**
  122629. * Creates an effect layer from parsed effect layer data
  122630. * @param parsedEffectLayer defines effect layer data
  122631. * @param scene defines the current scene
  122632. * @param rootUrl defines the root URL containing the effect layer information
  122633. * @returns a parsed effect Layer
  122634. */
  122635. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122636. }
  122637. }
  122638. declare module BABYLON {
  122639. interface AbstractScene {
  122640. /**
  122641. * The list of effect layers (highlights/glow) added to the scene
  122642. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122643. * @see http://doc.babylonjs.com/how_to/glow_layer
  122644. */
  122645. effectLayers: Array<EffectLayer>;
  122646. /**
  122647. * Removes the given effect layer from this scene.
  122648. * @param toRemove defines the effect layer to remove
  122649. * @returns the index of the removed effect layer
  122650. */
  122651. removeEffectLayer(toRemove: EffectLayer): number;
  122652. /**
  122653. * Adds the given effect layer to this scene
  122654. * @param newEffectLayer defines the effect layer to add
  122655. */
  122656. addEffectLayer(newEffectLayer: EffectLayer): void;
  122657. }
  122658. /**
  122659. * Defines the layer scene component responsible to manage any effect layers
  122660. * in a given scene.
  122661. */
  122662. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122663. /**
  122664. * The component name helpfull to identify the component in the list of scene components.
  122665. */
  122666. readonly name: string;
  122667. /**
  122668. * The scene the component belongs to.
  122669. */
  122670. scene: Scene;
  122671. private _engine;
  122672. private _renderEffects;
  122673. private _needStencil;
  122674. private _previousStencilState;
  122675. /**
  122676. * Creates a new instance of the component for the given scene
  122677. * @param scene Defines the scene to register the component in
  122678. */
  122679. constructor(scene: Scene);
  122680. /**
  122681. * Registers the component in a given scene
  122682. */
  122683. register(): void;
  122684. /**
  122685. * Rebuilds the elements related to this component in case of
  122686. * context lost for instance.
  122687. */
  122688. rebuild(): void;
  122689. /**
  122690. * Serializes the component data to the specified json object
  122691. * @param serializationObject The object to serialize to
  122692. */
  122693. serialize(serializationObject: any): void;
  122694. /**
  122695. * Adds all the elements from the container to the scene
  122696. * @param container the container holding the elements
  122697. */
  122698. addFromContainer(container: AbstractScene): void;
  122699. /**
  122700. * Removes all the elements in the container from the scene
  122701. * @param container contains the elements to remove
  122702. * @param dispose if the removed element should be disposed (default: false)
  122703. */
  122704. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122705. /**
  122706. * Disposes the component and the associated ressources.
  122707. */
  122708. dispose(): void;
  122709. private _isReadyForMesh;
  122710. private _renderMainTexture;
  122711. private _setStencil;
  122712. private _setStencilBack;
  122713. private _draw;
  122714. private _drawCamera;
  122715. private _drawRenderingGroup;
  122716. }
  122717. }
  122718. declare module BABYLON {
  122719. /** @hidden */
  122720. export var glowMapMergePixelShader: {
  122721. name: string;
  122722. shader: string;
  122723. };
  122724. }
  122725. declare module BABYLON {
  122726. /** @hidden */
  122727. export var glowMapMergeVertexShader: {
  122728. name: string;
  122729. shader: string;
  122730. };
  122731. }
  122732. declare module BABYLON {
  122733. interface AbstractScene {
  122734. /**
  122735. * Return a the first highlight layer of the scene with a given name.
  122736. * @param name The name of the highlight layer to look for.
  122737. * @return The highlight layer if found otherwise null.
  122738. */
  122739. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122740. }
  122741. /**
  122742. * Glow layer options. This helps customizing the behaviour
  122743. * of the glow layer.
  122744. */
  122745. export interface IGlowLayerOptions {
  122746. /**
  122747. * Multiplication factor apply to the canvas size to compute the render target size
  122748. * used to generated the glowing objects (the smaller the faster).
  122749. */
  122750. mainTextureRatio: number;
  122751. /**
  122752. * Enforces a fixed size texture to ensure resize independant blur.
  122753. */
  122754. mainTextureFixedSize?: number;
  122755. /**
  122756. * How big is the kernel of the blur texture.
  122757. */
  122758. blurKernelSize: number;
  122759. /**
  122760. * The camera attached to the layer.
  122761. */
  122762. camera: Nullable<Camera>;
  122763. /**
  122764. * Enable MSAA by chosing the number of samples.
  122765. */
  122766. mainTextureSamples?: number;
  122767. /**
  122768. * The rendering group to draw the layer in.
  122769. */
  122770. renderingGroupId: number;
  122771. }
  122772. /**
  122773. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122774. *
  122775. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122776. *
  122777. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122778. */
  122779. export class GlowLayer extends EffectLayer {
  122780. /**
  122781. * Effect Name of the layer.
  122782. */
  122783. static readonly EffectName: string;
  122784. /**
  122785. * The default blur kernel size used for the glow.
  122786. */
  122787. static DefaultBlurKernelSize: number;
  122788. /**
  122789. * The default texture size ratio used for the glow.
  122790. */
  122791. static DefaultTextureRatio: number;
  122792. /**
  122793. * Sets the kernel size of the blur.
  122794. */
  122795. set blurKernelSize(value: number);
  122796. /**
  122797. * Gets the kernel size of the blur.
  122798. */
  122799. get blurKernelSize(): number;
  122800. /**
  122801. * Sets the glow intensity.
  122802. */
  122803. set intensity(value: number);
  122804. /**
  122805. * Gets the glow intensity.
  122806. */
  122807. get intensity(): number;
  122808. private _options;
  122809. private _intensity;
  122810. private _horizontalBlurPostprocess1;
  122811. private _verticalBlurPostprocess1;
  122812. private _horizontalBlurPostprocess2;
  122813. private _verticalBlurPostprocess2;
  122814. private _blurTexture1;
  122815. private _blurTexture2;
  122816. private _postProcesses1;
  122817. private _postProcesses2;
  122818. private _includedOnlyMeshes;
  122819. private _excludedMeshes;
  122820. private _meshesUsingTheirOwnMaterials;
  122821. /**
  122822. * Callback used to let the user override the color selection on a per mesh basis
  122823. */
  122824. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122825. /**
  122826. * Callback used to let the user override the texture selection on a per mesh basis
  122827. */
  122828. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122829. /**
  122830. * Instantiates a new glow Layer and references it to the scene.
  122831. * @param name The name of the layer
  122832. * @param scene The scene to use the layer in
  122833. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122834. */
  122835. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122836. /**
  122837. * Get the effect name of the layer.
  122838. * @return The effect name
  122839. */
  122840. getEffectName(): string;
  122841. /**
  122842. * Create the merge effect. This is the shader use to blit the information back
  122843. * to the main canvas at the end of the scene rendering.
  122844. */
  122845. protected _createMergeEffect(): Effect;
  122846. /**
  122847. * Creates the render target textures and post processes used in the glow layer.
  122848. */
  122849. protected _createTextureAndPostProcesses(): void;
  122850. /**
  122851. * Checks for the readiness of the element composing the layer.
  122852. * @param subMesh the mesh to check for
  122853. * @param useInstances specify wether or not to use instances to render the mesh
  122854. * @param emissiveTexture the associated emissive texture used to generate the glow
  122855. * @return true if ready otherwise, false
  122856. */
  122857. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122858. /**
  122859. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122860. */
  122861. needStencil(): boolean;
  122862. /**
  122863. * Returns true if the mesh can be rendered, otherwise false.
  122864. * @param mesh The mesh to render
  122865. * @param material The material used on the mesh
  122866. * @returns true if it can be rendered otherwise false
  122867. */
  122868. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122869. /**
  122870. * Implementation specific of rendering the generating effect on the main canvas.
  122871. * @param effect The effect used to render through
  122872. */
  122873. protected _internalRender(effect: Effect): void;
  122874. /**
  122875. * Sets the required values for both the emissive texture and and the main color.
  122876. */
  122877. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122878. /**
  122879. * Returns true if the mesh should render, otherwise false.
  122880. * @param mesh The mesh to render
  122881. * @returns true if it should render otherwise false
  122882. */
  122883. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122884. /**
  122885. * Adds specific effects defines.
  122886. * @param defines The defines to add specifics to.
  122887. */
  122888. protected _addCustomEffectDefines(defines: string[]): void;
  122889. /**
  122890. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122891. * @param mesh The mesh to exclude from the glow layer
  122892. */
  122893. addExcludedMesh(mesh: Mesh): void;
  122894. /**
  122895. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122896. * @param mesh The mesh to remove
  122897. */
  122898. removeExcludedMesh(mesh: Mesh): void;
  122899. /**
  122900. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122901. * @param mesh The mesh to include in the glow layer
  122902. */
  122903. addIncludedOnlyMesh(mesh: Mesh): void;
  122904. /**
  122905. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122906. * @param mesh The mesh to remove
  122907. */
  122908. removeIncludedOnlyMesh(mesh: Mesh): void;
  122909. /**
  122910. * Determine if a given mesh will be used in the glow layer
  122911. * @param mesh The mesh to test
  122912. * @returns true if the mesh will be highlighted by the current glow layer
  122913. */
  122914. hasMesh(mesh: AbstractMesh): boolean;
  122915. /**
  122916. * Defines wether the current material of the mesh should be use to render the effect.
  122917. * @param mesh defines the current mesh to render
  122918. */
  122919. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122920. /**
  122921. * Add a mesh to be rendered through its own material and not with emissive only.
  122922. * @param mesh The mesh for which we need to use its material
  122923. */
  122924. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122925. /**
  122926. * Remove a mesh from being rendered through its own material and not with emissive only.
  122927. * @param mesh The mesh for which we need to not use its material
  122928. */
  122929. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122930. /**
  122931. * Free any resources and references associated to a mesh.
  122932. * Internal use
  122933. * @param mesh The mesh to free.
  122934. * @hidden
  122935. */
  122936. _disposeMesh(mesh: Mesh): void;
  122937. /**
  122938. * Gets the class name of the effect layer
  122939. * @returns the string with the class name of the effect layer
  122940. */
  122941. getClassName(): string;
  122942. /**
  122943. * Serializes this glow layer
  122944. * @returns a serialized glow layer object
  122945. */
  122946. serialize(): any;
  122947. /**
  122948. * Creates a Glow Layer from parsed glow layer data
  122949. * @param parsedGlowLayer defines glow layer data
  122950. * @param scene defines the current scene
  122951. * @param rootUrl defines the root URL containing the glow layer information
  122952. * @returns a parsed Glow Layer
  122953. */
  122954. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122955. }
  122956. }
  122957. declare module BABYLON {
  122958. /** @hidden */
  122959. export var glowBlurPostProcessPixelShader: {
  122960. name: string;
  122961. shader: string;
  122962. };
  122963. }
  122964. declare module BABYLON {
  122965. interface AbstractScene {
  122966. /**
  122967. * Return a the first highlight layer of the scene with a given name.
  122968. * @param name The name of the highlight layer to look for.
  122969. * @return The highlight layer if found otherwise null.
  122970. */
  122971. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122972. }
  122973. /**
  122974. * Highlight layer options. This helps customizing the behaviour
  122975. * of the highlight layer.
  122976. */
  122977. export interface IHighlightLayerOptions {
  122978. /**
  122979. * Multiplication factor apply to the canvas size to compute the render target size
  122980. * used to generated the glowing objects (the smaller the faster).
  122981. */
  122982. mainTextureRatio: number;
  122983. /**
  122984. * Enforces a fixed size texture to ensure resize independant blur.
  122985. */
  122986. mainTextureFixedSize?: number;
  122987. /**
  122988. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122989. * of the picture to blur (the smaller the faster).
  122990. */
  122991. blurTextureSizeRatio: number;
  122992. /**
  122993. * How big in texel of the blur texture is the vertical blur.
  122994. */
  122995. blurVerticalSize: number;
  122996. /**
  122997. * How big in texel of the blur texture is the horizontal blur.
  122998. */
  122999. blurHorizontalSize: number;
  123000. /**
  123001. * Alpha blending mode used to apply the blur. Default is combine.
  123002. */
  123003. alphaBlendingMode: number;
  123004. /**
  123005. * The camera attached to the layer.
  123006. */
  123007. camera: Nullable<Camera>;
  123008. /**
  123009. * Should we display highlight as a solid stroke?
  123010. */
  123011. isStroke?: boolean;
  123012. /**
  123013. * The rendering group to draw the layer in.
  123014. */
  123015. renderingGroupId: number;
  123016. }
  123017. /**
  123018. * The highlight layer Helps adding a glow effect around a mesh.
  123019. *
  123020. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  123021. * glowy meshes to your scene.
  123022. *
  123023. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  123024. */
  123025. export class HighlightLayer extends EffectLayer {
  123026. name: string;
  123027. /**
  123028. * Effect Name of the highlight layer.
  123029. */
  123030. static readonly EffectName: string;
  123031. /**
  123032. * The neutral color used during the preparation of the glow effect.
  123033. * This is black by default as the blend operation is a blend operation.
  123034. */
  123035. static NeutralColor: Color4;
  123036. /**
  123037. * Stencil value used for glowing meshes.
  123038. */
  123039. static GlowingMeshStencilReference: number;
  123040. /**
  123041. * Stencil value used for the other meshes in the scene.
  123042. */
  123043. static NormalMeshStencilReference: number;
  123044. /**
  123045. * Specifies whether or not the inner glow is ACTIVE in the layer.
  123046. */
  123047. innerGlow: boolean;
  123048. /**
  123049. * Specifies whether or not the outer glow is ACTIVE in the layer.
  123050. */
  123051. outerGlow: boolean;
  123052. /**
  123053. * Specifies the horizontal size of the blur.
  123054. */
  123055. set blurHorizontalSize(value: number);
  123056. /**
  123057. * Specifies the vertical size of the blur.
  123058. */
  123059. set blurVerticalSize(value: number);
  123060. /**
  123061. * Gets the horizontal size of the blur.
  123062. */
  123063. get blurHorizontalSize(): number;
  123064. /**
  123065. * Gets the vertical size of the blur.
  123066. */
  123067. get blurVerticalSize(): number;
  123068. /**
  123069. * An event triggered when the highlight layer is being blurred.
  123070. */
  123071. onBeforeBlurObservable: Observable<HighlightLayer>;
  123072. /**
  123073. * An event triggered when the highlight layer has been blurred.
  123074. */
  123075. onAfterBlurObservable: Observable<HighlightLayer>;
  123076. private _instanceGlowingMeshStencilReference;
  123077. private _options;
  123078. private _downSamplePostprocess;
  123079. private _horizontalBlurPostprocess;
  123080. private _verticalBlurPostprocess;
  123081. private _blurTexture;
  123082. private _meshes;
  123083. private _excludedMeshes;
  123084. /**
  123085. * Instantiates a new highlight Layer and references it to the scene..
  123086. * @param name The name of the layer
  123087. * @param scene The scene to use the layer in
  123088. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  123089. */
  123090. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  123091. /**
  123092. * Get the effect name of the layer.
  123093. * @return The effect name
  123094. */
  123095. getEffectName(): string;
  123096. /**
  123097. * Create the merge effect. This is the shader use to blit the information back
  123098. * to the main canvas at the end of the scene rendering.
  123099. */
  123100. protected _createMergeEffect(): Effect;
  123101. /**
  123102. * Creates the render target textures and post processes used in the highlight layer.
  123103. */
  123104. protected _createTextureAndPostProcesses(): void;
  123105. /**
  123106. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123107. */
  123108. needStencil(): boolean;
  123109. /**
  123110. * Checks for the readiness of the element composing the layer.
  123111. * @param subMesh the mesh to check for
  123112. * @param useInstances specify wether or not to use instances to render the mesh
  123113. * @param emissiveTexture the associated emissive texture used to generate the glow
  123114. * @return true if ready otherwise, false
  123115. */
  123116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123117. /**
  123118. * Implementation specific of rendering the generating effect on the main canvas.
  123119. * @param effect The effect used to render through
  123120. */
  123121. protected _internalRender(effect: Effect): void;
  123122. /**
  123123. * Returns true if the layer contains information to display, otherwise false.
  123124. */
  123125. shouldRender(): boolean;
  123126. /**
  123127. * Returns true if the mesh should render, otherwise false.
  123128. * @param mesh The mesh to render
  123129. * @returns true if it should render otherwise false
  123130. */
  123131. protected _shouldRenderMesh(mesh: Mesh): boolean;
  123132. /**
  123133. * Sets the required values for both the emissive texture and and the main color.
  123134. */
  123135. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123136. /**
  123137. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  123138. * @param mesh The mesh to exclude from the highlight layer
  123139. */
  123140. addExcludedMesh(mesh: Mesh): void;
  123141. /**
  123142. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  123143. * @param mesh The mesh to highlight
  123144. */
  123145. removeExcludedMesh(mesh: Mesh): void;
  123146. /**
  123147. * Determine if a given mesh will be highlighted by the current HighlightLayer
  123148. * @param mesh mesh to test
  123149. * @returns true if the mesh will be highlighted by the current HighlightLayer
  123150. */
  123151. hasMesh(mesh: AbstractMesh): boolean;
  123152. /**
  123153. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  123154. * @param mesh The mesh to highlight
  123155. * @param color The color of the highlight
  123156. * @param glowEmissiveOnly Extract the glow from the emissive texture
  123157. */
  123158. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  123159. /**
  123160. * Remove a mesh from the highlight layer in order to make it stop glowing.
  123161. * @param mesh The mesh to highlight
  123162. */
  123163. removeMesh(mesh: Mesh): void;
  123164. /**
  123165. * Force the stencil to the normal expected value for none glowing parts
  123166. */
  123167. private _defaultStencilReference;
  123168. /**
  123169. * Free any resources and references associated to a mesh.
  123170. * Internal use
  123171. * @param mesh The mesh to free.
  123172. * @hidden
  123173. */
  123174. _disposeMesh(mesh: Mesh): void;
  123175. /**
  123176. * Dispose the highlight layer and free resources.
  123177. */
  123178. dispose(): void;
  123179. /**
  123180. * Gets the class name of the effect layer
  123181. * @returns the string with the class name of the effect layer
  123182. */
  123183. getClassName(): string;
  123184. /**
  123185. * Serializes this Highlight layer
  123186. * @returns a serialized Highlight layer object
  123187. */
  123188. serialize(): any;
  123189. /**
  123190. * Creates a Highlight layer from parsed Highlight layer data
  123191. * @param parsedHightlightLayer defines the Highlight layer data
  123192. * @param scene defines the current scene
  123193. * @param rootUrl defines the root URL containing the Highlight layer information
  123194. * @returns a parsed Highlight layer
  123195. */
  123196. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  123197. }
  123198. }
  123199. declare module BABYLON {
  123200. interface AbstractScene {
  123201. /**
  123202. * The list of layers (background and foreground) of the scene
  123203. */
  123204. layers: Array<Layer>;
  123205. }
  123206. /**
  123207. * Defines the layer scene component responsible to manage any layers
  123208. * in a given scene.
  123209. */
  123210. export class LayerSceneComponent implements ISceneComponent {
  123211. /**
  123212. * The component name helpfull to identify the component in the list of scene components.
  123213. */
  123214. readonly name: string;
  123215. /**
  123216. * The scene the component belongs to.
  123217. */
  123218. scene: Scene;
  123219. private _engine;
  123220. /**
  123221. * Creates a new instance of the component for the given scene
  123222. * @param scene Defines the scene to register the component in
  123223. */
  123224. constructor(scene: Scene);
  123225. /**
  123226. * Registers the component in a given scene
  123227. */
  123228. register(): void;
  123229. /**
  123230. * Rebuilds the elements related to this component in case of
  123231. * context lost for instance.
  123232. */
  123233. rebuild(): void;
  123234. /**
  123235. * Disposes the component and the associated ressources.
  123236. */
  123237. dispose(): void;
  123238. private _draw;
  123239. private _drawCameraPredicate;
  123240. private _drawCameraBackground;
  123241. private _drawCameraForeground;
  123242. private _drawRenderTargetPredicate;
  123243. private _drawRenderTargetBackground;
  123244. private _drawRenderTargetForeground;
  123245. /**
  123246. * Adds all the elements from the container to the scene
  123247. * @param container the container holding the elements
  123248. */
  123249. addFromContainer(container: AbstractScene): void;
  123250. /**
  123251. * Removes all the elements in the container from the scene
  123252. * @param container contains the elements to remove
  123253. * @param dispose if the removed element should be disposed (default: false)
  123254. */
  123255. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123256. }
  123257. }
  123258. declare module BABYLON {
  123259. /** @hidden */
  123260. export var layerPixelShader: {
  123261. name: string;
  123262. shader: string;
  123263. };
  123264. }
  123265. declare module BABYLON {
  123266. /** @hidden */
  123267. export var layerVertexShader: {
  123268. name: string;
  123269. shader: string;
  123270. };
  123271. }
  123272. declare module BABYLON {
  123273. /**
  123274. * This represents a full screen 2d layer.
  123275. * This can be useful to display a picture in the background of your scene for instance.
  123276. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123277. */
  123278. export class Layer {
  123279. /**
  123280. * Define the name of the layer.
  123281. */
  123282. name: string;
  123283. /**
  123284. * Define the texture the layer should display.
  123285. */
  123286. texture: Nullable<Texture>;
  123287. /**
  123288. * Is the layer in background or foreground.
  123289. */
  123290. isBackground: boolean;
  123291. /**
  123292. * Define the color of the layer (instead of texture).
  123293. */
  123294. color: Color4;
  123295. /**
  123296. * Define the scale of the layer in order to zoom in out of the texture.
  123297. */
  123298. scale: Vector2;
  123299. /**
  123300. * Define an offset for the layer in order to shift the texture.
  123301. */
  123302. offset: Vector2;
  123303. /**
  123304. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123305. */
  123306. alphaBlendingMode: number;
  123307. /**
  123308. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123309. * Alpha test will not mix with the background color in case of transparency.
  123310. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123311. */
  123312. alphaTest: boolean;
  123313. /**
  123314. * Define a mask to restrict the layer to only some of the scene cameras.
  123315. */
  123316. layerMask: number;
  123317. /**
  123318. * Define the list of render target the layer is visible into.
  123319. */
  123320. renderTargetTextures: RenderTargetTexture[];
  123321. /**
  123322. * Define if the layer is only used in renderTarget or if it also
  123323. * renders in the main frame buffer of the canvas.
  123324. */
  123325. renderOnlyInRenderTargetTextures: boolean;
  123326. private _scene;
  123327. private _vertexBuffers;
  123328. private _indexBuffer;
  123329. private _effect;
  123330. private _previousDefines;
  123331. /**
  123332. * An event triggered when the layer is disposed.
  123333. */
  123334. onDisposeObservable: Observable<Layer>;
  123335. private _onDisposeObserver;
  123336. /**
  123337. * Back compatibility with callback before the onDisposeObservable existed.
  123338. * The set callback will be triggered when the layer has been disposed.
  123339. */
  123340. set onDispose(callback: () => void);
  123341. /**
  123342. * An event triggered before rendering the scene
  123343. */
  123344. onBeforeRenderObservable: Observable<Layer>;
  123345. private _onBeforeRenderObserver;
  123346. /**
  123347. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123348. * The set callback will be triggered just before rendering the layer.
  123349. */
  123350. set onBeforeRender(callback: () => void);
  123351. /**
  123352. * An event triggered after rendering the scene
  123353. */
  123354. onAfterRenderObservable: Observable<Layer>;
  123355. private _onAfterRenderObserver;
  123356. /**
  123357. * Back compatibility with callback before the onAfterRenderObservable existed.
  123358. * The set callback will be triggered just after rendering the layer.
  123359. */
  123360. set onAfterRender(callback: () => void);
  123361. /**
  123362. * Instantiates a new layer.
  123363. * This represents a full screen 2d layer.
  123364. * This can be useful to display a picture in the background of your scene for instance.
  123365. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123366. * @param name Define the name of the layer in the scene
  123367. * @param imgUrl Define the url of the texture to display in the layer
  123368. * @param scene Define the scene the layer belongs to
  123369. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123370. * @param color Defines a color for the layer
  123371. */
  123372. constructor(
  123373. /**
  123374. * Define the name of the layer.
  123375. */
  123376. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123377. private _createIndexBuffer;
  123378. /** @hidden */
  123379. _rebuild(): void;
  123380. /**
  123381. * Renders the layer in the scene.
  123382. */
  123383. render(): void;
  123384. /**
  123385. * Disposes and releases the associated ressources.
  123386. */
  123387. dispose(): void;
  123388. }
  123389. }
  123390. declare module BABYLON {
  123391. /** @hidden */
  123392. export var lensFlarePixelShader: {
  123393. name: string;
  123394. shader: string;
  123395. };
  123396. }
  123397. declare module BABYLON {
  123398. /** @hidden */
  123399. export var lensFlareVertexShader: {
  123400. name: string;
  123401. shader: string;
  123402. };
  123403. }
  123404. declare module BABYLON {
  123405. /**
  123406. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123407. * It is usually composed of several `lensFlare`.
  123408. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123409. */
  123410. export class LensFlareSystem {
  123411. /**
  123412. * Define the name of the lens flare system
  123413. */
  123414. name: string;
  123415. /**
  123416. * List of lens flares used in this system.
  123417. */
  123418. lensFlares: LensFlare[];
  123419. /**
  123420. * Define a limit from the border the lens flare can be visible.
  123421. */
  123422. borderLimit: number;
  123423. /**
  123424. * Define a viewport border we do not want to see the lens flare in.
  123425. */
  123426. viewportBorder: number;
  123427. /**
  123428. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123429. */
  123430. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123431. /**
  123432. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123433. */
  123434. layerMask: number;
  123435. /**
  123436. * Define the id of the lens flare system in the scene.
  123437. * (equal to name by default)
  123438. */
  123439. id: string;
  123440. private _scene;
  123441. private _emitter;
  123442. private _vertexBuffers;
  123443. private _indexBuffer;
  123444. private _effect;
  123445. private _positionX;
  123446. private _positionY;
  123447. private _isEnabled;
  123448. /** @hidden */
  123449. static _SceneComponentInitialization: (scene: Scene) => void;
  123450. /**
  123451. * Instantiates a lens flare system.
  123452. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123453. * It is usually composed of several `lensFlare`.
  123454. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123455. * @param name Define the name of the lens flare system in the scene
  123456. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123457. * @param scene Define the scene the lens flare system belongs to
  123458. */
  123459. constructor(
  123460. /**
  123461. * Define the name of the lens flare system
  123462. */
  123463. name: string, emitter: any, scene: Scene);
  123464. /**
  123465. * Define if the lens flare system is enabled.
  123466. */
  123467. get isEnabled(): boolean;
  123468. set isEnabled(value: boolean);
  123469. /**
  123470. * Get the scene the effects belongs to.
  123471. * @returns the scene holding the lens flare system
  123472. */
  123473. getScene(): Scene;
  123474. /**
  123475. * Get the emitter of the lens flare system.
  123476. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123477. * @returns the emitter of the lens flare system
  123478. */
  123479. getEmitter(): any;
  123480. /**
  123481. * Set the emitter of the lens flare system.
  123482. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123483. * @param newEmitter Define the new emitter of the system
  123484. */
  123485. setEmitter(newEmitter: any): void;
  123486. /**
  123487. * Get the lens flare system emitter position.
  123488. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123489. * @returns the position
  123490. */
  123491. getEmitterPosition(): Vector3;
  123492. /**
  123493. * @hidden
  123494. */
  123495. computeEffectivePosition(globalViewport: Viewport): boolean;
  123496. /** @hidden */
  123497. _isVisible(): boolean;
  123498. /**
  123499. * @hidden
  123500. */
  123501. render(): boolean;
  123502. /**
  123503. * Dispose and release the lens flare with its associated resources.
  123504. */
  123505. dispose(): void;
  123506. /**
  123507. * Parse a lens flare system from a JSON repressentation
  123508. * @param parsedLensFlareSystem Define the JSON to parse
  123509. * @param scene Define the scene the parsed system should be instantiated in
  123510. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123511. * @returns the parsed system
  123512. */
  123513. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123514. /**
  123515. * Serialize the current Lens Flare System into a JSON representation.
  123516. * @returns the serialized JSON
  123517. */
  123518. serialize(): any;
  123519. }
  123520. }
  123521. declare module BABYLON {
  123522. /**
  123523. * This represents one of the lens effect in a `lensFlareSystem`.
  123524. * It controls one of the indiviual texture used in the effect.
  123525. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123526. */
  123527. export class LensFlare {
  123528. /**
  123529. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123530. */
  123531. size: number;
  123532. /**
  123533. * 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.
  123534. */
  123535. position: number;
  123536. /**
  123537. * Define the lens color.
  123538. */
  123539. color: Color3;
  123540. /**
  123541. * Define the lens texture.
  123542. */
  123543. texture: Nullable<Texture>;
  123544. /**
  123545. * Define the alpha mode to render this particular lens.
  123546. */
  123547. alphaMode: number;
  123548. private _system;
  123549. /**
  123550. * Creates a new Lens Flare.
  123551. * This represents one of the lens effect in a `lensFlareSystem`.
  123552. * It controls one of the indiviual texture used in the effect.
  123553. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123554. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123555. * @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.
  123556. * @param color Define the lens color
  123557. * @param imgUrl Define the lens texture url
  123558. * @param system Define the `lensFlareSystem` this flare is part of
  123559. * @returns The newly created Lens Flare
  123560. */
  123561. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123562. /**
  123563. * Instantiates a new Lens Flare.
  123564. * This represents one of the lens effect in a `lensFlareSystem`.
  123565. * It controls one of the indiviual texture used in the effect.
  123566. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123567. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123568. * @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.
  123569. * @param color Define the lens color
  123570. * @param imgUrl Define the lens texture url
  123571. * @param system Define the `lensFlareSystem` this flare is part of
  123572. */
  123573. constructor(
  123574. /**
  123575. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123576. */
  123577. size: number,
  123578. /**
  123579. * 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.
  123580. */
  123581. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123582. /**
  123583. * Dispose and release the lens flare with its associated resources.
  123584. */
  123585. dispose(): void;
  123586. }
  123587. }
  123588. declare module BABYLON {
  123589. interface AbstractScene {
  123590. /**
  123591. * The list of lens flare system added to the scene
  123592. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123593. */
  123594. lensFlareSystems: Array<LensFlareSystem>;
  123595. /**
  123596. * Removes the given lens flare system from this scene.
  123597. * @param toRemove The lens flare system to remove
  123598. * @returns The index of the removed lens flare system
  123599. */
  123600. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123601. /**
  123602. * Adds the given lens flare system to this scene
  123603. * @param newLensFlareSystem The lens flare system to add
  123604. */
  123605. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123606. /**
  123607. * Gets a lens flare system using its name
  123608. * @param name defines the name to look for
  123609. * @returns the lens flare system or null if not found
  123610. */
  123611. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123612. /**
  123613. * Gets a lens flare system using its id
  123614. * @param id defines the id to look for
  123615. * @returns the lens flare system or null if not found
  123616. */
  123617. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123618. }
  123619. /**
  123620. * Defines the lens flare scene component responsible to manage any lens flares
  123621. * in a given scene.
  123622. */
  123623. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123624. /**
  123625. * The component name helpfull to identify the component in the list of scene components.
  123626. */
  123627. readonly name: string;
  123628. /**
  123629. * The scene the component belongs to.
  123630. */
  123631. scene: Scene;
  123632. /**
  123633. * Creates a new instance of the component for the given scene
  123634. * @param scene Defines the scene to register the component in
  123635. */
  123636. constructor(scene: Scene);
  123637. /**
  123638. * Registers the component in a given scene
  123639. */
  123640. register(): void;
  123641. /**
  123642. * Rebuilds the elements related to this component in case of
  123643. * context lost for instance.
  123644. */
  123645. rebuild(): void;
  123646. /**
  123647. * Adds all the elements from the container to the scene
  123648. * @param container the container holding the elements
  123649. */
  123650. addFromContainer(container: AbstractScene): void;
  123651. /**
  123652. * Removes all the elements in the container from the scene
  123653. * @param container contains the elements to remove
  123654. * @param dispose if the removed element should be disposed (default: false)
  123655. */
  123656. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123657. /**
  123658. * Serializes the component data to the specified json object
  123659. * @param serializationObject The object to serialize to
  123660. */
  123661. serialize(serializationObject: any): void;
  123662. /**
  123663. * Disposes the component and the associated ressources.
  123664. */
  123665. dispose(): void;
  123666. private _draw;
  123667. }
  123668. }
  123669. declare module BABYLON {
  123670. /**
  123671. * Defines the shadow generator component responsible to manage any shadow generators
  123672. * in a given scene.
  123673. */
  123674. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123675. /**
  123676. * The component name helpfull to identify the component in the list of scene components.
  123677. */
  123678. readonly name: string;
  123679. /**
  123680. * The scene the component belongs to.
  123681. */
  123682. scene: Scene;
  123683. /**
  123684. * Creates a new instance of the component for the given scene
  123685. * @param scene Defines the scene to register the component in
  123686. */
  123687. constructor(scene: Scene);
  123688. /**
  123689. * Registers the component in a given scene
  123690. */
  123691. register(): void;
  123692. /**
  123693. * Rebuilds the elements related to this component in case of
  123694. * context lost for instance.
  123695. */
  123696. rebuild(): void;
  123697. /**
  123698. * Serializes the component data to the specified json object
  123699. * @param serializationObject The object to serialize to
  123700. */
  123701. serialize(serializationObject: any): void;
  123702. /**
  123703. * Adds all the elements from the container to the scene
  123704. * @param container the container holding the elements
  123705. */
  123706. addFromContainer(container: AbstractScene): void;
  123707. /**
  123708. * Removes all the elements in the container from the scene
  123709. * @param container contains the elements to remove
  123710. * @param dispose if the removed element should be disposed (default: false)
  123711. */
  123712. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123713. /**
  123714. * Rebuilds the elements related to this component in case of
  123715. * context lost for instance.
  123716. */
  123717. dispose(): void;
  123718. private _gatherRenderTargets;
  123719. }
  123720. }
  123721. declare module BABYLON {
  123722. /**
  123723. * A point light is a light defined by an unique point in world space.
  123724. * The light is emitted in every direction from this point.
  123725. * A good example of a point light is a standard light bulb.
  123726. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123727. */
  123728. export class PointLight extends ShadowLight {
  123729. private _shadowAngle;
  123730. /**
  123731. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123732. * This specifies what angle the shadow will use to be created.
  123733. *
  123734. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123735. */
  123736. get shadowAngle(): number;
  123737. /**
  123738. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123739. * This specifies what angle the shadow will use to be created.
  123740. *
  123741. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123742. */
  123743. set shadowAngle(value: number);
  123744. /**
  123745. * Gets the direction if it has been set.
  123746. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123747. */
  123748. get direction(): Vector3;
  123749. /**
  123750. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123751. */
  123752. set direction(value: Vector3);
  123753. /**
  123754. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123755. * A PointLight emits the light in every direction.
  123756. * It can cast shadows.
  123757. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123758. * ```javascript
  123759. * var pointLight = new PointLight("pl", camera.position, scene);
  123760. * ```
  123761. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123762. * @param name The light friendly name
  123763. * @param position The position of the point light in the scene
  123764. * @param scene The scene the lights belongs to
  123765. */
  123766. constructor(name: string, position: Vector3, scene: Scene);
  123767. /**
  123768. * Returns the string "PointLight"
  123769. * @returns the class name
  123770. */
  123771. getClassName(): string;
  123772. /**
  123773. * Returns the integer 0.
  123774. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123775. */
  123776. getTypeID(): number;
  123777. /**
  123778. * Specifies wether or not the shadowmap should be a cube texture.
  123779. * @returns true if the shadowmap needs to be a cube texture.
  123780. */
  123781. needCube(): boolean;
  123782. /**
  123783. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123784. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123785. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123786. */
  123787. getShadowDirection(faceIndex?: number): Vector3;
  123788. /**
  123789. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123790. * - fov = PI / 2
  123791. * - aspect ratio : 1.0
  123792. * - z-near and far equal to the active camera minZ and maxZ.
  123793. * Returns the PointLight.
  123794. */
  123795. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123796. protected _buildUniformLayout(): void;
  123797. /**
  123798. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123799. * @param effect The effect to update
  123800. * @param lightIndex The index of the light in the effect to update
  123801. * @returns The point light
  123802. */
  123803. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123804. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123805. /**
  123806. * Prepares the list of defines specific to the light type.
  123807. * @param defines the list of defines
  123808. * @param lightIndex defines the index of the light for the effect
  123809. */
  123810. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123811. }
  123812. }
  123813. declare module BABYLON {
  123814. /**
  123815. * Header information of HDR texture files.
  123816. */
  123817. export interface HDRInfo {
  123818. /**
  123819. * The height of the texture in pixels.
  123820. */
  123821. height: number;
  123822. /**
  123823. * The width of the texture in pixels.
  123824. */
  123825. width: number;
  123826. /**
  123827. * The index of the beginning of the data in the binary file.
  123828. */
  123829. dataPosition: number;
  123830. }
  123831. /**
  123832. * This groups tools to convert HDR texture to native colors array.
  123833. */
  123834. export class HDRTools {
  123835. private static Ldexp;
  123836. private static Rgbe2float;
  123837. private static readStringLine;
  123838. /**
  123839. * Reads header information from an RGBE texture stored in a native array.
  123840. * More information on this format are available here:
  123841. * https://en.wikipedia.org/wiki/RGBE_image_format
  123842. *
  123843. * @param uint8array The binary file stored in native array.
  123844. * @return The header information.
  123845. */
  123846. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123847. /**
  123848. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123849. * This RGBE texture needs to store the information as a panorama.
  123850. *
  123851. * More information on this format are available here:
  123852. * https://en.wikipedia.org/wiki/RGBE_image_format
  123853. *
  123854. * @param buffer The binary file stored in an array buffer.
  123855. * @param size The expected size of the extracted cubemap.
  123856. * @return The Cube Map information.
  123857. */
  123858. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123859. /**
  123860. * Returns the pixels data extracted from an RGBE texture.
  123861. * This pixels will be stored left to right up to down in the R G B order in one array.
  123862. *
  123863. * More information on this format are available here:
  123864. * https://en.wikipedia.org/wiki/RGBE_image_format
  123865. *
  123866. * @param uint8array The binary file stored in an array buffer.
  123867. * @param hdrInfo The header information of the file.
  123868. * @return The pixels data in RGB right to left up to down order.
  123869. */
  123870. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123871. private static RGBE_ReadPixels_RLE;
  123872. }
  123873. }
  123874. declare module BABYLON {
  123875. /**
  123876. * This represents a texture coming from an HDR input.
  123877. *
  123878. * The only supported format is currently panorama picture stored in RGBE format.
  123879. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123880. */
  123881. export class HDRCubeTexture extends BaseTexture {
  123882. private static _facesMapping;
  123883. private _generateHarmonics;
  123884. private _noMipmap;
  123885. private _textureMatrix;
  123886. private _size;
  123887. private _onLoad;
  123888. private _onError;
  123889. /**
  123890. * The texture URL.
  123891. */
  123892. url: string;
  123893. /**
  123894. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123895. */
  123896. coordinatesMode: number;
  123897. protected _isBlocking: boolean;
  123898. /**
  123899. * Sets wether or not the texture is blocking during loading.
  123900. */
  123901. set isBlocking(value: boolean);
  123902. /**
  123903. * Gets wether or not the texture is blocking during loading.
  123904. */
  123905. get isBlocking(): boolean;
  123906. protected _rotationY: number;
  123907. /**
  123908. * Sets texture matrix rotation angle around Y axis in radians.
  123909. */
  123910. set rotationY(value: number);
  123911. /**
  123912. * Gets texture matrix rotation angle around Y axis radians.
  123913. */
  123914. get rotationY(): number;
  123915. /**
  123916. * Gets or sets the center of the bounding box associated with the cube texture
  123917. * It must define where the camera used to render the texture was set
  123918. */
  123919. boundingBoxPosition: Vector3;
  123920. private _boundingBoxSize;
  123921. /**
  123922. * Gets or sets the size of the bounding box associated with the cube texture
  123923. * When defined, the cubemap will switch to local mode
  123924. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123925. * @example https://www.babylonjs-playground.com/#RNASML
  123926. */
  123927. set boundingBoxSize(value: Vector3);
  123928. get boundingBoxSize(): Vector3;
  123929. /**
  123930. * Instantiates an HDRTexture from the following parameters.
  123931. *
  123932. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123933. * @param scene The scene the texture will be used in
  123934. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123935. * @param noMipmap Forces to not generate the mipmap if true
  123936. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123937. * @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)
  123938. * @param reserved Reserved flag for internal use.
  123939. */
  123940. 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>);
  123941. /**
  123942. * Get the current class name of the texture useful for serialization or dynamic coding.
  123943. * @returns "HDRCubeTexture"
  123944. */
  123945. getClassName(): string;
  123946. /**
  123947. * Occurs when the file is raw .hdr file.
  123948. */
  123949. private loadTexture;
  123950. clone(): HDRCubeTexture;
  123951. delayLoad(): void;
  123952. /**
  123953. * Get the texture reflection matrix used to rotate/transform the reflection.
  123954. * @returns the reflection matrix
  123955. */
  123956. getReflectionTextureMatrix(): Matrix;
  123957. /**
  123958. * Set the texture reflection matrix used to rotate/transform the reflection.
  123959. * @param value Define the reflection matrix to set
  123960. */
  123961. setReflectionTextureMatrix(value: Matrix): void;
  123962. /**
  123963. * Parses a JSON representation of an HDR Texture in order to create the texture
  123964. * @param parsedTexture Define the JSON representation
  123965. * @param scene Define the scene the texture should be created in
  123966. * @param rootUrl Define the root url in case we need to load relative dependencies
  123967. * @returns the newly created texture after parsing
  123968. */
  123969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123970. serialize(): any;
  123971. }
  123972. }
  123973. declare module BABYLON {
  123974. /**
  123975. * Class used to control physics engine
  123976. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123977. */
  123978. export class PhysicsEngine implements IPhysicsEngine {
  123979. private _physicsPlugin;
  123980. /**
  123981. * Global value used to control the smallest number supported by the simulation
  123982. */
  123983. static Epsilon: number;
  123984. private _impostors;
  123985. private _joints;
  123986. private _subTimeStep;
  123987. /**
  123988. * Gets the gravity vector used by the simulation
  123989. */
  123990. gravity: Vector3;
  123991. /**
  123992. * Factory used to create the default physics plugin.
  123993. * @returns The default physics plugin
  123994. */
  123995. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123996. /**
  123997. * Creates a new Physics Engine
  123998. * @param gravity defines the gravity vector used by the simulation
  123999. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  124000. */
  124001. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  124002. /**
  124003. * Sets the gravity vector used by the simulation
  124004. * @param gravity defines the gravity vector to use
  124005. */
  124006. setGravity(gravity: Vector3): void;
  124007. /**
  124008. * Set the time step of the physics engine.
  124009. * Default is 1/60.
  124010. * To slow it down, enter 1/600 for example.
  124011. * To speed it up, 1/30
  124012. * @param newTimeStep defines the new timestep to apply to this world.
  124013. */
  124014. setTimeStep(newTimeStep?: number): void;
  124015. /**
  124016. * Get the time step of the physics engine.
  124017. * @returns the current time step
  124018. */
  124019. getTimeStep(): number;
  124020. /**
  124021. * Set the sub time step of the physics engine.
  124022. * Default is 0 meaning there is no sub steps
  124023. * To increase physics resolution precision, set a small value (like 1 ms)
  124024. * @param subTimeStep defines the new sub timestep used for physics resolution.
  124025. */
  124026. setSubTimeStep(subTimeStep?: number): void;
  124027. /**
  124028. * Get the sub time step of the physics engine.
  124029. * @returns the current sub time step
  124030. */
  124031. getSubTimeStep(): number;
  124032. /**
  124033. * Release all resources
  124034. */
  124035. dispose(): void;
  124036. /**
  124037. * Gets the name of the current physics plugin
  124038. * @returns the name of the plugin
  124039. */
  124040. getPhysicsPluginName(): string;
  124041. /**
  124042. * Adding a new impostor for the impostor tracking.
  124043. * This will be done by the impostor itself.
  124044. * @param impostor the impostor to add
  124045. */
  124046. addImpostor(impostor: PhysicsImpostor): void;
  124047. /**
  124048. * Remove an impostor from the engine.
  124049. * This impostor and its mesh will not longer be updated by the physics engine.
  124050. * @param impostor the impostor to remove
  124051. */
  124052. removeImpostor(impostor: PhysicsImpostor): void;
  124053. /**
  124054. * Add a joint to the physics engine
  124055. * @param mainImpostor defines the main impostor to which the joint is added.
  124056. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  124057. * @param joint defines the joint that will connect both impostors.
  124058. */
  124059. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  124060. /**
  124061. * Removes a joint from the simulation
  124062. * @param mainImpostor defines the impostor used with the joint
  124063. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  124064. * @param joint defines the joint to remove
  124065. */
  124066. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  124067. /**
  124068. * Called by the scene. No need to call it.
  124069. * @param delta defines the timespam between frames
  124070. */
  124071. _step(delta: number): void;
  124072. /**
  124073. * Gets the current plugin used to run the simulation
  124074. * @returns current plugin
  124075. */
  124076. getPhysicsPlugin(): IPhysicsEnginePlugin;
  124077. /**
  124078. * Gets the list of physic impostors
  124079. * @returns an array of PhysicsImpostor
  124080. */
  124081. getImpostors(): Array<PhysicsImpostor>;
  124082. /**
  124083. * Gets the impostor for a physics enabled object
  124084. * @param object defines the object impersonated by the impostor
  124085. * @returns the PhysicsImpostor or null if not found
  124086. */
  124087. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  124088. /**
  124089. * Gets the impostor for a physics body object
  124090. * @param body defines physics body used by the impostor
  124091. * @returns the PhysicsImpostor or null if not found
  124092. */
  124093. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  124094. /**
  124095. * Does a raycast in the physics world
  124096. * @param from when should the ray start?
  124097. * @param to when should the ray end?
  124098. * @returns PhysicsRaycastResult
  124099. */
  124100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124101. }
  124102. }
  124103. declare module BABYLON {
  124104. /** @hidden */
  124105. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  124106. private _useDeltaForWorldStep;
  124107. world: any;
  124108. name: string;
  124109. private _physicsMaterials;
  124110. private _fixedTimeStep;
  124111. private _cannonRaycastResult;
  124112. private _raycastResult;
  124113. private _physicsBodysToRemoveAfterStep;
  124114. BJSCANNON: any;
  124115. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  124116. setGravity(gravity: Vector3): void;
  124117. setTimeStep(timeStep: number): void;
  124118. getTimeStep(): number;
  124119. executeStep(delta: number): void;
  124120. private _removeMarkedPhysicsBodiesFromWorld;
  124121. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124122. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124123. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124124. private _processChildMeshes;
  124125. removePhysicsBody(impostor: PhysicsImpostor): void;
  124126. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124127. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124128. private _addMaterial;
  124129. private _checkWithEpsilon;
  124130. private _createShape;
  124131. private _createHeightmap;
  124132. private _minus90X;
  124133. private _plus90X;
  124134. private _tmpPosition;
  124135. private _tmpDeltaPosition;
  124136. private _tmpUnityRotation;
  124137. private _updatePhysicsBodyTransformation;
  124138. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124139. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124140. isSupported(): boolean;
  124141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124146. getBodyMass(impostor: PhysicsImpostor): number;
  124147. getBodyFriction(impostor: PhysicsImpostor): number;
  124148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124149. getBodyRestitution(impostor: PhysicsImpostor): number;
  124150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124151. sleepBody(impostor: PhysicsImpostor): void;
  124152. wakeUpBody(impostor: PhysicsImpostor): void;
  124153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  124154. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124157. getRadius(impostor: PhysicsImpostor): number;
  124158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124159. dispose(): void;
  124160. private _extendNamespace;
  124161. /**
  124162. * Does a raycast in the physics world
  124163. * @param from when should the ray start?
  124164. * @param to when should the ray end?
  124165. * @returns PhysicsRaycastResult
  124166. */
  124167. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124168. }
  124169. }
  124170. declare module BABYLON {
  124171. /** @hidden */
  124172. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  124173. world: any;
  124174. name: string;
  124175. BJSOIMO: any;
  124176. private _raycastResult;
  124177. constructor(iterations?: number, oimoInjection?: any);
  124178. setGravity(gravity: Vector3): void;
  124179. setTimeStep(timeStep: number): void;
  124180. getTimeStep(): number;
  124181. private _tmpImpostorsArray;
  124182. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124183. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124184. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124185. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124186. private _tmpPositionVector;
  124187. removePhysicsBody(impostor: PhysicsImpostor): void;
  124188. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124189. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124190. isSupported(): boolean;
  124191. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124192. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124193. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124194. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124195. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124196. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124197. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124198. getBodyMass(impostor: PhysicsImpostor): number;
  124199. getBodyFriction(impostor: PhysicsImpostor): number;
  124200. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124201. getBodyRestitution(impostor: PhysicsImpostor): number;
  124202. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124203. sleepBody(impostor: PhysicsImpostor): void;
  124204. wakeUpBody(impostor: PhysicsImpostor): void;
  124205. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124206. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  124207. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  124208. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124209. getRadius(impostor: PhysicsImpostor): number;
  124210. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124211. dispose(): void;
  124212. /**
  124213. * Does a raycast in the physics world
  124214. * @param from when should the ray start?
  124215. * @param to when should the ray end?
  124216. * @returns PhysicsRaycastResult
  124217. */
  124218. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124219. }
  124220. }
  124221. declare module BABYLON {
  124222. /**
  124223. * Class containing static functions to help procedurally build meshes
  124224. */
  124225. export class RibbonBuilder {
  124226. /**
  124227. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124228. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124229. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124230. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124231. * * 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
  124232. * * 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
  124233. * * 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
  124234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124237. * * 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
  124238. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124239. * * 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
  124240. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124242. * @param name defines the name of the mesh
  124243. * @param options defines the options used to create the mesh
  124244. * @param scene defines the hosting scene
  124245. * @returns the ribbon mesh
  124246. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124248. */
  124249. static CreateRibbon(name: string, options: {
  124250. pathArray: Vector3[][];
  124251. closeArray?: boolean;
  124252. closePath?: boolean;
  124253. offset?: number;
  124254. updatable?: boolean;
  124255. sideOrientation?: number;
  124256. frontUVs?: Vector4;
  124257. backUVs?: Vector4;
  124258. instance?: Mesh;
  124259. invertUV?: boolean;
  124260. uvs?: Vector2[];
  124261. colors?: Color4[];
  124262. }, scene?: Nullable<Scene>): Mesh;
  124263. }
  124264. }
  124265. declare module BABYLON {
  124266. /**
  124267. * Class containing static functions to help procedurally build meshes
  124268. */
  124269. export class ShapeBuilder {
  124270. /**
  124271. * 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.
  124272. * * 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.
  124273. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124274. * * 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.
  124275. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124276. * * 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
  124277. * * 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
  124278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124283. * @param name defines the name of the mesh
  124284. * @param options defines the options used to create the mesh
  124285. * @param scene defines the hosting scene
  124286. * @returns the extruded shape mesh
  124287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124289. */
  124290. static ExtrudeShape(name: string, options: {
  124291. shape: Vector3[];
  124292. path: Vector3[];
  124293. scale?: number;
  124294. rotation?: number;
  124295. cap?: number;
  124296. updatable?: boolean;
  124297. sideOrientation?: number;
  124298. frontUVs?: Vector4;
  124299. backUVs?: Vector4;
  124300. instance?: Mesh;
  124301. invertUV?: boolean;
  124302. }, scene?: Nullable<Scene>): Mesh;
  124303. /**
  124304. * Creates an custom extruded shape mesh.
  124305. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124306. * * 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.
  124307. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124308. * * 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
  124309. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124310. * * 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
  124311. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124312. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124313. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124314. * * 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
  124315. * * 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
  124316. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124319. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124321. * @param name defines the name of the mesh
  124322. * @param options defines the options used to create the mesh
  124323. * @param scene defines the hosting scene
  124324. * @returns the custom extruded shape mesh
  124325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124326. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124328. */
  124329. static ExtrudeShapeCustom(name: string, options: {
  124330. shape: Vector3[];
  124331. path: Vector3[];
  124332. scaleFunction?: any;
  124333. rotationFunction?: any;
  124334. ribbonCloseArray?: boolean;
  124335. ribbonClosePath?: boolean;
  124336. cap?: number;
  124337. updatable?: boolean;
  124338. sideOrientation?: number;
  124339. frontUVs?: Vector4;
  124340. backUVs?: Vector4;
  124341. instance?: Mesh;
  124342. invertUV?: boolean;
  124343. }, scene?: Nullable<Scene>): Mesh;
  124344. private static _ExtrudeShapeGeneric;
  124345. }
  124346. }
  124347. declare module BABYLON {
  124348. /**
  124349. * AmmoJS Physics plugin
  124350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124351. * @see https://github.com/kripken/ammo.js/
  124352. */
  124353. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124354. private _useDeltaForWorldStep;
  124355. /**
  124356. * Reference to the Ammo library
  124357. */
  124358. bjsAMMO: any;
  124359. /**
  124360. * Created ammoJS world which physics bodies are added to
  124361. */
  124362. world: any;
  124363. /**
  124364. * Name of the plugin
  124365. */
  124366. name: string;
  124367. private _timeStep;
  124368. private _fixedTimeStep;
  124369. private _maxSteps;
  124370. private _tmpQuaternion;
  124371. private _tmpAmmoTransform;
  124372. private _tmpAmmoQuaternion;
  124373. private _tmpAmmoConcreteContactResultCallback;
  124374. private _collisionConfiguration;
  124375. private _dispatcher;
  124376. private _overlappingPairCache;
  124377. private _solver;
  124378. private _softBodySolver;
  124379. private _tmpAmmoVectorA;
  124380. private _tmpAmmoVectorB;
  124381. private _tmpAmmoVectorC;
  124382. private _tmpAmmoVectorD;
  124383. private _tmpContactCallbackResult;
  124384. private _tmpAmmoVectorRCA;
  124385. private _tmpAmmoVectorRCB;
  124386. private _raycastResult;
  124387. private static readonly DISABLE_COLLISION_FLAG;
  124388. private static readonly KINEMATIC_FLAG;
  124389. private static readonly DISABLE_DEACTIVATION_FLAG;
  124390. /**
  124391. * Initializes the ammoJS plugin
  124392. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124393. * @param ammoInjection can be used to inject your own ammo reference
  124394. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124395. */
  124396. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124397. /**
  124398. * Sets the gravity of the physics world (m/(s^2))
  124399. * @param gravity Gravity to set
  124400. */
  124401. setGravity(gravity: Vector3): void;
  124402. /**
  124403. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124404. * @param timeStep timestep to use in seconds
  124405. */
  124406. setTimeStep(timeStep: number): void;
  124407. /**
  124408. * 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)
  124409. * @param fixedTimeStep fixedTimeStep to use in seconds
  124410. */
  124411. setFixedTimeStep(fixedTimeStep: number): void;
  124412. /**
  124413. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124414. * @param maxSteps the maximum number of steps by the physics engine per frame
  124415. */
  124416. setMaxSteps(maxSteps: number): void;
  124417. /**
  124418. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124419. * @returns the current timestep in seconds
  124420. */
  124421. getTimeStep(): number;
  124422. /**
  124423. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124424. */
  124425. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124426. private _isImpostorInContact;
  124427. private _isImpostorPairInContact;
  124428. private _stepSimulation;
  124429. /**
  124430. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124431. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124432. * After the step the babylon meshes are set to the position of the physics imposters
  124433. * @param delta amount of time to step forward
  124434. * @param impostors array of imposters to update before/after the step
  124435. */
  124436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124437. /**
  124438. * Update babylon mesh to match physics world object
  124439. * @param impostor imposter to match
  124440. */
  124441. private _afterSoftStep;
  124442. /**
  124443. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124444. * @param impostor imposter to match
  124445. */
  124446. private _ropeStep;
  124447. /**
  124448. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124449. * @param impostor imposter to match
  124450. */
  124451. private _softbodyOrClothStep;
  124452. private _tmpVector;
  124453. private _tmpMatrix;
  124454. /**
  124455. * Applies an impulse on the imposter
  124456. * @param impostor imposter to apply impulse to
  124457. * @param force amount of force to be applied to the imposter
  124458. * @param contactPoint the location to apply the impulse on the imposter
  124459. */
  124460. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124461. /**
  124462. * Applies a force on the imposter
  124463. * @param impostor imposter to apply force
  124464. * @param force amount of force to be applied to the imposter
  124465. * @param contactPoint the location to apply the force on the imposter
  124466. */
  124467. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124468. /**
  124469. * Creates a physics body using the plugin
  124470. * @param impostor the imposter to create the physics body on
  124471. */
  124472. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124473. /**
  124474. * Removes the physics body from the imposter and disposes of the body's memory
  124475. * @param impostor imposter to remove the physics body from
  124476. */
  124477. removePhysicsBody(impostor: PhysicsImpostor): void;
  124478. /**
  124479. * Generates a joint
  124480. * @param impostorJoint the imposter joint to create the joint with
  124481. */
  124482. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124483. /**
  124484. * Removes a joint
  124485. * @param impostorJoint the imposter joint to remove the joint from
  124486. */
  124487. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124488. private _addMeshVerts;
  124489. /**
  124490. * Initialise the soft body vertices to match its object's (mesh) vertices
  124491. * Softbody vertices (nodes) are in world space and to match this
  124492. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124493. * @param impostor to create the softbody for
  124494. */
  124495. private _softVertexData;
  124496. /**
  124497. * Create an impostor's soft body
  124498. * @param impostor to create the softbody for
  124499. */
  124500. private _createSoftbody;
  124501. /**
  124502. * Create cloth for an impostor
  124503. * @param impostor to create the softbody for
  124504. */
  124505. private _createCloth;
  124506. /**
  124507. * Create rope for an impostor
  124508. * @param impostor to create the softbody for
  124509. */
  124510. private _createRope;
  124511. /**
  124512. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124513. * @param impostor to create the custom physics shape for
  124514. */
  124515. private _createCustom;
  124516. private _addHullVerts;
  124517. private _createShape;
  124518. /**
  124519. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124520. * @param impostor imposter containing the physics body and babylon object
  124521. */
  124522. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124523. /**
  124524. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124525. * @param impostor imposter containing the physics body and babylon object
  124526. * @param newPosition new position
  124527. * @param newRotation new rotation
  124528. */
  124529. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124530. /**
  124531. * If this plugin is supported
  124532. * @returns true if its supported
  124533. */
  124534. isSupported(): boolean;
  124535. /**
  124536. * Sets the linear velocity of the physics body
  124537. * @param impostor imposter to set the velocity on
  124538. * @param velocity velocity to set
  124539. */
  124540. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124541. /**
  124542. * Sets the angular velocity of the physics body
  124543. * @param impostor imposter to set the velocity on
  124544. * @param velocity velocity to set
  124545. */
  124546. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124547. /**
  124548. * gets the linear velocity
  124549. * @param impostor imposter to get linear velocity from
  124550. * @returns linear velocity
  124551. */
  124552. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124553. /**
  124554. * gets the angular velocity
  124555. * @param impostor imposter to get angular velocity from
  124556. * @returns angular velocity
  124557. */
  124558. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124559. /**
  124560. * Sets the mass of physics body
  124561. * @param impostor imposter to set the mass on
  124562. * @param mass mass to set
  124563. */
  124564. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124565. /**
  124566. * Gets the mass of the physics body
  124567. * @param impostor imposter to get the mass from
  124568. * @returns mass
  124569. */
  124570. getBodyMass(impostor: PhysicsImpostor): number;
  124571. /**
  124572. * Gets friction of the impostor
  124573. * @param impostor impostor to get friction from
  124574. * @returns friction value
  124575. */
  124576. getBodyFriction(impostor: PhysicsImpostor): number;
  124577. /**
  124578. * Sets friction of the impostor
  124579. * @param impostor impostor to set friction on
  124580. * @param friction friction value
  124581. */
  124582. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124583. /**
  124584. * Gets restitution of the impostor
  124585. * @param impostor impostor to get restitution from
  124586. * @returns restitution value
  124587. */
  124588. getBodyRestitution(impostor: PhysicsImpostor): number;
  124589. /**
  124590. * Sets resitution of the impostor
  124591. * @param impostor impostor to set resitution on
  124592. * @param restitution resitution value
  124593. */
  124594. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124595. /**
  124596. * Gets pressure inside the impostor
  124597. * @param impostor impostor to get pressure from
  124598. * @returns pressure value
  124599. */
  124600. getBodyPressure(impostor: PhysicsImpostor): number;
  124601. /**
  124602. * Sets pressure inside a soft body impostor
  124603. * Cloth and rope must remain 0 pressure
  124604. * @param impostor impostor to set pressure on
  124605. * @param pressure pressure value
  124606. */
  124607. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124608. /**
  124609. * Gets stiffness of the impostor
  124610. * @param impostor impostor to get stiffness from
  124611. * @returns pressure value
  124612. */
  124613. getBodyStiffness(impostor: PhysicsImpostor): number;
  124614. /**
  124615. * Sets stiffness of the impostor
  124616. * @param impostor impostor to set stiffness on
  124617. * @param stiffness stiffness value from 0 to 1
  124618. */
  124619. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124620. /**
  124621. * Gets velocityIterations of the impostor
  124622. * @param impostor impostor to get velocity iterations from
  124623. * @returns velocityIterations value
  124624. */
  124625. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124626. /**
  124627. * Sets velocityIterations of the impostor
  124628. * @param impostor impostor to set velocity iterations on
  124629. * @param velocityIterations velocityIterations value
  124630. */
  124631. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124632. /**
  124633. * Gets positionIterations of the impostor
  124634. * @param impostor impostor to get position iterations from
  124635. * @returns positionIterations value
  124636. */
  124637. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124638. /**
  124639. * Sets positionIterations of the impostor
  124640. * @param impostor impostor to set position on
  124641. * @param positionIterations positionIterations value
  124642. */
  124643. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124644. /**
  124645. * Append an anchor to a cloth object
  124646. * @param impostor is the cloth impostor to add anchor to
  124647. * @param otherImpostor is the rigid impostor to anchor to
  124648. * @param width ratio across width from 0 to 1
  124649. * @param height ratio up height from 0 to 1
  124650. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124651. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124652. */
  124653. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124654. /**
  124655. * Append an hook to a rope object
  124656. * @param impostor is the rope impostor to add hook to
  124657. * @param otherImpostor is the rigid impostor to hook to
  124658. * @param length ratio along the rope from 0 to 1
  124659. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124660. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124661. */
  124662. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124663. /**
  124664. * Sleeps the physics body and stops it from being active
  124665. * @param impostor impostor to sleep
  124666. */
  124667. sleepBody(impostor: PhysicsImpostor): void;
  124668. /**
  124669. * Activates the physics body
  124670. * @param impostor impostor to activate
  124671. */
  124672. wakeUpBody(impostor: PhysicsImpostor): void;
  124673. /**
  124674. * Updates the distance parameters of the joint
  124675. * @param joint joint to update
  124676. * @param maxDistance maximum distance of the joint
  124677. * @param minDistance minimum distance of the joint
  124678. */
  124679. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124680. /**
  124681. * Sets a motor on the joint
  124682. * @param joint joint to set motor on
  124683. * @param speed speed of the motor
  124684. * @param maxForce maximum force of the motor
  124685. * @param motorIndex index of the motor
  124686. */
  124687. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124688. /**
  124689. * Sets the motors limit
  124690. * @param joint joint to set limit on
  124691. * @param upperLimit upper limit
  124692. * @param lowerLimit lower limit
  124693. */
  124694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124695. /**
  124696. * Syncs the position and rotation of a mesh with the impostor
  124697. * @param mesh mesh to sync
  124698. * @param impostor impostor to update the mesh with
  124699. */
  124700. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124701. /**
  124702. * Gets the radius of the impostor
  124703. * @param impostor impostor to get radius from
  124704. * @returns the radius
  124705. */
  124706. getRadius(impostor: PhysicsImpostor): number;
  124707. /**
  124708. * Gets the box size of the impostor
  124709. * @param impostor impostor to get box size from
  124710. * @param result the resulting box size
  124711. */
  124712. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124713. /**
  124714. * Disposes of the impostor
  124715. */
  124716. dispose(): void;
  124717. /**
  124718. * Does a raycast in the physics world
  124719. * @param from when should the ray start?
  124720. * @param to when should the ray end?
  124721. * @returns PhysicsRaycastResult
  124722. */
  124723. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124724. }
  124725. }
  124726. declare module BABYLON {
  124727. interface AbstractScene {
  124728. /**
  124729. * The list of reflection probes added to the scene
  124730. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124731. */
  124732. reflectionProbes: Array<ReflectionProbe>;
  124733. /**
  124734. * Removes the given reflection probe from this scene.
  124735. * @param toRemove The reflection probe to remove
  124736. * @returns The index of the removed reflection probe
  124737. */
  124738. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124739. /**
  124740. * Adds the given reflection probe to this scene.
  124741. * @param newReflectionProbe The reflection probe to add
  124742. */
  124743. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124744. }
  124745. /**
  124746. * Class used to generate realtime reflection / refraction cube textures
  124747. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124748. */
  124749. export class ReflectionProbe {
  124750. /** defines the name of the probe */
  124751. name: string;
  124752. private _scene;
  124753. private _renderTargetTexture;
  124754. private _projectionMatrix;
  124755. private _viewMatrix;
  124756. private _target;
  124757. private _add;
  124758. private _attachedMesh;
  124759. private _invertYAxis;
  124760. /** Gets or sets probe position (center of the cube map) */
  124761. position: Vector3;
  124762. /**
  124763. * Creates a new reflection probe
  124764. * @param name defines the name of the probe
  124765. * @param size defines the texture resolution (for each face)
  124766. * @param scene defines the hosting scene
  124767. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124768. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124769. */
  124770. constructor(
  124771. /** defines the name of the probe */
  124772. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124773. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124774. get samples(): number;
  124775. set samples(value: number);
  124776. /** Gets or sets the refresh rate to use (on every frame by default) */
  124777. get refreshRate(): number;
  124778. set refreshRate(value: number);
  124779. /**
  124780. * Gets the hosting scene
  124781. * @returns a Scene
  124782. */
  124783. getScene(): Scene;
  124784. /** Gets the internal CubeTexture used to render to */
  124785. get cubeTexture(): RenderTargetTexture;
  124786. /** Gets the list of meshes to render */
  124787. get renderList(): Nullable<AbstractMesh[]>;
  124788. /**
  124789. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124790. * @param mesh defines the mesh to attach to
  124791. */
  124792. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124793. /**
  124794. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124795. * @param renderingGroupId The rendering group id corresponding to its index
  124796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124797. */
  124798. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124799. /**
  124800. * Clean all associated resources
  124801. */
  124802. dispose(): void;
  124803. /**
  124804. * Converts the reflection probe information to a readable string for debug purpose.
  124805. * @param fullDetails Supports for multiple levels of logging within scene loading
  124806. * @returns the human readable reflection probe info
  124807. */
  124808. toString(fullDetails?: boolean): string;
  124809. /**
  124810. * Get the class name of the relfection probe.
  124811. * @returns "ReflectionProbe"
  124812. */
  124813. getClassName(): string;
  124814. /**
  124815. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124816. * @returns The JSON representation of the texture
  124817. */
  124818. serialize(): any;
  124819. /**
  124820. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124821. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124822. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124823. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124824. * @returns The parsed reflection probe if successful
  124825. */
  124826. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124827. }
  124828. }
  124829. declare module BABYLON {
  124830. /** @hidden */
  124831. export var _BabylonLoaderRegistered: boolean;
  124832. /**
  124833. * Helps setting up some configuration for the babylon file loader.
  124834. */
  124835. export class BabylonFileLoaderConfiguration {
  124836. /**
  124837. * The loader does not allow injecting custom physix engine into the plugins.
  124838. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124839. * So you could set this variable to your engine import to make it work.
  124840. */
  124841. static LoaderInjectedPhysicsEngine: any;
  124842. }
  124843. }
  124844. declare module BABYLON {
  124845. /**
  124846. * The Physically based simple base material of BJS.
  124847. *
  124848. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124849. * It is used as the base class for both the specGloss and metalRough conventions.
  124850. */
  124851. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124852. /**
  124853. * Number of Simultaneous lights allowed on the material.
  124854. */
  124855. maxSimultaneousLights: number;
  124856. /**
  124857. * If sets to true, disables all the lights affecting the material.
  124858. */
  124859. disableLighting: boolean;
  124860. /**
  124861. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124862. */
  124863. environmentTexture: BaseTexture;
  124864. /**
  124865. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124866. */
  124867. invertNormalMapX: boolean;
  124868. /**
  124869. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124870. */
  124871. invertNormalMapY: boolean;
  124872. /**
  124873. * Normal map used in the model.
  124874. */
  124875. normalTexture: BaseTexture;
  124876. /**
  124877. * Emissivie color used to self-illuminate the model.
  124878. */
  124879. emissiveColor: Color3;
  124880. /**
  124881. * Emissivie texture used to self-illuminate the model.
  124882. */
  124883. emissiveTexture: BaseTexture;
  124884. /**
  124885. * Occlusion Channel Strenght.
  124886. */
  124887. occlusionStrength: number;
  124888. /**
  124889. * Occlusion Texture of the material (adding extra occlusion effects).
  124890. */
  124891. occlusionTexture: BaseTexture;
  124892. /**
  124893. * Defines the alpha limits in alpha test mode.
  124894. */
  124895. alphaCutOff: number;
  124896. /**
  124897. * Gets the current double sided mode.
  124898. */
  124899. get doubleSided(): boolean;
  124900. /**
  124901. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124902. */
  124903. set doubleSided(value: boolean);
  124904. /**
  124905. * Stores the pre-calculated light information of a mesh in a texture.
  124906. */
  124907. lightmapTexture: BaseTexture;
  124908. /**
  124909. * If true, the light map contains occlusion information instead of lighting info.
  124910. */
  124911. useLightmapAsShadowmap: boolean;
  124912. /**
  124913. * Instantiates a new PBRMaterial instance.
  124914. *
  124915. * @param name The material name
  124916. * @param scene The scene the material will be use in.
  124917. */
  124918. constructor(name: string, scene: Scene);
  124919. getClassName(): string;
  124920. }
  124921. }
  124922. declare module BABYLON {
  124923. /**
  124924. * The PBR material of BJS following the metal roughness convention.
  124925. *
  124926. * This fits to the PBR convention in the GLTF definition:
  124927. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124928. */
  124929. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124930. /**
  124931. * The base color has two different interpretations depending on the value of metalness.
  124932. * When the material is a metal, the base color is the specific measured reflectance value
  124933. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124934. * of the material.
  124935. */
  124936. baseColor: Color3;
  124937. /**
  124938. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124939. * well as opacity information in the alpha channel.
  124940. */
  124941. baseTexture: BaseTexture;
  124942. /**
  124943. * Specifies the metallic scalar value of the material.
  124944. * Can also be used to scale the metalness values of the metallic texture.
  124945. */
  124946. metallic: number;
  124947. /**
  124948. * Specifies the roughness scalar value of the material.
  124949. * Can also be used to scale the roughness values of the metallic texture.
  124950. */
  124951. roughness: number;
  124952. /**
  124953. * Texture containing both the metallic value in the B channel and the
  124954. * roughness value in the G channel to keep better precision.
  124955. */
  124956. metallicRoughnessTexture: BaseTexture;
  124957. /**
  124958. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124959. *
  124960. * @param name The material name
  124961. * @param scene The scene the material will be use in.
  124962. */
  124963. constructor(name: string, scene: Scene);
  124964. /**
  124965. * Return the currrent class name of the material.
  124966. */
  124967. getClassName(): string;
  124968. /**
  124969. * Makes a duplicate of the current material.
  124970. * @param name - name to use for the new material.
  124971. */
  124972. clone(name: string): PBRMetallicRoughnessMaterial;
  124973. /**
  124974. * Serialize the material to a parsable JSON object.
  124975. */
  124976. serialize(): any;
  124977. /**
  124978. * Parses a JSON object correponding to the serialize function.
  124979. */
  124980. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124981. }
  124982. }
  124983. declare module BABYLON {
  124984. /**
  124985. * The PBR material of BJS following the specular glossiness convention.
  124986. *
  124987. * This fits to the PBR convention in the GLTF definition:
  124988. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124989. */
  124990. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124991. /**
  124992. * Specifies the diffuse color of the material.
  124993. */
  124994. diffuseColor: Color3;
  124995. /**
  124996. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124997. * channel.
  124998. */
  124999. diffuseTexture: BaseTexture;
  125000. /**
  125001. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  125002. */
  125003. specularColor: Color3;
  125004. /**
  125005. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  125006. */
  125007. glossiness: number;
  125008. /**
  125009. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  125010. */
  125011. specularGlossinessTexture: BaseTexture;
  125012. /**
  125013. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  125014. *
  125015. * @param name The material name
  125016. * @param scene The scene the material will be use in.
  125017. */
  125018. constructor(name: string, scene: Scene);
  125019. /**
  125020. * Return the currrent class name of the material.
  125021. */
  125022. getClassName(): string;
  125023. /**
  125024. * Makes a duplicate of the current material.
  125025. * @param name - name to use for the new material.
  125026. */
  125027. clone(name: string): PBRSpecularGlossinessMaterial;
  125028. /**
  125029. * Serialize the material to a parsable JSON object.
  125030. */
  125031. serialize(): any;
  125032. /**
  125033. * Parses a JSON object correponding to the serialize function.
  125034. */
  125035. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  125036. }
  125037. }
  125038. declare module BABYLON {
  125039. /**
  125040. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  125041. * It can help converting any input color in a desired output one. This can then be used to create effects
  125042. * from sepia, black and white to sixties or futuristic rendering...
  125043. *
  125044. * The only supported format is currently 3dl.
  125045. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  125046. */
  125047. export class ColorGradingTexture extends BaseTexture {
  125048. /**
  125049. * The current texture matrix. (will always be identity in color grading texture)
  125050. */
  125051. private _textureMatrix;
  125052. /**
  125053. * The texture URL.
  125054. */
  125055. url: string;
  125056. /**
  125057. * Empty line regex stored for GC.
  125058. */
  125059. private static _noneEmptyLineRegex;
  125060. private _engine;
  125061. /**
  125062. * Instantiates a ColorGradingTexture from the following parameters.
  125063. *
  125064. * @param url The location of the color gradind data (currently only supporting 3dl)
  125065. * @param scene The scene the texture will be used in
  125066. */
  125067. constructor(url: string, scene: Scene);
  125068. /**
  125069. * Returns the texture matrix used in most of the material.
  125070. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  125071. */
  125072. getTextureMatrix(): Matrix;
  125073. /**
  125074. * Occurs when the file being loaded is a .3dl LUT file.
  125075. */
  125076. private load3dlTexture;
  125077. /**
  125078. * Starts the loading process of the texture.
  125079. */
  125080. private loadTexture;
  125081. /**
  125082. * Clones the color gradind texture.
  125083. */
  125084. clone(): ColorGradingTexture;
  125085. /**
  125086. * Called during delayed load for textures.
  125087. */
  125088. delayLoad(): void;
  125089. /**
  125090. * Parses a color grading texture serialized by Babylon.
  125091. * @param parsedTexture The texture information being parsedTexture
  125092. * @param scene The scene to load the texture in
  125093. * @param rootUrl The root url of the data assets to load
  125094. * @return A color gradind texture
  125095. */
  125096. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  125097. /**
  125098. * Serializes the LUT texture to json format.
  125099. */
  125100. serialize(): any;
  125101. }
  125102. }
  125103. declare module BABYLON {
  125104. /**
  125105. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  125106. */
  125107. export class EquiRectangularCubeTexture extends BaseTexture {
  125108. /** The six faces of the cube. */
  125109. private static _FacesMapping;
  125110. private _noMipmap;
  125111. private _onLoad;
  125112. private _onError;
  125113. /** The size of the cubemap. */
  125114. private _size;
  125115. /** The buffer of the image. */
  125116. private _buffer;
  125117. /** The width of the input image. */
  125118. private _width;
  125119. /** The height of the input image. */
  125120. private _height;
  125121. /** The URL to the image. */
  125122. url: string;
  125123. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  125124. coordinatesMode: number;
  125125. /**
  125126. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  125127. * @param url The location of the image
  125128. * @param scene The scene the texture will be used in
  125129. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125130. * @param noMipmap Forces to not generate the mipmap if true
  125131. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125132. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125133. * @param onLoad — defines a callback called when texture is loaded
  125134. * @param onError — defines a callback called if there is an error
  125135. */
  125136. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  125137. /**
  125138. * Load the image data, by putting the image on a canvas and extracting its buffer.
  125139. */
  125140. private loadImage;
  125141. /**
  125142. * Convert the image buffer into a cubemap and create a CubeTexture.
  125143. */
  125144. private loadTexture;
  125145. /**
  125146. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  125147. * @param buffer The ArrayBuffer that should be converted.
  125148. * @returns The buffer as Float32Array.
  125149. */
  125150. private getFloat32ArrayFromArrayBuffer;
  125151. /**
  125152. * Get the current class name of the texture useful for serialization or dynamic coding.
  125153. * @returns "EquiRectangularCubeTexture"
  125154. */
  125155. getClassName(): string;
  125156. /**
  125157. * Create a clone of the current EquiRectangularCubeTexture and return it.
  125158. * @returns A clone of the current EquiRectangularCubeTexture.
  125159. */
  125160. clone(): EquiRectangularCubeTexture;
  125161. }
  125162. }
  125163. declare module BABYLON {
  125164. /**
  125165. * Based on jsTGALoader - Javascript loader for TGA file
  125166. * By Vincent Thibault
  125167. * @see http://blog.robrowser.com/javascript-tga-loader.html
  125168. */
  125169. export class TGATools {
  125170. private static _TYPE_INDEXED;
  125171. private static _TYPE_RGB;
  125172. private static _TYPE_GREY;
  125173. private static _TYPE_RLE_INDEXED;
  125174. private static _TYPE_RLE_RGB;
  125175. private static _TYPE_RLE_GREY;
  125176. private static _ORIGIN_MASK;
  125177. private static _ORIGIN_SHIFT;
  125178. private static _ORIGIN_BL;
  125179. private static _ORIGIN_BR;
  125180. private static _ORIGIN_UL;
  125181. private static _ORIGIN_UR;
  125182. /**
  125183. * Gets the header of a TGA file
  125184. * @param data defines the TGA data
  125185. * @returns the header
  125186. */
  125187. static GetTGAHeader(data: Uint8Array): any;
  125188. /**
  125189. * Uploads TGA content to a Babylon Texture
  125190. * @hidden
  125191. */
  125192. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  125193. /** @hidden */
  125194. 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;
  125195. /** @hidden */
  125196. 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;
  125197. /** @hidden */
  125198. 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;
  125199. /** @hidden */
  125200. 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;
  125201. /** @hidden */
  125202. 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;
  125203. /** @hidden */
  125204. 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;
  125205. }
  125206. }
  125207. declare module BABYLON {
  125208. /**
  125209. * Implementation of the TGA Texture Loader.
  125210. * @hidden
  125211. */
  125212. export class _TGATextureLoader implements IInternalTextureLoader {
  125213. /**
  125214. * Defines wether the loader supports cascade loading the different faces.
  125215. */
  125216. readonly supportCascades: boolean;
  125217. /**
  125218. * This returns if the loader support the current file information.
  125219. * @param extension defines the file extension of the file being loaded
  125220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125221. * @param fallback defines the fallback internal texture if any
  125222. * @param isBase64 defines whether the texture is encoded as a base64
  125223. * @param isBuffer defines whether the texture data are stored as a buffer
  125224. * @returns true if the loader can load the specified file
  125225. */
  125226. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125227. /**
  125228. * Transform the url before loading if required.
  125229. * @param rootUrl the url of the texture
  125230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125231. * @returns the transformed texture
  125232. */
  125233. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125234. /**
  125235. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125236. * @param rootUrl the url of the texture
  125237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125238. * @returns the fallback texture
  125239. */
  125240. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125241. /**
  125242. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125243. * @param data contains the texture data
  125244. * @param texture defines the BabylonJS internal texture
  125245. * @param createPolynomials will be true if polynomials have been requested
  125246. * @param onLoad defines the callback to trigger once the texture is ready
  125247. * @param onError defines the callback to trigger in case of error
  125248. */
  125249. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125250. /**
  125251. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125252. * @param data contains the texture data
  125253. * @param texture defines the BabylonJS internal texture
  125254. * @param callback defines the method to call once ready to upload
  125255. */
  125256. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125257. }
  125258. }
  125259. declare module BABYLON {
  125260. /**
  125261. * Info about the .basis files
  125262. */
  125263. class BasisFileInfo {
  125264. /**
  125265. * If the file has alpha
  125266. */
  125267. hasAlpha: boolean;
  125268. /**
  125269. * Info about each image of the basis file
  125270. */
  125271. images: Array<{
  125272. levels: Array<{
  125273. width: number;
  125274. height: number;
  125275. transcodedPixels: ArrayBufferView;
  125276. }>;
  125277. }>;
  125278. }
  125279. /**
  125280. * Result of transcoding a basis file
  125281. */
  125282. class TranscodeResult {
  125283. /**
  125284. * Info about the .basis file
  125285. */
  125286. fileInfo: BasisFileInfo;
  125287. /**
  125288. * Format to use when loading the file
  125289. */
  125290. format: number;
  125291. }
  125292. /**
  125293. * Configuration options for the Basis transcoder
  125294. */
  125295. export class BasisTranscodeConfiguration {
  125296. /**
  125297. * Supported compression formats used to determine the supported output format of the transcoder
  125298. */
  125299. supportedCompressionFormats?: {
  125300. /**
  125301. * etc1 compression format
  125302. */
  125303. etc1?: boolean;
  125304. /**
  125305. * s3tc compression format
  125306. */
  125307. s3tc?: boolean;
  125308. /**
  125309. * pvrtc compression format
  125310. */
  125311. pvrtc?: boolean;
  125312. /**
  125313. * etc2 compression format
  125314. */
  125315. etc2?: boolean;
  125316. };
  125317. /**
  125318. * If mipmap levels should be loaded for transcoded images (Default: true)
  125319. */
  125320. loadMipmapLevels?: boolean;
  125321. /**
  125322. * Index of a single image to load (Default: all images)
  125323. */
  125324. loadSingleImage?: number;
  125325. }
  125326. /**
  125327. * Used to load .Basis files
  125328. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125329. */
  125330. export class BasisTools {
  125331. private static _IgnoreSupportedFormats;
  125332. /**
  125333. * URL to use when loading the basis transcoder
  125334. */
  125335. static JSModuleURL: string;
  125336. /**
  125337. * URL to use when loading the wasm module for the transcoder
  125338. */
  125339. static WasmModuleURL: string;
  125340. /**
  125341. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125342. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125343. * @returns internal format corresponding to the Basis format
  125344. */
  125345. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125346. private static _WorkerPromise;
  125347. private static _Worker;
  125348. private static _actionId;
  125349. private static _CreateWorkerAsync;
  125350. /**
  125351. * Transcodes a loaded image file to compressed pixel data
  125352. * @param imageData image data to transcode
  125353. * @param config configuration options for the transcoding
  125354. * @returns a promise resulting in the transcoded image
  125355. */
  125356. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125357. /**
  125358. * Loads a texture from the transcode result
  125359. * @param texture texture load to
  125360. * @param transcodeResult the result of transcoding the basis file to load from
  125361. */
  125362. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125363. }
  125364. }
  125365. declare module BABYLON {
  125366. /**
  125367. * Loader for .basis file format
  125368. */
  125369. export class _BasisTextureLoader implements IInternalTextureLoader {
  125370. /**
  125371. * Defines whether the loader supports cascade loading the different faces.
  125372. */
  125373. readonly supportCascades: boolean;
  125374. /**
  125375. * This returns if the loader support the current file information.
  125376. * @param extension defines the file extension of the file being loaded
  125377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125378. * @param fallback defines the fallback internal texture if any
  125379. * @param isBase64 defines whether the texture is encoded as a base64
  125380. * @param isBuffer defines whether the texture data are stored as a buffer
  125381. * @returns true if the loader can load the specified file
  125382. */
  125383. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125384. /**
  125385. * Transform the url before loading if required.
  125386. * @param rootUrl the url of the texture
  125387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125388. * @returns the transformed texture
  125389. */
  125390. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125391. /**
  125392. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125393. * @param rootUrl the url of the texture
  125394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125395. * @returns the fallback texture
  125396. */
  125397. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125398. /**
  125399. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125400. * @param data contains the texture data
  125401. * @param texture defines the BabylonJS internal texture
  125402. * @param createPolynomials will be true if polynomials have been requested
  125403. * @param onLoad defines the callback to trigger once the texture is ready
  125404. * @param onError defines the callback to trigger in case of error
  125405. */
  125406. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125407. /**
  125408. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125409. * @param data contains the texture data
  125410. * @param texture defines the BabylonJS internal texture
  125411. * @param callback defines the method to call once ready to upload
  125412. */
  125413. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125414. }
  125415. }
  125416. declare module BABYLON {
  125417. /**
  125418. * 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.
  125419. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125420. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125421. */
  125422. export class CustomProceduralTexture extends ProceduralTexture {
  125423. private _animate;
  125424. private _time;
  125425. private _config;
  125426. private _texturePath;
  125427. /**
  125428. * Instantiates a new Custom Procedural Texture.
  125429. * 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.
  125430. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125431. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125432. * @param name Define the name of the texture
  125433. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125434. * @param size Define the size of the texture to create
  125435. * @param scene Define the scene the texture belongs to
  125436. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125437. * @param generateMipMaps Define if the texture should creates mip maps or not
  125438. */
  125439. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125440. private _loadJson;
  125441. /**
  125442. * Is the texture ready to be used ? (rendered at least once)
  125443. * @returns true if ready, otherwise, false.
  125444. */
  125445. isReady(): boolean;
  125446. /**
  125447. * Render the texture to its associated render target.
  125448. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125449. */
  125450. render(useCameraPostProcess?: boolean): void;
  125451. /**
  125452. * Update the list of dependant textures samplers in the shader.
  125453. */
  125454. updateTextures(): void;
  125455. /**
  125456. * Update the uniform values of the procedural texture in the shader.
  125457. */
  125458. updateShaderUniforms(): void;
  125459. /**
  125460. * Define if the texture animates or not.
  125461. */
  125462. get animate(): boolean;
  125463. set animate(value: boolean);
  125464. }
  125465. }
  125466. declare module BABYLON {
  125467. /** @hidden */
  125468. export var noisePixelShader: {
  125469. name: string;
  125470. shader: string;
  125471. };
  125472. }
  125473. declare module BABYLON {
  125474. /**
  125475. * Class used to generate noise procedural textures
  125476. */
  125477. export class NoiseProceduralTexture extends ProceduralTexture {
  125478. private _time;
  125479. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125480. brightness: number;
  125481. /** Defines the number of octaves to process */
  125482. octaves: number;
  125483. /** Defines the level of persistence (0.8 by default) */
  125484. persistence: number;
  125485. /** Gets or sets animation speed factor (default is 1) */
  125486. animationSpeedFactor: number;
  125487. /**
  125488. * Creates a new NoiseProceduralTexture
  125489. * @param name defines the name fo the texture
  125490. * @param size defines the size of the texture (default is 256)
  125491. * @param scene defines the hosting scene
  125492. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125493. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125494. */
  125495. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125496. private _updateShaderUniforms;
  125497. protected _getDefines(): string;
  125498. /** Generate the current state of the procedural texture */
  125499. render(useCameraPostProcess?: boolean): void;
  125500. /**
  125501. * Serializes this noise procedural texture
  125502. * @returns a serialized noise procedural texture object
  125503. */
  125504. serialize(): any;
  125505. /**
  125506. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125507. * @param parsedTexture defines parsed texture data
  125508. * @param scene defines the current scene
  125509. * @param rootUrl defines the root URL containing noise procedural texture information
  125510. * @returns a parsed NoiseProceduralTexture
  125511. */
  125512. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125513. }
  125514. }
  125515. declare module BABYLON {
  125516. /**
  125517. * Raw cube texture where the raw buffers are passed in
  125518. */
  125519. export class RawCubeTexture extends CubeTexture {
  125520. /**
  125521. * Creates a cube texture where the raw buffers are passed in.
  125522. * @param scene defines the scene the texture is attached to
  125523. * @param data defines the array of data to use to create each face
  125524. * @param size defines the size of the textures
  125525. * @param format defines the format of the data
  125526. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125527. * @param generateMipMaps defines if the engine should generate the mip levels
  125528. * @param invertY defines if data must be stored with Y axis inverted
  125529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125530. * @param compression defines the compression used (null by default)
  125531. */
  125532. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125533. /**
  125534. * Updates the raw cube texture.
  125535. * @param data defines the data to store
  125536. * @param format defines the data format
  125537. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125538. * @param invertY defines if data must be stored with Y axis inverted
  125539. * @param compression defines the compression used (null by default)
  125540. * @param level defines which level of the texture to update
  125541. */
  125542. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125543. /**
  125544. * Updates a raw cube texture with RGBD encoded data.
  125545. * @param data defines the array of data [mipmap][face] to use to create each face
  125546. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125549. * @returns a promsie that resolves when the operation is complete
  125550. */
  125551. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125552. /**
  125553. * Clones the raw cube texture.
  125554. * @return a new cube texture
  125555. */
  125556. clone(): CubeTexture;
  125557. /** @hidden */
  125558. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125559. }
  125560. }
  125561. declare module BABYLON {
  125562. /**
  125563. * Class used to store 3D textures containing user data
  125564. */
  125565. export class RawTexture3D extends Texture {
  125566. /** Gets or sets the texture format to use */
  125567. format: number;
  125568. private _engine;
  125569. /**
  125570. * Create a new RawTexture3D
  125571. * @param data defines the data of the texture
  125572. * @param width defines the width of the texture
  125573. * @param height defines the height of the texture
  125574. * @param depth defines the depth of the texture
  125575. * @param format defines the texture format to use
  125576. * @param scene defines the hosting scene
  125577. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125578. * @param invertY defines if texture must be stored with Y axis inverted
  125579. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125580. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125581. */
  125582. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125583. /** Gets or sets the texture format to use */
  125584. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125585. /**
  125586. * Update the texture with new data
  125587. * @param data defines the data to store in the texture
  125588. */
  125589. update(data: ArrayBufferView): void;
  125590. }
  125591. }
  125592. declare module BABYLON {
  125593. /**
  125594. * Class used to store 2D array textures containing user data
  125595. */
  125596. export class RawTexture2DArray extends Texture {
  125597. /** Gets or sets the texture format to use */
  125598. format: number;
  125599. private _engine;
  125600. /**
  125601. * Create a new RawTexture2DArray
  125602. * @param data defines the data of the texture
  125603. * @param width defines the width of the texture
  125604. * @param height defines the height of the texture
  125605. * @param depth defines the number of layers of the texture
  125606. * @param format defines the texture format to use
  125607. * @param scene defines the hosting scene
  125608. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125609. * @param invertY defines if texture must be stored with Y axis inverted
  125610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125612. */
  125613. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125614. /** Gets or sets the texture format to use */
  125615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125616. /**
  125617. * Update the texture with new data
  125618. * @param data defines the data to store in the texture
  125619. */
  125620. update(data: ArrayBufferView): void;
  125621. }
  125622. }
  125623. declare module BABYLON {
  125624. /**
  125625. * Creates a refraction texture used by refraction channel of the standard material.
  125626. * It is like a mirror but to see through a material.
  125627. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125628. */
  125629. export class RefractionTexture extends RenderTargetTexture {
  125630. /**
  125631. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125632. * 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.
  125633. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125634. */
  125635. refractionPlane: Plane;
  125636. /**
  125637. * Define how deep under the surface we should see.
  125638. */
  125639. depth: number;
  125640. /**
  125641. * Creates a refraction texture used by refraction channel of the standard material.
  125642. * It is like a mirror but to see through a material.
  125643. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125644. * @param name Define the texture name
  125645. * @param size Define the size of the underlying texture
  125646. * @param scene Define the scene the refraction belongs to
  125647. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125648. */
  125649. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125650. /**
  125651. * Clone the refraction texture.
  125652. * @returns the cloned texture
  125653. */
  125654. clone(): RefractionTexture;
  125655. /**
  125656. * Serialize the texture to a JSON representation you could use in Parse later on
  125657. * @returns the serialized JSON representation
  125658. */
  125659. serialize(): any;
  125660. }
  125661. }
  125662. declare module BABYLON {
  125663. /**
  125664. * Defines the options related to the creation of an HtmlElementTexture
  125665. */
  125666. export interface IHtmlElementTextureOptions {
  125667. /**
  125668. * Defines wether mip maps should be created or not.
  125669. */
  125670. generateMipMaps?: boolean;
  125671. /**
  125672. * Defines the sampling mode of the texture.
  125673. */
  125674. samplingMode?: number;
  125675. /**
  125676. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125677. */
  125678. engine: Nullable<ThinEngine>;
  125679. /**
  125680. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125681. */
  125682. scene: Nullable<Scene>;
  125683. }
  125684. /**
  125685. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125686. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125687. * is automatically managed.
  125688. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125689. * in your application.
  125690. *
  125691. * As the update is not automatic, you need to call them manually.
  125692. */
  125693. export class HtmlElementTexture extends BaseTexture {
  125694. /**
  125695. * The texture URL.
  125696. */
  125697. element: HTMLVideoElement | HTMLCanvasElement;
  125698. private static readonly DefaultOptions;
  125699. private _textureMatrix;
  125700. private _engine;
  125701. private _isVideo;
  125702. private _generateMipMaps;
  125703. private _samplingMode;
  125704. /**
  125705. * Instantiates a HtmlElementTexture from the following parameters.
  125706. *
  125707. * @param name Defines the name of the texture
  125708. * @param element Defines the video or canvas the texture is filled with
  125709. * @param options Defines the other none mandatory texture creation options
  125710. */
  125711. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125712. private _createInternalTexture;
  125713. /**
  125714. * Returns the texture matrix used in most of the material.
  125715. */
  125716. getTextureMatrix(): Matrix;
  125717. /**
  125718. * Updates the content of the texture.
  125719. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125720. */
  125721. update(invertY?: Nullable<boolean>): void;
  125722. }
  125723. }
  125724. declare module BABYLON {
  125725. /**
  125726. * Enum used to define the target of a block
  125727. */
  125728. export enum NodeMaterialBlockTargets {
  125729. /** Vertex shader */
  125730. Vertex = 1,
  125731. /** Fragment shader */
  125732. Fragment = 2,
  125733. /** Neutral */
  125734. Neutral = 4,
  125735. /** Vertex and Fragment */
  125736. VertexAndFragment = 3
  125737. }
  125738. }
  125739. declare module BABYLON {
  125740. /**
  125741. * Defines the kind of connection point for node based material
  125742. */
  125743. export enum NodeMaterialBlockConnectionPointTypes {
  125744. /** Float */
  125745. Float = 1,
  125746. /** Int */
  125747. Int = 2,
  125748. /** Vector2 */
  125749. Vector2 = 4,
  125750. /** Vector3 */
  125751. Vector3 = 8,
  125752. /** Vector4 */
  125753. Vector4 = 16,
  125754. /** Color3 */
  125755. Color3 = 32,
  125756. /** Color4 */
  125757. Color4 = 64,
  125758. /** Matrix */
  125759. Matrix = 128,
  125760. /** Detect type based on connection */
  125761. AutoDetect = 1024,
  125762. /** Output type that will be defined by input type */
  125763. BasedOnInput = 2048
  125764. }
  125765. }
  125766. declare module BABYLON {
  125767. /**
  125768. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125769. */
  125770. export enum NodeMaterialBlockConnectionPointMode {
  125771. /** Value is an uniform */
  125772. Uniform = 0,
  125773. /** Value is a mesh attribute */
  125774. Attribute = 1,
  125775. /** Value is a varying between vertex and fragment shaders */
  125776. Varying = 2,
  125777. /** Mode is undefined */
  125778. Undefined = 3
  125779. }
  125780. }
  125781. declare module BABYLON {
  125782. /**
  125783. * Enum used to define system values e.g. values automatically provided by the system
  125784. */
  125785. export enum NodeMaterialSystemValues {
  125786. /** World */
  125787. World = 1,
  125788. /** View */
  125789. View = 2,
  125790. /** Projection */
  125791. Projection = 3,
  125792. /** ViewProjection */
  125793. ViewProjection = 4,
  125794. /** WorldView */
  125795. WorldView = 5,
  125796. /** WorldViewProjection */
  125797. WorldViewProjection = 6,
  125798. /** CameraPosition */
  125799. CameraPosition = 7,
  125800. /** Fog Color */
  125801. FogColor = 8,
  125802. /** Delta time */
  125803. DeltaTime = 9
  125804. }
  125805. }
  125806. declare module BABYLON {
  125807. /**
  125808. * Root class for all node material optimizers
  125809. */
  125810. export class NodeMaterialOptimizer {
  125811. /**
  125812. * Function used to optimize a NodeMaterial graph
  125813. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125814. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125815. */
  125816. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125817. }
  125818. }
  125819. declare module BABYLON {
  125820. /**
  125821. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125822. */
  125823. export class TransformBlock extends NodeMaterialBlock {
  125824. /**
  125825. * Defines the value to use to complement W value to transform it to a Vector4
  125826. */
  125827. complementW: number;
  125828. /**
  125829. * Defines the value to use to complement z value to transform it to a Vector4
  125830. */
  125831. complementZ: number;
  125832. /**
  125833. * Creates a new TransformBlock
  125834. * @param name defines the block name
  125835. */
  125836. constructor(name: string);
  125837. /**
  125838. * Gets the current class name
  125839. * @returns the class name
  125840. */
  125841. getClassName(): string;
  125842. /**
  125843. * Gets the vector input
  125844. */
  125845. get vector(): NodeMaterialConnectionPoint;
  125846. /**
  125847. * Gets the output component
  125848. */
  125849. get output(): NodeMaterialConnectionPoint;
  125850. /**
  125851. * Gets the matrix transform input
  125852. */
  125853. get transform(): NodeMaterialConnectionPoint;
  125854. protected _buildBlock(state: NodeMaterialBuildState): this;
  125855. serialize(): any;
  125856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125857. protected _dumpPropertiesCode(): string;
  125858. }
  125859. }
  125860. declare module BABYLON {
  125861. /**
  125862. * Block used to output the vertex position
  125863. */
  125864. export class VertexOutputBlock extends NodeMaterialBlock {
  125865. /**
  125866. * Creates a new VertexOutputBlock
  125867. * @param name defines the block name
  125868. */
  125869. constructor(name: string);
  125870. /**
  125871. * Gets the current class name
  125872. * @returns the class name
  125873. */
  125874. getClassName(): string;
  125875. /**
  125876. * Gets the vector input component
  125877. */
  125878. get vector(): NodeMaterialConnectionPoint;
  125879. protected _buildBlock(state: NodeMaterialBuildState): this;
  125880. }
  125881. }
  125882. declare module BABYLON {
  125883. /**
  125884. * Block used to output the final color
  125885. */
  125886. export class FragmentOutputBlock extends NodeMaterialBlock {
  125887. /**
  125888. * Create a new FragmentOutputBlock
  125889. * @param name defines the block name
  125890. */
  125891. constructor(name: string);
  125892. /**
  125893. * Gets the current class name
  125894. * @returns the class name
  125895. */
  125896. getClassName(): string;
  125897. /**
  125898. * Gets the rgba input component
  125899. */
  125900. get rgba(): NodeMaterialConnectionPoint;
  125901. /**
  125902. * Gets the rgb input component
  125903. */
  125904. get rgb(): NodeMaterialConnectionPoint;
  125905. /**
  125906. * Gets the a input component
  125907. */
  125908. get a(): NodeMaterialConnectionPoint;
  125909. protected _buildBlock(state: NodeMaterialBuildState): this;
  125910. }
  125911. }
  125912. declare module BABYLON {
  125913. /**
  125914. * Block used to read a reflection texture from a sampler
  125915. */
  125916. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125917. private _define3DName;
  125918. private _defineCubicName;
  125919. private _defineExplicitName;
  125920. private _defineProjectionName;
  125921. private _defineLocalCubicName;
  125922. private _defineSphericalName;
  125923. private _definePlanarName;
  125924. private _defineEquirectangularName;
  125925. private _defineMirroredEquirectangularFixedName;
  125926. private _defineEquirectangularFixedName;
  125927. private _defineSkyboxName;
  125928. private _cubeSamplerName;
  125929. private _2DSamplerName;
  125930. private _positionUVWName;
  125931. private _directionWName;
  125932. private _reflectionCoordsName;
  125933. private _reflection2DCoordsName;
  125934. private _reflectionColorName;
  125935. private _reflectionMatrixName;
  125936. /**
  125937. * Gets or sets the texture associated with the node
  125938. */
  125939. texture: Nullable<BaseTexture>;
  125940. /**
  125941. * Create a new TextureBlock
  125942. * @param name defines the block name
  125943. */
  125944. constructor(name: string);
  125945. /**
  125946. * Gets the current class name
  125947. * @returns the class name
  125948. */
  125949. getClassName(): string;
  125950. /**
  125951. * Gets the world position input component
  125952. */
  125953. get position(): NodeMaterialConnectionPoint;
  125954. /**
  125955. * Gets the world position input component
  125956. */
  125957. get worldPosition(): NodeMaterialConnectionPoint;
  125958. /**
  125959. * Gets the world normal input component
  125960. */
  125961. get worldNormal(): NodeMaterialConnectionPoint;
  125962. /**
  125963. * Gets the world input component
  125964. */
  125965. get world(): NodeMaterialConnectionPoint;
  125966. /**
  125967. * Gets the camera (or eye) position component
  125968. */
  125969. get cameraPosition(): NodeMaterialConnectionPoint;
  125970. /**
  125971. * Gets the view input component
  125972. */
  125973. get view(): NodeMaterialConnectionPoint;
  125974. /**
  125975. * Gets the rgb output component
  125976. */
  125977. get rgb(): NodeMaterialConnectionPoint;
  125978. /**
  125979. * Gets the r output component
  125980. */
  125981. get r(): NodeMaterialConnectionPoint;
  125982. /**
  125983. * Gets the g output component
  125984. */
  125985. get g(): NodeMaterialConnectionPoint;
  125986. /**
  125987. * Gets the b output component
  125988. */
  125989. get b(): NodeMaterialConnectionPoint;
  125990. autoConfigure(material: NodeMaterial): void;
  125991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125992. isReady(): boolean;
  125993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125994. private _injectVertexCode;
  125995. private _writeOutput;
  125996. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125997. protected _dumpPropertiesCode(): string;
  125998. serialize(): any;
  125999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126000. }
  126001. }
  126002. declare module BABYLON {
  126003. /**
  126004. * Interface used to configure the node material editor
  126005. */
  126006. export interface INodeMaterialEditorOptions {
  126007. /** Define the URl to load node editor script */
  126008. editorURL?: string;
  126009. }
  126010. /** @hidden */
  126011. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  126012. /** BONES */
  126013. NUM_BONE_INFLUENCERS: number;
  126014. BonesPerMesh: number;
  126015. BONETEXTURE: boolean;
  126016. /** MORPH TARGETS */
  126017. MORPHTARGETS: boolean;
  126018. MORPHTARGETS_NORMAL: boolean;
  126019. MORPHTARGETS_TANGENT: boolean;
  126020. MORPHTARGETS_UV: boolean;
  126021. NUM_MORPH_INFLUENCERS: number;
  126022. /** IMAGE PROCESSING */
  126023. IMAGEPROCESSING: boolean;
  126024. VIGNETTE: boolean;
  126025. VIGNETTEBLENDMODEMULTIPLY: boolean;
  126026. VIGNETTEBLENDMODEOPAQUE: boolean;
  126027. TONEMAPPING: boolean;
  126028. TONEMAPPING_ACES: boolean;
  126029. CONTRAST: boolean;
  126030. EXPOSURE: boolean;
  126031. COLORCURVES: boolean;
  126032. COLORGRADING: boolean;
  126033. COLORGRADING3D: boolean;
  126034. SAMPLER3DGREENDEPTH: boolean;
  126035. SAMPLER3DBGRMAP: boolean;
  126036. IMAGEPROCESSINGPOSTPROCESS: boolean;
  126037. /** MISC. */
  126038. BUMPDIRECTUV: number;
  126039. constructor();
  126040. setValue(name: string, value: boolean): void;
  126041. }
  126042. /**
  126043. * Class used to configure NodeMaterial
  126044. */
  126045. export interface INodeMaterialOptions {
  126046. /**
  126047. * Defines if blocks should emit comments
  126048. */
  126049. emitComments: boolean;
  126050. }
  126051. /**
  126052. * Class used to create a node based material built by assembling shader blocks
  126053. */
  126054. export class NodeMaterial extends PushMaterial {
  126055. private static _BuildIdGenerator;
  126056. private _options;
  126057. private _vertexCompilationState;
  126058. private _fragmentCompilationState;
  126059. private _sharedData;
  126060. private _buildId;
  126061. private _buildWasSuccessful;
  126062. private _cachedWorldViewMatrix;
  126063. private _cachedWorldViewProjectionMatrix;
  126064. private _optimizers;
  126065. private _animationFrame;
  126066. /** Define the URl to load node editor script */
  126067. static EditorURL: string;
  126068. private BJSNODEMATERIALEDITOR;
  126069. /** Get the inspector from bundle or global */
  126070. private _getGlobalNodeMaterialEditor;
  126071. /**
  126072. * Gets or sets data used by visual editor
  126073. * @see https://nme.babylonjs.com
  126074. */
  126075. editorData: any;
  126076. /**
  126077. * 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)
  126078. */
  126079. ignoreAlpha: boolean;
  126080. /**
  126081. * Defines the maximum number of lights that can be used in the material
  126082. */
  126083. maxSimultaneousLights: number;
  126084. /**
  126085. * Observable raised when the material is built
  126086. */
  126087. onBuildObservable: Observable<NodeMaterial>;
  126088. /**
  126089. * Gets or sets the root nodes of the material vertex shader
  126090. */
  126091. _vertexOutputNodes: NodeMaterialBlock[];
  126092. /**
  126093. * Gets or sets the root nodes of the material fragment (pixel) shader
  126094. */
  126095. _fragmentOutputNodes: NodeMaterialBlock[];
  126096. /** Gets or sets options to control the node material overall behavior */
  126097. get options(): INodeMaterialOptions;
  126098. set options(options: INodeMaterialOptions);
  126099. /**
  126100. * Default configuration related to image processing available in the standard Material.
  126101. */
  126102. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126103. /**
  126104. * Gets the image processing configuration used either in this material.
  126105. */
  126106. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126107. /**
  126108. * Sets the Default image processing configuration used either in the this material.
  126109. *
  126110. * If sets to null, the scene one is in use.
  126111. */
  126112. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126113. /**
  126114. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  126115. */
  126116. attachedBlocks: NodeMaterialBlock[];
  126117. /**
  126118. * Create a new node based material
  126119. * @param name defines the material name
  126120. * @param scene defines the hosting scene
  126121. * @param options defines creation option
  126122. */
  126123. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  126124. /**
  126125. * Gets the current class name of the material e.g. "NodeMaterial"
  126126. * @returns the class name
  126127. */
  126128. getClassName(): string;
  126129. /**
  126130. * Keep track of the image processing observer to allow dispose and replace.
  126131. */
  126132. private _imageProcessingObserver;
  126133. /**
  126134. * Attaches a new image processing configuration to the Standard Material.
  126135. * @param configuration
  126136. */
  126137. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126138. /**
  126139. * Get a block by its name
  126140. * @param name defines the name of the block to retrieve
  126141. * @returns the required block or null if not found
  126142. */
  126143. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  126144. /**
  126145. * Get a block by its name
  126146. * @param predicate defines the predicate used to find the good candidate
  126147. * @returns the required block or null if not found
  126148. */
  126149. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  126150. /**
  126151. * Get an input block by its name
  126152. * @param predicate defines the predicate used to find the good candidate
  126153. * @returns the required input block or null if not found
  126154. */
  126155. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  126156. /**
  126157. * Gets the list of input blocks attached to this material
  126158. * @returns an array of InputBlocks
  126159. */
  126160. getInputBlocks(): InputBlock[];
  126161. /**
  126162. * Adds a new optimizer to the list of optimizers
  126163. * @param optimizer defines the optimizers to add
  126164. * @returns the current material
  126165. */
  126166. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126167. /**
  126168. * Remove an optimizer from the list of optimizers
  126169. * @param optimizer defines the optimizers to remove
  126170. * @returns the current material
  126171. */
  126172. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126173. /**
  126174. * Add a new block to the list of output nodes
  126175. * @param node defines the node to add
  126176. * @returns the current material
  126177. */
  126178. addOutputNode(node: NodeMaterialBlock): this;
  126179. /**
  126180. * Remove a block from the list of root nodes
  126181. * @param node defines the node to remove
  126182. * @returns the current material
  126183. */
  126184. removeOutputNode(node: NodeMaterialBlock): this;
  126185. private _addVertexOutputNode;
  126186. private _removeVertexOutputNode;
  126187. private _addFragmentOutputNode;
  126188. private _removeFragmentOutputNode;
  126189. /**
  126190. * Specifies if the material will require alpha blending
  126191. * @returns a boolean specifying if alpha blending is needed
  126192. */
  126193. needAlphaBlending(): boolean;
  126194. /**
  126195. * Specifies if this material should be rendered in alpha test mode
  126196. * @returns a boolean specifying if an alpha test is needed.
  126197. */
  126198. needAlphaTesting(): boolean;
  126199. private _initializeBlock;
  126200. private _resetDualBlocks;
  126201. /**
  126202. * Remove a block from the current node material
  126203. * @param block defines the block to remove
  126204. */
  126205. removeBlock(block: NodeMaterialBlock): void;
  126206. /**
  126207. * Build the material and generates the inner effect
  126208. * @param verbose defines if the build should log activity
  126209. */
  126210. build(verbose?: boolean): void;
  126211. /**
  126212. * Runs an otpimization phase to try to improve the shader code
  126213. */
  126214. optimize(): void;
  126215. private _prepareDefinesForAttributes;
  126216. /**
  126217. * Get if the submesh is ready to be used and all its information available.
  126218. * Child classes can use it to update shaders
  126219. * @param mesh defines the mesh to check
  126220. * @param subMesh defines which submesh to check
  126221. * @param useInstances specifies that instances should be used
  126222. * @returns a boolean indicating that the submesh is ready or not
  126223. */
  126224. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126225. /**
  126226. * Get a string representing the shaders built by the current node graph
  126227. */
  126228. get compiledShaders(): string;
  126229. /**
  126230. * Binds the world matrix to the material
  126231. * @param world defines the world transformation matrix
  126232. */
  126233. bindOnlyWorldMatrix(world: Matrix): void;
  126234. /**
  126235. * Binds the submesh to this material by preparing the effect and shader to draw
  126236. * @param world defines the world transformation matrix
  126237. * @param mesh defines the mesh containing the submesh
  126238. * @param subMesh defines the submesh to bind the material to
  126239. */
  126240. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126241. /**
  126242. * Gets the active textures from the material
  126243. * @returns an array of textures
  126244. */
  126245. getActiveTextures(): BaseTexture[];
  126246. /**
  126247. * Gets the list of texture blocks
  126248. * @returns an array of texture blocks
  126249. */
  126250. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126251. /**
  126252. * Specifies if the material uses a texture
  126253. * @param texture defines the texture to check against the material
  126254. * @returns a boolean specifying if the material uses the texture
  126255. */
  126256. hasTexture(texture: BaseTexture): boolean;
  126257. /**
  126258. * Disposes the material
  126259. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126260. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126261. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126262. */
  126263. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126264. /** Creates the node editor window. */
  126265. private _createNodeEditor;
  126266. /**
  126267. * Launch the node material editor
  126268. * @param config Define the configuration of the editor
  126269. * @return a promise fulfilled when the node editor is visible
  126270. */
  126271. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126272. /**
  126273. * Clear the current material
  126274. */
  126275. clear(): void;
  126276. /**
  126277. * Clear the current material and set it to a default state
  126278. */
  126279. setToDefault(): void;
  126280. /**
  126281. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126282. * @param url defines the url to load from
  126283. * @returns a promise that will fullfil when the material is fully loaded
  126284. */
  126285. loadAsync(url: string): Promise<void>;
  126286. private _gatherBlocks;
  126287. /**
  126288. * Generate a string containing the code declaration required to create an equivalent of this material
  126289. * @returns a string
  126290. */
  126291. generateCode(): string;
  126292. /**
  126293. * Serializes this material in a JSON representation
  126294. * @returns the serialized material object
  126295. */
  126296. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  126297. private _restoreConnections;
  126298. /**
  126299. * Clear the current graph and load a new one from a serialization object
  126300. * @param source defines the JSON representation of the material
  126301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126302. */
  126303. loadFromSerialization(source: any, rootUrl?: string): void;
  126304. /**
  126305. * Creates a node material from parsed material data
  126306. * @param source defines the JSON representation of the material
  126307. * @param scene defines the hosting scene
  126308. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126309. * @returns a new node material
  126310. */
  126311. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126312. /**
  126313. * Creates a new node material set to default basic configuration
  126314. * @param name defines the name of the material
  126315. * @param scene defines the hosting scene
  126316. * @returns a new NodeMaterial
  126317. */
  126318. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126319. }
  126320. }
  126321. declare module BABYLON {
  126322. /**
  126323. * Block used to read a texture from a sampler
  126324. */
  126325. export class TextureBlock extends NodeMaterialBlock {
  126326. private _defineName;
  126327. private _linearDefineName;
  126328. private _tempTextureRead;
  126329. private _samplerName;
  126330. private _transformedUVName;
  126331. private _textureTransformName;
  126332. private _textureInfoName;
  126333. private _mainUVName;
  126334. private _mainUVDefineName;
  126335. /**
  126336. * Gets or sets the texture associated with the node
  126337. */
  126338. texture: Nullable<Texture>;
  126339. /**
  126340. * Create a new TextureBlock
  126341. * @param name defines the block name
  126342. */
  126343. constructor(name: string);
  126344. /**
  126345. * Gets the current class name
  126346. * @returns the class name
  126347. */
  126348. getClassName(): string;
  126349. /**
  126350. * Gets the uv input component
  126351. */
  126352. get uv(): NodeMaterialConnectionPoint;
  126353. /**
  126354. * Gets the rgba output component
  126355. */
  126356. get rgba(): NodeMaterialConnectionPoint;
  126357. /**
  126358. * Gets the rgb output component
  126359. */
  126360. get rgb(): NodeMaterialConnectionPoint;
  126361. /**
  126362. * Gets the r output component
  126363. */
  126364. get r(): NodeMaterialConnectionPoint;
  126365. /**
  126366. * Gets the g output component
  126367. */
  126368. get g(): NodeMaterialConnectionPoint;
  126369. /**
  126370. * Gets the b output component
  126371. */
  126372. get b(): NodeMaterialConnectionPoint;
  126373. /**
  126374. * Gets the a output component
  126375. */
  126376. get a(): NodeMaterialConnectionPoint;
  126377. get target(): NodeMaterialBlockTargets;
  126378. autoConfigure(material: NodeMaterial): void;
  126379. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126381. private _getTextureBase;
  126382. isReady(): boolean;
  126383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126384. private get _isMixed();
  126385. private _injectVertexCode;
  126386. private _writeTextureRead;
  126387. private _writeOutput;
  126388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126389. protected _dumpPropertiesCode(): string;
  126390. serialize(): any;
  126391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126392. }
  126393. }
  126394. declare module BABYLON {
  126395. /**
  126396. * Class used to store shared data between 2 NodeMaterialBuildState
  126397. */
  126398. export class NodeMaterialBuildStateSharedData {
  126399. /**
  126400. * Gets the list of emitted varyings
  126401. */
  126402. temps: string[];
  126403. /**
  126404. * Gets the list of emitted varyings
  126405. */
  126406. varyings: string[];
  126407. /**
  126408. * Gets the varying declaration string
  126409. */
  126410. varyingDeclaration: string;
  126411. /**
  126412. * Input blocks
  126413. */
  126414. inputBlocks: InputBlock[];
  126415. /**
  126416. * Input blocks
  126417. */
  126418. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126419. /**
  126420. * Bindable blocks (Blocks that need to set data to the effect)
  126421. */
  126422. bindableBlocks: NodeMaterialBlock[];
  126423. /**
  126424. * List of blocks that can provide a compilation fallback
  126425. */
  126426. blocksWithFallbacks: NodeMaterialBlock[];
  126427. /**
  126428. * List of blocks that can provide a define update
  126429. */
  126430. blocksWithDefines: NodeMaterialBlock[];
  126431. /**
  126432. * List of blocks that can provide a repeatable content
  126433. */
  126434. repeatableContentBlocks: NodeMaterialBlock[];
  126435. /**
  126436. * List of blocks that can provide a dynamic list of uniforms
  126437. */
  126438. dynamicUniformBlocks: NodeMaterialBlock[];
  126439. /**
  126440. * List of blocks that can block the isReady function for the material
  126441. */
  126442. blockingBlocks: NodeMaterialBlock[];
  126443. /**
  126444. * Gets the list of animated inputs
  126445. */
  126446. animatedInputs: InputBlock[];
  126447. /**
  126448. * Build Id used to avoid multiple recompilations
  126449. */
  126450. buildId: number;
  126451. /** List of emitted variables */
  126452. variableNames: {
  126453. [key: string]: number;
  126454. };
  126455. /** List of emitted defines */
  126456. defineNames: {
  126457. [key: string]: number;
  126458. };
  126459. /** Should emit comments? */
  126460. emitComments: boolean;
  126461. /** Emit build activity */
  126462. verbose: boolean;
  126463. /** Gets or sets the hosting scene */
  126464. scene: Scene;
  126465. /**
  126466. * Gets the compilation hints emitted at compilation time
  126467. */
  126468. hints: {
  126469. needWorldViewMatrix: boolean;
  126470. needWorldViewProjectionMatrix: boolean;
  126471. needAlphaBlending: boolean;
  126472. needAlphaTesting: boolean;
  126473. };
  126474. /**
  126475. * List of compilation checks
  126476. */
  126477. checks: {
  126478. emitVertex: boolean;
  126479. emitFragment: boolean;
  126480. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126481. };
  126482. /** Creates a new shared data */
  126483. constructor();
  126484. /**
  126485. * Emits console errors and exceptions if there is a failing check
  126486. */
  126487. emitErrors(): void;
  126488. }
  126489. }
  126490. declare module BABYLON {
  126491. /**
  126492. * Class used to store node based material build state
  126493. */
  126494. export class NodeMaterialBuildState {
  126495. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126496. supportUniformBuffers: boolean;
  126497. /**
  126498. * Gets the list of emitted attributes
  126499. */
  126500. attributes: string[];
  126501. /**
  126502. * Gets the list of emitted uniforms
  126503. */
  126504. uniforms: string[];
  126505. /**
  126506. * Gets the list of emitted constants
  126507. */
  126508. constants: string[];
  126509. /**
  126510. * Gets the list of emitted samplers
  126511. */
  126512. samplers: string[];
  126513. /**
  126514. * Gets the list of emitted functions
  126515. */
  126516. functions: {
  126517. [key: string]: string;
  126518. };
  126519. /**
  126520. * Gets the list of emitted extensions
  126521. */
  126522. extensions: {
  126523. [key: string]: string;
  126524. };
  126525. /**
  126526. * Gets the target of the compilation state
  126527. */
  126528. target: NodeMaterialBlockTargets;
  126529. /**
  126530. * Gets the list of emitted counters
  126531. */
  126532. counters: {
  126533. [key: string]: number;
  126534. };
  126535. /**
  126536. * Shared data between multiple NodeMaterialBuildState instances
  126537. */
  126538. sharedData: NodeMaterialBuildStateSharedData;
  126539. /** @hidden */
  126540. _vertexState: NodeMaterialBuildState;
  126541. /** @hidden */
  126542. _attributeDeclaration: string;
  126543. /** @hidden */
  126544. _uniformDeclaration: string;
  126545. /** @hidden */
  126546. _constantDeclaration: string;
  126547. /** @hidden */
  126548. _samplerDeclaration: string;
  126549. /** @hidden */
  126550. _varyingTransfer: string;
  126551. private _repeatableContentAnchorIndex;
  126552. /** @hidden */
  126553. _builtCompilationString: string;
  126554. /**
  126555. * Gets the emitted compilation strings
  126556. */
  126557. compilationString: string;
  126558. /**
  126559. * Finalize the compilation strings
  126560. * @param state defines the current compilation state
  126561. */
  126562. finalize(state: NodeMaterialBuildState): void;
  126563. /** @hidden */
  126564. get _repeatableContentAnchor(): string;
  126565. /** @hidden */
  126566. _getFreeVariableName(prefix: string): string;
  126567. /** @hidden */
  126568. _getFreeDefineName(prefix: string): string;
  126569. /** @hidden */
  126570. _excludeVariableName(name: string): void;
  126571. /** @hidden */
  126572. _emit2DSampler(name: string): void;
  126573. /** @hidden */
  126574. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126575. /** @hidden */
  126576. _emitExtension(name: string, extension: string): void;
  126577. /** @hidden */
  126578. _emitFunction(name: string, code: string, comments: string): void;
  126579. /** @hidden */
  126580. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126581. replaceStrings?: {
  126582. search: RegExp;
  126583. replace: string;
  126584. }[];
  126585. repeatKey?: string;
  126586. }): string;
  126587. /** @hidden */
  126588. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126589. repeatKey?: string;
  126590. removeAttributes?: boolean;
  126591. removeUniforms?: boolean;
  126592. removeVaryings?: boolean;
  126593. removeIfDef?: boolean;
  126594. replaceStrings?: {
  126595. search: RegExp;
  126596. replace: string;
  126597. }[];
  126598. }, storeKey?: string): void;
  126599. /** @hidden */
  126600. _registerTempVariable(name: string): boolean;
  126601. /** @hidden */
  126602. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126603. /** @hidden */
  126604. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126605. /** @hidden */
  126606. _emitFloat(value: number): string;
  126607. }
  126608. }
  126609. declare module BABYLON {
  126610. /**
  126611. * Defines a block that can be used inside a node based material
  126612. */
  126613. export class NodeMaterialBlock {
  126614. private _buildId;
  126615. private _buildTarget;
  126616. private _target;
  126617. private _isFinalMerger;
  126618. private _isInput;
  126619. protected _isUnique: boolean;
  126620. /** @hidden */
  126621. _codeVariableName: string;
  126622. /** @hidden */
  126623. _inputs: NodeMaterialConnectionPoint[];
  126624. /** @hidden */
  126625. _outputs: NodeMaterialConnectionPoint[];
  126626. /** @hidden */
  126627. _preparationId: number;
  126628. /**
  126629. * Gets or sets the name of the block
  126630. */
  126631. name: string;
  126632. /**
  126633. * Gets or sets the unique id of the node
  126634. */
  126635. uniqueId: number;
  126636. /**
  126637. * Gets or sets the comments associated with this block
  126638. */
  126639. comments: string;
  126640. /**
  126641. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126642. */
  126643. get isUnique(): boolean;
  126644. /**
  126645. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126646. */
  126647. get isFinalMerger(): boolean;
  126648. /**
  126649. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126650. */
  126651. get isInput(): boolean;
  126652. /**
  126653. * Gets or sets the build Id
  126654. */
  126655. get buildId(): number;
  126656. set buildId(value: number);
  126657. /**
  126658. * Gets or sets the target of the block
  126659. */
  126660. get target(): NodeMaterialBlockTargets;
  126661. set target(value: NodeMaterialBlockTargets);
  126662. /**
  126663. * Gets the list of input points
  126664. */
  126665. get inputs(): NodeMaterialConnectionPoint[];
  126666. /** Gets the list of output points */
  126667. get outputs(): NodeMaterialConnectionPoint[];
  126668. /**
  126669. * Find an input by its name
  126670. * @param name defines the name of the input to look for
  126671. * @returns the input or null if not found
  126672. */
  126673. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126674. /**
  126675. * Find an output by its name
  126676. * @param name defines the name of the outputto look for
  126677. * @returns the output or null if not found
  126678. */
  126679. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126680. /**
  126681. * Creates a new NodeMaterialBlock
  126682. * @param name defines the block name
  126683. * @param target defines the target of that block (Vertex by default)
  126684. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126685. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126686. */
  126687. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126688. /**
  126689. * Initialize the block and prepare the context for build
  126690. * @param state defines the state that will be used for the build
  126691. */
  126692. initialize(state: NodeMaterialBuildState): void;
  126693. /**
  126694. * Bind data to effect. Will only be called for blocks with isBindable === true
  126695. * @param effect defines the effect to bind data to
  126696. * @param nodeMaterial defines the hosting NodeMaterial
  126697. * @param mesh defines the mesh that will be rendered
  126698. */
  126699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126700. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126701. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126702. protected _writeFloat(value: number): string;
  126703. /**
  126704. * Gets the current class name e.g. "NodeMaterialBlock"
  126705. * @returns the class name
  126706. */
  126707. getClassName(): string;
  126708. /**
  126709. * Register a new input. Must be called inside a block constructor
  126710. * @param name defines the connection point name
  126711. * @param type defines the connection point type
  126712. * @param isOptional defines a boolean indicating that this input can be omitted
  126713. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126714. * @returns the current block
  126715. */
  126716. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126717. /**
  126718. * Register a new output. Must be called inside a block constructor
  126719. * @param name defines the connection point name
  126720. * @param type defines the connection point type
  126721. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126722. * @returns the current block
  126723. */
  126724. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126725. /**
  126726. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126727. * @param forOutput defines an optional connection point to check compatibility with
  126728. * @returns the first available input or null
  126729. */
  126730. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126731. /**
  126732. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126733. * @param forBlock defines an optional block to check compatibility with
  126734. * @returns the first available input or null
  126735. */
  126736. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126737. /**
  126738. * Gets the sibling of the given output
  126739. * @param current defines the current output
  126740. * @returns the next output in the list or null
  126741. */
  126742. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126743. /**
  126744. * Connect current block with another block
  126745. * @param other defines the block to connect with
  126746. * @param options define the various options to help pick the right connections
  126747. * @returns the current block
  126748. */
  126749. connectTo(other: NodeMaterialBlock, options?: {
  126750. input?: string;
  126751. output?: string;
  126752. outputSwizzle?: string;
  126753. }): this | undefined;
  126754. protected _buildBlock(state: NodeMaterialBuildState): void;
  126755. /**
  126756. * Add uniforms, samplers and uniform buffers at compilation time
  126757. * @param state defines the state to update
  126758. * @param nodeMaterial defines the node material requesting the update
  126759. * @param defines defines the material defines to update
  126760. * @param uniformBuffers defines the list of uniform buffer names
  126761. */
  126762. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126763. /**
  126764. * Add potential fallbacks if shader compilation fails
  126765. * @param mesh defines the mesh to be rendered
  126766. * @param fallbacks defines the current prioritized list of fallbacks
  126767. */
  126768. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126769. /**
  126770. * Initialize defines for shader compilation
  126771. * @param mesh defines the mesh to be rendered
  126772. * @param nodeMaterial defines the node material requesting the update
  126773. * @param defines defines the material defines to update
  126774. * @param useInstances specifies that instances should be used
  126775. */
  126776. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126777. /**
  126778. * Update defines for shader compilation
  126779. * @param mesh defines the mesh to be rendered
  126780. * @param nodeMaterial defines the node material requesting the update
  126781. * @param defines defines the material defines to update
  126782. * @param useInstances specifies that instances should be used
  126783. */
  126784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126785. /**
  126786. * Lets the block try to connect some inputs automatically
  126787. * @param material defines the hosting NodeMaterial
  126788. */
  126789. autoConfigure(material: NodeMaterial): void;
  126790. /**
  126791. * Function called when a block is declared as repeatable content generator
  126792. * @param vertexShaderState defines the current compilation state for the vertex shader
  126793. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126794. * @param mesh defines the mesh to be rendered
  126795. * @param defines defines the material defines to update
  126796. */
  126797. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126798. /**
  126799. * Checks if the block is ready
  126800. * @param mesh defines the mesh to be rendered
  126801. * @param nodeMaterial defines the node material requesting the update
  126802. * @param defines defines the material defines to update
  126803. * @param useInstances specifies that instances should be used
  126804. * @returns true if the block is ready
  126805. */
  126806. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126807. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126808. private _processBuild;
  126809. /**
  126810. * Compile the current node and generate the shader code
  126811. * @param state defines the current compilation state (uniforms, samplers, current string)
  126812. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126813. * @returns true if already built
  126814. */
  126815. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126816. protected _inputRename(name: string): string;
  126817. protected _outputRename(name: string): string;
  126818. protected _dumpPropertiesCode(): string;
  126819. /** @hidden */
  126820. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126821. /** @hidden */
  126822. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126823. /**
  126824. * Clone the current block to a new identical block
  126825. * @param scene defines the hosting scene
  126826. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126827. * @returns a copy of the current block
  126828. */
  126829. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126830. /**
  126831. * Serializes this block in a JSON representation
  126832. * @returns the serialized block object
  126833. */
  126834. serialize(): any;
  126835. /** @hidden */
  126836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126837. /**
  126838. * Release resources
  126839. */
  126840. dispose(): void;
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. /**
  126845. * Enum defining the type of animations supported by InputBlock
  126846. */
  126847. export enum AnimatedInputBlockTypes {
  126848. /** No animation */
  126849. None = 0,
  126850. /** Time based animation. Will only work for floats */
  126851. Time = 1
  126852. }
  126853. }
  126854. declare module BABYLON {
  126855. /**
  126856. * Block used to expose an input value
  126857. */
  126858. export class InputBlock extends NodeMaterialBlock {
  126859. private _mode;
  126860. private _associatedVariableName;
  126861. private _storedValue;
  126862. private _valueCallback;
  126863. private _type;
  126864. private _animationType;
  126865. /** Gets or set a value used to limit the range of float values */
  126866. min: number;
  126867. /** Gets or set a value used to limit the range of float values */
  126868. max: number;
  126869. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126870. matrixMode: number;
  126871. /** @hidden */
  126872. _systemValue: Nullable<NodeMaterialSystemValues>;
  126873. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126874. visibleInInspector: boolean;
  126875. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126876. isConstant: boolean;
  126877. /** Gets or sets the group to use to display this block in the Inspector */
  126878. groupInInspector: string;
  126879. /**
  126880. * Gets or sets the connection point type (default is float)
  126881. */
  126882. get type(): NodeMaterialBlockConnectionPointTypes;
  126883. /**
  126884. * Creates a new InputBlock
  126885. * @param name defines the block name
  126886. * @param target defines the target of that block (Vertex by default)
  126887. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126888. */
  126889. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126890. /**
  126891. * Gets the output component
  126892. */
  126893. get output(): NodeMaterialConnectionPoint;
  126894. /**
  126895. * Set the source of this connection point to a vertex attribute
  126896. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126897. * @returns the current connection point
  126898. */
  126899. setAsAttribute(attributeName?: string): InputBlock;
  126900. /**
  126901. * Set the source of this connection point to a system value
  126902. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126903. * @returns the current connection point
  126904. */
  126905. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126906. /**
  126907. * Gets or sets the value of that point.
  126908. * Please note that this value will be ignored if valueCallback is defined
  126909. */
  126910. get value(): any;
  126911. set value(value: any);
  126912. /**
  126913. * Gets or sets a callback used to get the value of that point.
  126914. * Please note that setting this value will force the connection point to ignore the value property
  126915. */
  126916. get valueCallback(): () => any;
  126917. set valueCallback(value: () => any);
  126918. /**
  126919. * Gets or sets the associated variable name in the shader
  126920. */
  126921. get associatedVariableName(): string;
  126922. set associatedVariableName(value: string);
  126923. /** Gets or sets the type of animation applied to the input */
  126924. get animationType(): AnimatedInputBlockTypes;
  126925. set animationType(value: AnimatedInputBlockTypes);
  126926. /**
  126927. * Gets a boolean indicating that this connection point not defined yet
  126928. */
  126929. get isUndefined(): boolean;
  126930. /**
  126931. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126932. * In this case the connection point name must be the name of the uniform to use.
  126933. * Can only be set on inputs
  126934. */
  126935. get isUniform(): boolean;
  126936. set isUniform(value: boolean);
  126937. /**
  126938. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126939. * In this case the connection point name must be the name of the attribute to use
  126940. * Can only be set on inputs
  126941. */
  126942. get isAttribute(): boolean;
  126943. set isAttribute(value: boolean);
  126944. /**
  126945. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126946. * Can only be set on exit points
  126947. */
  126948. get isVarying(): boolean;
  126949. set isVarying(value: boolean);
  126950. /**
  126951. * Gets a boolean indicating that the current connection point is a system value
  126952. */
  126953. get isSystemValue(): boolean;
  126954. /**
  126955. * Gets or sets the current well known value or null if not defined as a system value
  126956. */
  126957. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126958. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126959. /**
  126960. * Gets the current class name
  126961. * @returns the class name
  126962. */
  126963. getClassName(): string;
  126964. /**
  126965. * Animate the input if animationType !== None
  126966. * @param scene defines the rendering scene
  126967. */
  126968. animate(scene: Scene): void;
  126969. private _emitDefine;
  126970. initialize(state: NodeMaterialBuildState): void;
  126971. /**
  126972. * Set the input block to its default value (based on its type)
  126973. */
  126974. setDefaultValue(): void;
  126975. private _emitConstant;
  126976. private _emit;
  126977. /** @hidden */
  126978. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126979. /** @hidden */
  126980. _transmit(effect: Effect, scene: Scene): void;
  126981. protected _buildBlock(state: NodeMaterialBuildState): void;
  126982. protected _dumpPropertiesCode(): string;
  126983. serialize(): any;
  126984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126985. }
  126986. }
  126987. declare module BABYLON {
  126988. /**
  126989. * Enum used to define the compatibility state between two connection points
  126990. */
  126991. export enum NodeMaterialConnectionPointCompatibilityStates {
  126992. /** Points are compatibles */
  126993. Compatible = 0,
  126994. /** Points are incompatible because of their types */
  126995. TypeIncompatible = 1,
  126996. /** Points are incompatible because of their targets (vertex vs fragment) */
  126997. TargetIncompatible = 2
  126998. }
  126999. /**
  127000. * Defines the direction of a connection point
  127001. */
  127002. export enum NodeMaterialConnectionPointDirection {
  127003. /** Input */
  127004. Input = 0,
  127005. /** Output */
  127006. Output = 1
  127007. }
  127008. /**
  127009. * Defines a connection point for a block
  127010. */
  127011. export class NodeMaterialConnectionPoint {
  127012. /** @hidden */
  127013. _ownerBlock: NodeMaterialBlock;
  127014. /** @hidden */
  127015. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  127016. private _endpoints;
  127017. private _associatedVariableName;
  127018. private _direction;
  127019. /** @hidden */
  127020. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  127021. /** @hidden */
  127022. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  127023. private _type;
  127024. /** @hidden */
  127025. _enforceAssociatedVariableName: boolean;
  127026. /** Gets the direction of the point */
  127027. get direction(): NodeMaterialConnectionPointDirection;
  127028. /**
  127029. * Gets or sets the additional types supported by this connection point
  127030. */
  127031. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  127032. /**
  127033. * Gets or sets the additional types excluded by this connection point
  127034. */
  127035. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  127036. /**
  127037. * Observable triggered when this point is connected
  127038. */
  127039. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  127040. /**
  127041. * Gets or sets the associated variable name in the shader
  127042. */
  127043. get associatedVariableName(): string;
  127044. set associatedVariableName(value: string);
  127045. /**
  127046. * Gets or sets the connection point type (default is float)
  127047. */
  127048. get type(): NodeMaterialBlockConnectionPointTypes;
  127049. set type(value: NodeMaterialBlockConnectionPointTypes);
  127050. /**
  127051. * Gets or sets the connection point name
  127052. */
  127053. name: string;
  127054. /**
  127055. * Gets or sets a boolean indicating that this connection point can be omitted
  127056. */
  127057. isOptional: boolean;
  127058. /**
  127059. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  127060. */
  127061. define: string;
  127062. /** @hidden */
  127063. _prioritizeVertex: boolean;
  127064. private _target;
  127065. /** Gets or sets the target of that connection point */
  127066. get target(): NodeMaterialBlockTargets;
  127067. set target(value: NodeMaterialBlockTargets);
  127068. /**
  127069. * Gets a boolean indicating that the current point is connected
  127070. */
  127071. get isConnected(): boolean;
  127072. /**
  127073. * Gets a boolean indicating that the current point is connected to an input block
  127074. */
  127075. get isConnectedToInputBlock(): boolean;
  127076. /**
  127077. * Gets a the connected input block (if any)
  127078. */
  127079. get connectInputBlock(): Nullable<InputBlock>;
  127080. /** Get the other side of the connection (if any) */
  127081. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  127082. /** Get the block that owns this connection point */
  127083. get ownerBlock(): NodeMaterialBlock;
  127084. /** Get the block connected on the other side of this connection (if any) */
  127085. get sourceBlock(): Nullable<NodeMaterialBlock>;
  127086. /** Get the block connected on the endpoints of this connection (if any) */
  127087. get connectedBlocks(): Array<NodeMaterialBlock>;
  127088. /** Gets the list of connected endpoints */
  127089. get endpoints(): NodeMaterialConnectionPoint[];
  127090. /** Gets a boolean indicating if that output point is connected to at least one input */
  127091. get hasEndpoints(): boolean;
  127092. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  127093. get isConnectedInVertexShader(): boolean;
  127094. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  127095. get isConnectedInFragmentShader(): boolean;
  127096. /**
  127097. * Creates a new connection point
  127098. * @param name defines the connection point name
  127099. * @param ownerBlock defines the block hosting this connection point
  127100. * @param direction defines the direction of the connection point
  127101. */
  127102. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  127103. /**
  127104. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  127105. * @returns the class name
  127106. */
  127107. getClassName(): string;
  127108. /**
  127109. * Gets a boolean indicating if the current point can be connected to another point
  127110. * @param connectionPoint defines the other connection point
  127111. * @returns a boolean
  127112. */
  127113. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  127114. /**
  127115. * Gets a number indicating if the current point can be connected to another point
  127116. * @param connectionPoint defines the other connection point
  127117. * @returns a number defining the compatibility state
  127118. */
  127119. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  127120. /**
  127121. * Connect this point to another connection point
  127122. * @param connectionPoint defines the other connection point
  127123. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  127124. * @returns the current connection point
  127125. */
  127126. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  127127. /**
  127128. * Disconnect this point from one of his endpoint
  127129. * @param endpoint defines the other connection point
  127130. * @returns the current connection point
  127131. */
  127132. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  127133. /**
  127134. * Serializes this point in a JSON representation
  127135. * @returns the serialized point object
  127136. */
  127137. serialize(): any;
  127138. /**
  127139. * Release resources
  127140. */
  127141. dispose(): void;
  127142. }
  127143. }
  127144. declare module BABYLON {
  127145. /**
  127146. * Block used to add support for vertex skinning (bones)
  127147. */
  127148. export class BonesBlock extends NodeMaterialBlock {
  127149. /**
  127150. * Creates a new BonesBlock
  127151. * @param name defines the block name
  127152. */
  127153. constructor(name: string);
  127154. /**
  127155. * Initialize the block and prepare the context for build
  127156. * @param state defines the state that will be used for the build
  127157. */
  127158. initialize(state: NodeMaterialBuildState): void;
  127159. /**
  127160. * Gets the current class name
  127161. * @returns the class name
  127162. */
  127163. getClassName(): string;
  127164. /**
  127165. * Gets the matrix indices input component
  127166. */
  127167. get matricesIndices(): NodeMaterialConnectionPoint;
  127168. /**
  127169. * Gets the matrix weights input component
  127170. */
  127171. get matricesWeights(): NodeMaterialConnectionPoint;
  127172. /**
  127173. * Gets the extra matrix indices input component
  127174. */
  127175. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  127176. /**
  127177. * Gets the extra matrix weights input component
  127178. */
  127179. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  127180. /**
  127181. * Gets the world input component
  127182. */
  127183. get world(): NodeMaterialConnectionPoint;
  127184. /**
  127185. * Gets the output component
  127186. */
  127187. get output(): NodeMaterialConnectionPoint;
  127188. autoConfigure(material: NodeMaterial): void;
  127189. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  127190. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127192. protected _buildBlock(state: NodeMaterialBuildState): this;
  127193. }
  127194. }
  127195. declare module BABYLON {
  127196. /**
  127197. * Block used to add support for instances
  127198. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  127199. */
  127200. export class InstancesBlock extends NodeMaterialBlock {
  127201. /**
  127202. * Creates a new InstancesBlock
  127203. * @param name defines the block name
  127204. */
  127205. constructor(name: string);
  127206. /**
  127207. * Gets the current class name
  127208. * @returns the class name
  127209. */
  127210. getClassName(): string;
  127211. /**
  127212. * Gets the first world row input component
  127213. */
  127214. get world0(): NodeMaterialConnectionPoint;
  127215. /**
  127216. * Gets the second world row input component
  127217. */
  127218. get world1(): NodeMaterialConnectionPoint;
  127219. /**
  127220. * Gets the third world row input component
  127221. */
  127222. get world2(): NodeMaterialConnectionPoint;
  127223. /**
  127224. * Gets the forth world row input component
  127225. */
  127226. get world3(): NodeMaterialConnectionPoint;
  127227. /**
  127228. * Gets the world input component
  127229. */
  127230. get world(): NodeMaterialConnectionPoint;
  127231. /**
  127232. * Gets the output component
  127233. */
  127234. get output(): NodeMaterialConnectionPoint;
  127235. autoConfigure(material: NodeMaterial): void;
  127236. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127237. protected _buildBlock(state: NodeMaterialBuildState): this;
  127238. }
  127239. }
  127240. declare module BABYLON {
  127241. /**
  127242. * Block used to add morph targets support to vertex shader
  127243. */
  127244. export class MorphTargetsBlock extends NodeMaterialBlock {
  127245. private _repeatableContentAnchor;
  127246. private _repeatebleContentGenerated;
  127247. /**
  127248. * Create a new MorphTargetsBlock
  127249. * @param name defines the block name
  127250. */
  127251. constructor(name: string);
  127252. /**
  127253. * Gets the current class name
  127254. * @returns the class name
  127255. */
  127256. getClassName(): string;
  127257. /**
  127258. * Gets the position input component
  127259. */
  127260. get position(): NodeMaterialConnectionPoint;
  127261. /**
  127262. * Gets the normal input component
  127263. */
  127264. get normal(): NodeMaterialConnectionPoint;
  127265. /**
  127266. * Gets the tangent input component
  127267. */
  127268. get tangent(): NodeMaterialConnectionPoint;
  127269. /**
  127270. * Gets the tangent input component
  127271. */
  127272. get uv(): NodeMaterialConnectionPoint;
  127273. /**
  127274. * Gets the position output component
  127275. */
  127276. get positionOutput(): NodeMaterialConnectionPoint;
  127277. /**
  127278. * Gets the normal output component
  127279. */
  127280. get normalOutput(): NodeMaterialConnectionPoint;
  127281. /**
  127282. * Gets the tangent output component
  127283. */
  127284. get tangentOutput(): NodeMaterialConnectionPoint;
  127285. /**
  127286. * Gets the tangent output component
  127287. */
  127288. get uvOutput(): NodeMaterialConnectionPoint;
  127289. initialize(state: NodeMaterialBuildState): void;
  127290. autoConfigure(material: NodeMaterial): void;
  127291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127292. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127293. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127294. protected _buildBlock(state: NodeMaterialBuildState): this;
  127295. }
  127296. }
  127297. declare module BABYLON {
  127298. /**
  127299. * Block used to get data information from a light
  127300. */
  127301. export class LightInformationBlock extends NodeMaterialBlock {
  127302. private _lightDataUniformName;
  127303. private _lightColorUniformName;
  127304. private _lightTypeDefineName;
  127305. /**
  127306. * Gets or sets the light associated with this block
  127307. */
  127308. light: Nullable<Light>;
  127309. /**
  127310. * Creates a new LightInformationBlock
  127311. * @param name defines the block name
  127312. */
  127313. constructor(name: string);
  127314. /**
  127315. * Gets the current class name
  127316. * @returns the class name
  127317. */
  127318. getClassName(): string;
  127319. /**
  127320. * Gets the world position input component
  127321. */
  127322. get worldPosition(): NodeMaterialConnectionPoint;
  127323. /**
  127324. * Gets the direction output component
  127325. */
  127326. get direction(): NodeMaterialConnectionPoint;
  127327. /**
  127328. * Gets the direction output component
  127329. */
  127330. get color(): NodeMaterialConnectionPoint;
  127331. /**
  127332. * Gets the direction output component
  127333. */
  127334. get intensity(): NodeMaterialConnectionPoint;
  127335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127337. protected _buildBlock(state: NodeMaterialBuildState): this;
  127338. serialize(): any;
  127339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127340. }
  127341. }
  127342. declare module BABYLON {
  127343. /**
  127344. * Block used to add image processing support to fragment shader
  127345. */
  127346. export class ImageProcessingBlock extends NodeMaterialBlock {
  127347. /**
  127348. * Create a new ImageProcessingBlock
  127349. * @param name defines the block name
  127350. */
  127351. constructor(name: string);
  127352. /**
  127353. * Gets the current class name
  127354. * @returns the class name
  127355. */
  127356. getClassName(): string;
  127357. /**
  127358. * Gets the color input component
  127359. */
  127360. get color(): NodeMaterialConnectionPoint;
  127361. /**
  127362. * Gets the output component
  127363. */
  127364. get output(): NodeMaterialConnectionPoint;
  127365. /**
  127366. * Initialize the block and prepare the context for build
  127367. * @param state defines the state that will be used for the build
  127368. */
  127369. initialize(state: NodeMaterialBuildState): void;
  127370. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127373. protected _buildBlock(state: NodeMaterialBuildState): this;
  127374. }
  127375. }
  127376. declare module BABYLON {
  127377. /**
  127378. * Block used to pertub normals based on a normal map
  127379. */
  127380. export class PerturbNormalBlock extends NodeMaterialBlock {
  127381. private _tangentSpaceParameterName;
  127382. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127383. invertX: boolean;
  127384. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127385. invertY: boolean;
  127386. /**
  127387. * Create a new PerturbNormalBlock
  127388. * @param name defines the block name
  127389. */
  127390. constructor(name: string);
  127391. /**
  127392. * Gets the current class name
  127393. * @returns the class name
  127394. */
  127395. getClassName(): string;
  127396. /**
  127397. * Gets the world position input component
  127398. */
  127399. get worldPosition(): NodeMaterialConnectionPoint;
  127400. /**
  127401. * Gets the world normal input component
  127402. */
  127403. get worldNormal(): NodeMaterialConnectionPoint;
  127404. /**
  127405. * Gets the uv input component
  127406. */
  127407. get uv(): NodeMaterialConnectionPoint;
  127408. /**
  127409. * Gets the normal map color input component
  127410. */
  127411. get normalMapColor(): NodeMaterialConnectionPoint;
  127412. /**
  127413. * Gets the strength input component
  127414. */
  127415. get strength(): NodeMaterialConnectionPoint;
  127416. /**
  127417. * Gets the output component
  127418. */
  127419. get output(): NodeMaterialConnectionPoint;
  127420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127422. autoConfigure(material: NodeMaterial): void;
  127423. protected _buildBlock(state: NodeMaterialBuildState): this;
  127424. protected _dumpPropertiesCode(): string;
  127425. serialize(): any;
  127426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127427. }
  127428. }
  127429. declare module BABYLON {
  127430. /**
  127431. * Block used to discard a pixel if a value is smaller than a cutoff
  127432. */
  127433. export class DiscardBlock extends NodeMaterialBlock {
  127434. /**
  127435. * Create a new DiscardBlock
  127436. * @param name defines the block name
  127437. */
  127438. constructor(name: string);
  127439. /**
  127440. * Gets the current class name
  127441. * @returns the class name
  127442. */
  127443. getClassName(): string;
  127444. /**
  127445. * Gets the color input component
  127446. */
  127447. get value(): NodeMaterialConnectionPoint;
  127448. /**
  127449. * Gets the cutoff input component
  127450. */
  127451. get cutoff(): NodeMaterialConnectionPoint;
  127452. protected _buildBlock(state: NodeMaterialBuildState): this;
  127453. }
  127454. }
  127455. declare module BABYLON {
  127456. /**
  127457. * Block used to test if the fragment shader is front facing
  127458. */
  127459. export class FrontFacingBlock extends NodeMaterialBlock {
  127460. /**
  127461. * Creates a new FrontFacingBlock
  127462. * @param name defines the block name
  127463. */
  127464. constructor(name: string);
  127465. /**
  127466. * Gets the current class name
  127467. * @returns the class name
  127468. */
  127469. getClassName(): string;
  127470. /**
  127471. * Gets the output component
  127472. */
  127473. get output(): NodeMaterialConnectionPoint;
  127474. protected _buildBlock(state: NodeMaterialBuildState): this;
  127475. }
  127476. }
  127477. declare module BABYLON {
  127478. /**
  127479. * Block used to get the derivative value on x and y of a given input
  127480. */
  127481. export class DerivativeBlock extends NodeMaterialBlock {
  127482. /**
  127483. * Create a new DerivativeBlock
  127484. * @param name defines the block name
  127485. */
  127486. constructor(name: string);
  127487. /**
  127488. * Gets the current class name
  127489. * @returns the class name
  127490. */
  127491. getClassName(): string;
  127492. /**
  127493. * Gets the input component
  127494. */
  127495. get input(): NodeMaterialConnectionPoint;
  127496. /**
  127497. * Gets the derivative output on x
  127498. */
  127499. get dx(): NodeMaterialConnectionPoint;
  127500. /**
  127501. * Gets the derivative output on y
  127502. */
  127503. get dy(): NodeMaterialConnectionPoint;
  127504. protected _buildBlock(state: NodeMaterialBuildState): this;
  127505. }
  127506. }
  127507. declare module BABYLON {
  127508. /**
  127509. * Block used to add support for scene fog
  127510. */
  127511. export class FogBlock extends NodeMaterialBlock {
  127512. private _fogDistanceName;
  127513. private _fogParameters;
  127514. /**
  127515. * Create a new FogBlock
  127516. * @param name defines the block name
  127517. */
  127518. constructor(name: string);
  127519. /**
  127520. * Gets the current class name
  127521. * @returns the class name
  127522. */
  127523. getClassName(): string;
  127524. /**
  127525. * Gets the world position input component
  127526. */
  127527. get worldPosition(): NodeMaterialConnectionPoint;
  127528. /**
  127529. * Gets the view input component
  127530. */
  127531. get view(): NodeMaterialConnectionPoint;
  127532. /**
  127533. * Gets the color input component
  127534. */
  127535. get input(): NodeMaterialConnectionPoint;
  127536. /**
  127537. * Gets the fog color input component
  127538. */
  127539. get fogColor(): NodeMaterialConnectionPoint;
  127540. /**
  127541. * Gets the output component
  127542. */
  127543. get output(): NodeMaterialConnectionPoint;
  127544. autoConfigure(material: NodeMaterial): void;
  127545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127547. protected _buildBlock(state: NodeMaterialBuildState): this;
  127548. }
  127549. }
  127550. declare module BABYLON {
  127551. /**
  127552. * Block used to add light in the fragment shader
  127553. */
  127554. export class LightBlock extends NodeMaterialBlock {
  127555. private _lightId;
  127556. /**
  127557. * Gets or sets the light associated with this block
  127558. */
  127559. light: Nullable<Light>;
  127560. /**
  127561. * Create a new LightBlock
  127562. * @param name defines the block name
  127563. */
  127564. constructor(name: string);
  127565. /**
  127566. * Gets the current class name
  127567. * @returns the class name
  127568. */
  127569. getClassName(): string;
  127570. /**
  127571. * Gets the world position input component
  127572. */
  127573. get worldPosition(): NodeMaterialConnectionPoint;
  127574. /**
  127575. * Gets the world normal input component
  127576. */
  127577. get worldNormal(): NodeMaterialConnectionPoint;
  127578. /**
  127579. * Gets the camera (or eye) position component
  127580. */
  127581. get cameraPosition(): NodeMaterialConnectionPoint;
  127582. /**
  127583. * Gets the glossiness component
  127584. */
  127585. get glossiness(): NodeMaterialConnectionPoint;
  127586. /**
  127587. * Gets the glossinness power component
  127588. */
  127589. get glossPower(): NodeMaterialConnectionPoint;
  127590. /**
  127591. * Gets the diffuse color component
  127592. */
  127593. get diffuseColor(): NodeMaterialConnectionPoint;
  127594. /**
  127595. * Gets the specular color component
  127596. */
  127597. get specularColor(): NodeMaterialConnectionPoint;
  127598. /**
  127599. * Gets the diffuse output component
  127600. */
  127601. get diffuseOutput(): NodeMaterialConnectionPoint;
  127602. /**
  127603. * Gets the specular output component
  127604. */
  127605. get specularOutput(): NodeMaterialConnectionPoint;
  127606. /**
  127607. * Gets the shadow output component
  127608. */
  127609. get shadow(): NodeMaterialConnectionPoint;
  127610. autoConfigure(material: NodeMaterial): void;
  127611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127612. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127614. private _injectVertexCode;
  127615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127616. serialize(): any;
  127617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127618. }
  127619. }
  127620. declare module BABYLON {
  127621. /**
  127622. * Block used to multiply 2 values
  127623. */
  127624. export class MultiplyBlock extends NodeMaterialBlock {
  127625. /**
  127626. * Creates a new MultiplyBlock
  127627. * @param name defines the block name
  127628. */
  127629. constructor(name: string);
  127630. /**
  127631. * Gets the current class name
  127632. * @returns the class name
  127633. */
  127634. getClassName(): string;
  127635. /**
  127636. * Gets the left operand input component
  127637. */
  127638. get left(): NodeMaterialConnectionPoint;
  127639. /**
  127640. * Gets the right operand input component
  127641. */
  127642. get right(): NodeMaterialConnectionPoint;
  127643. /**
  127644. * Gets the output component
  127645. */
  127646. get output(): NodeMaterialConnectionPoint;
  127647. protected _buildBlock(state: NodeMaterialBuildState): this;
  127648. }
  127649. }
  127650. declare module BABYLON {
  127651. /**
  127652. * Block used to add 2 vectors
  127653. */
  127654. export class AddBlock extends NodeMaterialBlock {
  127655. /**
  127656. * Creates a new AddBlock
  127657. * @param name defines the block name
  127658. */
  127659. constructor(name: string);
  127660. /**
  127661. * Gets the current class name
  127662. * @returns the class name
  127663. */
  127664. getClassName(): string;
  127665. /**
  127666. * Gets the left operand input component
  127667. */
  127668. get left(): NodeMaterialConnectionPoint;
  127669. /**
  127670. * Gets the right operand input component
  127671. */
  127672. get right(): NodeMaterialConnectionPoint;
  127673. /**
  127674. * Gets the output component
  127675. */
  127676. get output(): NodeMaterialConnectionPoint;
  127677. protected _buildBlock(state: NodeMaterialBuildState): this;
  127678. }
  127679. }
  127680. declare module BABYLON {
  127681. /**
  127682. * Block used to scale a vector by a float
  127683. */
  127684. export class ScaleBlock extends NodeMaterialBlock {
  127685. /**
  127686. * Creates a new ScaleBlock
  127687. * @param name defines the block name
  127688. */
  127689. constructor(name: string);
  127690. /**
  127691. * Gets the current class name
  127692. * @returns the class name
  127693. */
  127694. getClassName(): string;
  127695. /**
  127696. * Gets the input component
  127697. */
  127698. get input(): NodeMaterialConnectionPoint;
  127699. /**
  127700. * Gets the factor input component
  127701. */
  127702. get factor(): NodeMaterialConnectionPoint;
  127703. /**
  127704. * Gets the output component
  127705. */
  127706. get output(): NodeMaterialConnectionPoint;
  127707. protected _buildBlock(state: NodeMaterialBuildState): this;
  127708. }
  127709. }
  127710. declare module BABYLON {
  127711. /**
  127712. * Block used to clamp a float
  127713. */
  127714. export class ClampBlock extends NodeMaterialBlock {
  127715. /** Gets or sets the minimum range */
  127716. minimum: number;
  127717. /** Gets or sets the maximum range */
  127718. maximum: number;
  127719. /**
  127720. * Creates a new ClampBlock
  127721. * @param name defines the block name
  127722. */
  127723. constructor(name: string);
  127724. /**
  127725. * Gets the current class name
  127726. * @returns the class name
  127727. */
  127728. getClassName(): string;
  127729. /**
  127730. * Gets the value input component
  127731. */
  127732. get value(): NodeMaterialConnectionPoint;
  127733. /**
  127734. * Gets the output component
  127735. */
  127736. get output(): NodeMaterialConnectionPoint;
  127737. protected _buildBlock(state: NodeMaterialBuildState): this;
  127738. protected _dumpPropertiesCode(): string;
  127739. serialize(): any;
  127740. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127741. }
  127742. }
  127743. declare module BABYLON {
  127744. /**
  127745. * Block used to apply a cross product between 2 vectors
  127746. */
  127747. export class CrossBlock extends NodeMaterialBlock {
  127748. /**
  127749. * Creates a new CrossBlock
  127750. * @param name defines the block name
  127751. */
  127752. constructor(name: string);
  127753. /**
  127754. * Gets the current class name
  127755. * @returns the class name
  127756. */
  127757. getClassName(): string;
  127758. /**
  127759. * Gets the left operand input component
  127760. */
  127761. get left(): NodeMaterialConnectionPoint;
  127762. /**
  127763. * Gets the right operand input component
  127764. */
  127765. get right(): NodeMaterialConnectionPoint;
  127766. /**
  127767. * Gets the output component
  127768. */
  127769. get output(): NodeMaterialConnectionPoint;
  127770. protected _buildBlock(state: NodeMaterialBuildState): this;
  127771. }
  127772. }
  127773. declare module BABYLON {
  127774. /**
  127775. * Block used to apply a dot product between 2 vectors
  127776. */
  127777. export class DotBlock extends NodeMaterialBlock {
  127778. /**
  127779. * Creates a new DotBlock
  127780. * @param name defines the block name
  127781. */
  127782. constructor(name: string);
  127783. /**
  127784. * Gets the current class name
  127785. * @returns the class name
  127786. */
  127787. getClassName(): string;
  127788. /**
  127789. * Gets the left operand input component
  127790. */
  127791. get left(): NodeMaterialConnectionPoint;
  127792. /**
  127793. * Gets the right operand input component
  127794. */
  127795. get right(): NodeMaterialConnectionPoint;
  127796. /**
  127797. * Gets the output component
  127798. */
  127799. get output(): NodeMaterialConnectionPoint;
  127800. protected _buildBlock(state: NodeMaterialBuildState): this;
  127801. }
  127802. }
  127803. declare module BABYLON {
  127804. /**
  127805. * Block used to remap a float from a range to a new one
  127806. */
  127807. export class RemapBlock extends NodeMaterialBlock {
  127808. /**
  127809. * Gets or sets the source range
  127810. */
  127811. sourceRange: Vector2;
  127812. /**
  127813. * Gets or sets the target range
  127814. */
  127815. targetRange: Vector2;
  127816. /**
  127817. * Creates a new RemapBlock
  127818. * @param name defines the block name
  127819. */
  127820. constructor(name: string);
  127821. /**
  127822. * Gets the current class name
  127823. * @returns the class name
  127824. */
  127825. getClassName(): string;
  127826. /**
  127827. * Gets the input component
  127828. */
  127829. get input(): NodeMaterialConnectionPoint;
  127830. /**
  127831. * Gets the source min input component
  127832. */
  127833. get sourceMin(): NodeMaterialConnectionPoint;
  127834. /**
  127835. * Gets the source max input component
  127836. */
  127837. get sourceMax(): NodeMaterialConnectionPoint;
  127838. /**
  127839. * Gets the target min input component
  127840. */
  127841. get targetMin(): NodeMaterialConnectionPoint;
  127842. /**
  127843. * Gets the target max input component
  127844. */
  127845. get targetMax(): NodeMaterialConnectionPoint;
  127846. /**
  127847. * Gets the output component
  127848. */
  127849. get output(): NodeMaterialConnectionPoint;
  127850. protected _buildBlock(state: NodeMaterialBuildState): this;
  127851. protected _dumpPropertiesCode(): string;
  127852. serialize(): any;
  127853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127854. }
  127855. }
  127856. declare module BABYLON {
  127857. /**
  127858. * Block used to normalize a vector
  127859. */
  127860. export class NormalizeBlock extends NodeMaterialBlock {
  127861. /**
  127862. * Creates a new NormalizeBlock
  127863. * @param name defines the block name
  127864. */
  127865. constructor(name: string);
  127866. /**
  127867. * Gets the current class name
  127868. * @returns the class name
  127869. */
  127870. getClassName(): string;
  127871. /**
  127872. * Gets the input component
  127873. */
  127874. get input(): NodeMaterialConnectionPoint;
  127875. /**
  127876. * Gets the output component
  127877. */
  127878. get output(): NodeMaterialConnectionPoint;
  127879. protected _buildBlock(state: NodeMaterialBuildState): this;
  127880. }
  127881. }
  127882. declare module BABYLON {
  127883. /**
  127884. * Operations supported by the Trigonometry block
  127885. */
  127886. export enum TrigonometryBlockOperations {
  127887. /** Cos */
  127888. Cos = 0,
  127889. /** Sin */
  127890. Sin = 1,
  127891. /** Abs */
  127892. Abs = 2,
  127893. /** Exp */
  127894. Exp = 3,
  127895. /** Exp2 */
  127896. Exp2 = 4,
  127897. /** Round */
  127898. Round = 5,
  127899. /** Floor */
  127900. Floor = 6,
  127901. /** Ceiling */
  127902. Ceiling = 7,
  127903. /** Square root */
  127904. Sqrt = 8,
  127905. /** Log */
  127906. Log = 9,
  127907. /** Tangent */
  127908. Tan = 10,
  127909. /** Arc tangent */
  127910. ArcTan = 11,
  127911. /** Arc cosinus */
  127912. ArcCos = 12,
  127913. /** Arc sinus */
  127914. ArcSin = 13,
  127915. /** Fraction */
  127916. Fract = 14,
  127917. /** Sign */
  127918. Sign = 15,
  127919. /** To radians (from degrees) */
  127920. Radians = 16,
  127921. /** To degrees (from radians) */
  127922. Degrees = 17
  127923. }
  127924. /**
  127925. * Block used to apply trigonometry operation to floats
  127926. */
  127927. export class TrigonometryBlock extends NodeMaterialBlock {
  127928. /**
  127929. * Gets or sets the operation applied by the block
  127930. */
  127931. operation: TrigonometryBlockOperations;
  127932. /**
  127933. * Creates a new TrigonometryBlock
  127934. * @param name defines the block name
  127935. */
  127936. constructor(name: string);
  127937. /**
  127938. * Gets the current class name
  127939. * @returns the class name
  127940. */
  127941. getClassName(): string;
  127942. /**
  127943. * Gets the input component
  127944. */
  127945. get input(): NodeMaterialConnectionPoint;
  127946. /**
  127947. * Gets the output component
  127948. */
  127949. get output(): NodeMaterialConnectionPoint;
  127950. protected _buildBlock(state: NodeMaterialBuildState): this;
  127951. serialize(): any;
  127952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127953. protected _dumpPropertiesCode(): string;
  127954. }
  127955. }
  127956. declare module BABYLON {
  127957. /**
  127958. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127959. */
  127960. export class ColorMergerBlock extends NodeMaterialBlock {
  127961. /**
  127962. * Create a new ColorMergerBlock
  127963. * @param name defines the block name
  127964. */
  127965. constructor(name: string);
  127966. /**
  127967. * Gets the current class name
  127968. * @returns the class name
  127969. */
  127970. getClassName(): string;
  127971. /**
  127972. * Gets the rgb component (input)
  127973. */
  127974. get rgbIn(): NodeMaterialConnectionPoint;
  127975. /**
  127976. * Gets the r component (input)
  127977. */
  127978. get r(): NodeMaterialConnectionPoint;
  127979. /**
  127980. * Gets the g component (input)
  127981. */
  127982. get g(): NodeMaterialConnectionPoint;
  127983. /**
  127984. * Gets the b component (input)
  127985. */
  127986. get b(): NodeMaterialConnectionPoint;
  127987. /**
  127988. * Gets the a component (input)
  127989. */
  127990. get a(): NodeMaterialConnectionPoint;
  127991. /**
  127992. * Gets the rgba component (output)
  127993. */
  127994. get rgba(): NodeMaterialConnectionPoint;
  127995. /**
  127996. * Gets the rgb component (output)
  127997. */
  127998. get rgbOut(): NodeMaterialConnectionPoint;
  127999. /**
  128000. * Gets the rgb component (output)
  128001. * @deprecated Please use rgbOut instead.
  128002. */
  128003. get rgb(): NodeMaterialConnectionPoint;
  128004. protected _buildBlock(state: NodeMaterialBuildState): this;
  128005. }
  128006. }
  128007. declare module BABYLON {
  128008. /**
  128009. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  128010. */
  128011. export class VectorMergerBlock extends NodeMaterialBlock {
  128012. /**
  128013. * Create a new VectorMergerBlock
  128014. * @param name defines the block name
  128015. */
  128016. constructor(name: string);
  128017. /**
  128018. * Gets the current class name
  128019. * @returns the class name
  128020. */
  128021. getClassName(): string;
  128022. /**
  128023. * Gets the xyz component (input)
  128024. */
  128025. get xyzIn(): NodeMaterialConnectionPoint;
  128026. /**
  128027. * Gets the xy component (input)
  128028. */
  128029. get xyIn(): NodeMaterialConnectionPoint;
  128030. /**
  128031. * Gets the x component (input)
  128032. */
  128033. get x(): NodeMaterialConnectionPoint;
  128034. /**
  128035. * Gets the y component (input)
  128036. */
  128037. get y(): NodeMaterialConnectionPoint;
  128038. /**
  128039. * Gets the z component (input)
  128040. */
  128041. get z(): NodeMaterialConnectionPoint;
  128042. /**
  128043. * Gets the w component (input)
  128044. */
  128045. get w(): NodeMaterialConnectionPoint;
  128046. /**
  128047. * Gets the xyzw component (output)
  128048. */
  128049. get xyzw(): NodeMaterialConnectionPoint;
  128050. /**
  128051. * Gets the xyz component (output)
  128052. */
  128053. get xyzOut(): NodeMaterialConnectionPoint;
  128054. /**
  128055. * Gets the xy component (output)
  128056. */
  128057. get xyOut(): NodeMaterialConnectionPoint;
  128058. /**
  128059. * Gets the xy component (output)
  128060. * @deprecated Please use xyOut instead.
  128061. */
  128062. get xy(): NodeMaterialConnectionPoint;
  128063. /**
  128064. * Gets the xyz component (output)
  128065. * @deprecated Please use xyzOut instead.
  128066. */
  128067. get xyz(): NodeMaterialConnectionPoint;
  128068. protected _buildBlock(state: NodeMaterialBuildState): this;
  128069. }
  128070. }
  128071. declare module BABYLON {
  128072. /**
  128073. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  128074. */
  128075. export class ColorSplitterBlock extends NodeMaterialBlock {
  128076. /**
  128077. * Create a new ColorSplitterBlock
  128078. * @param name defines the block name
  128079. */
  128080. constructor(name: string);
  128081. /**
  128082. * Gets the current class name
  128083. * @returns the class name
  128084. */
  128085. getClassName(): string;
  128086. /**
  128087. * Gets the rgba component (input)
  128088. */
  128089. get rgba(): NodeMaterialConnectionPoint;
  128090. /**
  128091. * Gets the rgb component (input)
  128092. */
  128093. get rgbIn(): NodeMaterialConnectionPoint;
  128094. /**
  128095. * Gets the rgb component (output)
  128096. */
  128097. get rgbOut(): NodeMaterialConnectionPoint;
  128098. /**
  128099. * Gets the r component (output)
  128100. */
  128101. get r(): NodeMaterialConnectionPoint;
  128102. /**
  128103. * Gets the g component (output)
  128104. */
  128105. get g(): NodeMaterialConnectionPoint;
  128106. /**
  128107. * Gets the b component (output)
  128108. */
  128109. get b(): NodeMaterialConnectionPoint;
  128110. /**
  128111. * Gets the a component (output)
  128112. */
  128113. get a(): NodeMaterialConnectionPoint;
  128114. protected _inputRename(name: string): string;
  128115. protected _outputRename(name: string): string;
  128116. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128117. }
  128118. }
  128119. declare module BABYLON {
  128120. /**
  128121. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  128122. */
  128123. export class VectorSplitterBlock extends NodeMaterialBlock {
  128124. /**
  128125. * Create a new VectorSplitterBlock
  128126. * @param name defines the block name
  128127. */
  128128. constructor(name: string);
  128129. /**
  128130. * Gets the current class name
  128131. * @returns the class name
  128132. */
  128133. getClassName(): string;
  128134. /**
  128135. * Gets the xyzw component (input)
  128136. */
  128137. get xyzw(): NodeMaterialConnectionPoint;
  128138. /**
  128139. * Gets the xyz component (input)
  128140. */
  128141. get xyzIn(): NodeMaterialConnectionPoint;
  128142. /**
  128143. * Gets the xy component (input)
  128144. */
  128145. get xyIn(): NodeMaterialConnectionPoint;
  128146. /**
  128147. * Gets the xyz component (output)
  128148. */
  128149. get xyzOut(): NodeMaterialConnectionPoint;
  128150. /**
  128151. * Gets the xy component (output)
  128152. */
  128153. get xyOut(): NodeMaterialConnectionPoint;
  128154. /**
  128155. * Gets the x component (output)
  128156. */
  128157. get x(): NodeMaterialConnectionPoint;
  128158. /**
  128159. * Gets the y component (output)
  128160. */
  128161. get y(): NodeMaterialConnectionPoint;
  128162. /**
  128163. * Gets the z component (output)
  128164. */
  128165. get z(): NodeMaterialConnectionPoint;
  128166. /**
  128167. * Gets the w component (output)
  128168. */
  128169. get w(): NodeMaterialConnectionPoint;
  128170. protected _inputRename(name: string): string;
  128171. protected _outputRename(name: string): string;
  128172. protected _buildBlock(state: NodeMaterialBuildState): this;
  128173. }
  128174. }
  128175. declare module BABYLON {
  128176. /**
  128177. * Block used to lerp between 2 values
  128178. */
  128179. export class LerpBlock extends NodeMaterialBlock {
  128180. /**
  128181. * Creates a new LerpBlock
  128182. * @param name defines the block name
  128183. */
  128184. constructor(name: string);
  128185. /**
  128186. * Gets the current class name
  128187. * @returns the class name
  128188. */
  128189. getClassName(): string;
  128190. /**
  128191. * Gets the left operand input component
  128192. */
  128193. get left(): NodeMaterialConnectionPoint;
  128194. /**
  128195. * Gets the right operand input component
  128196. */
  128197. get right(): NodeMaterialConnectionPoint;
  128198. /**
  128199. * Gets the gradient operand input component
  128200. */
  128201. get gradient(): NodeMaterialConnectionPoint;
  128202. /**
  128203. * Gets the output component
  128204. */
  128205. get output(): NodeMaterialConnectionPoint;
  128206. protected _buildBlock(state: NodeMaterialBuildState): this;
  128207. }
  128208. }
  128209. declare module BABYLON {
  128210. /**
  128211. * Block used to divide 2 vectors
  128212. */
  128213. export class DivideBlock extends NodeMaterialBlock {
  128214. /**
  128215. * Creates a new DivideBlock
  128216. * @param name defines the block name
  128217. */
  128218. constructor(name: string);
  128219. /**
  128220. * Gets the current class name
  128221. * @returns the class name
  128222. */
  128223. getClassName(): string;
  128224. /**
  128225. * Gets the left operand input component
  128226. */
  128227. get left(): NodeMaterialConnectionPoint;
  128228. /**
  128229. * Gets the right operand input component
  128230. */
  128231. get right(): NodeMaterialConnectionPoint;
  128232. /**
  128233. * Gets the output component
  128234. */
  128235. get output(): NodeMaterialConnectionPoint;
  128236. protected _buildBlock(state: NodeMaterialBuildState): this;
  128237. }
  128238. }
  128239. declare module BABYLON {
  128240. /**
  128241. * Block used to subtract 2 vectors
  128242. */
  128243. export class SubtractBlock extends NodeMaterialBlock {
  128244. /**
  128245. * Creates a new SubtractBlock
  128246. * @param name defines the block name
  128247. */
  128248. constructor(name: string);
  128249. /**
  128250. * Gets the current class name
  128251. * @returns the class name
  128252. */
  128253. getClassName(): string;
  128254. /**
  128255. * Gets the left operand input component
  128256. */
  128257. get left(): NodeMaterialConnectionPoint;
  128258. /**
  128259. * Gets the right operand input component
  128260. */
  128261. get right(): NodeMaterialConnectionPoint;
  128262. /**
  128263. * Gets the output component
  128264. */
  128265. get output(): NodeMaterialConnectionPoint;
  128266. protected _buildBlock(state: NodeMaterialBuildState): this;
  128267. }
  128268. }
  128269. declare module BABYLON {
  128270. /**
  128271. * Block used to step a value
  128272. */
  128273. export class StepBlock extends NodeMaterialBlock {
  128274. /**
  128275. * Creates a new StepBlock
  128276. * @param name defines the block name
  128277. */
  128278. constructor(name: string);
  128279. /**
  128280. * Gets the current class name
  128281. * @returns the class name
  128282. */
  128283. getClassName(): string;
  128284. /**
  128285. * Gets the value operand input component
  128286. */
  128287. get value(): NodeMaterialConnectionPoint;
  128288. /**
  128289. * Gets the edge operand input component
  128290. */
  128291. get edge(): NodeMaterialConnectionPoint;
  128292. /**
  128293. * Gets the output component
  128294. */
  128295. get output(): NodeMaterialConnectionPoint;
  128296. protected _buildBlock(state: NodeMaterialBuildState): this;
  128297. }
  128298. }
  128299. declare module BABYLON {
  128300. /**
  128301. * Block used to get the opposite (1 - x) of a value
  128302. */
  128303. export class OneMinusBlock extends NodeMaterialBlock {
  128304. /**
  128305. * Creates a new OneMinusBlock
  128306. * @param name defines the block name
  128307. */
  128308. constructor(name: string);
  128309. /**
  128310. * Gets the current class name
  128311. * @returns the class name
  128312. */
  128313. getClassName(): string;
  128314. /**
  128315. * Gets the input component
  128316. */
  128317. get input(): NodeMaterialConnectionPoint;
  128318. /**
  128319. * Gets the output component
  128320. */
  128321. get output(): NodeMaterialConnectionPoint;
  128322. protected _buildBlock(state: NodeMaterialBuildState): this;
  128323. }
  128324. }
  128325. declare module BABYLON {
  128326. /**
  128327. * Block used to get the view direction
  128328. */
  128329. export class ViewDirectionBlock extends NodeMaterialBlock {
  128330. /**
  128331. * Creates a new ViewDirectionBlock
  128332. * @param name defines the block name
  128333. */
  128334. constructor(name: string);
  128335. /**
  128336. * Gets the current class name
  128337. * @returns the class name
  128338. */
  128339. getClassName(): string;
  128340. /**
  128341. * Gets the world position component
  128342. */
  128343. get worldPosition(): NodeMaterialConnectionPoint;
  128344. /**
  128345. * Gets the camera position component
  128346. */
  128347. get cameraPosition(): NodeMaterialConnectionPoint;
  128348. /**
  128349. * Gets the output component
  128350. */
  128351. get output(): NodeMaterialConnectionPoint;
  128352. autoConfigure(material: NodeMaterial): void;
  128353. protected _buildBlock(state: NodeMaterialBuildState): this;
  128354. }
  128355. }
  128356. declare module BABYLON {
  128357. /**
  128358. * Block used to compute fresnel value
  128359. */
  128360. export class FresnelBlock extends NodeMaterialBlock {
  128361. /**
  128362. * Create a new FresnelBlock
  128363. * @param name defines the block name
  128364. */
  128365. constructor(name: string);
  128366. /**
  128367. * Gets the current class name
  128368. * @returns the class name
  128369. */
  128370. getClassName(): string;
  128371. /**
  128372. * Gets the world normal input component
  128373. */
  128374. get worldNormal(): NodeMaterialConnectionPoint;
  128375. /**
  128376. * Gets the view direction input component
  128377. */
  128378. get viewDirection(): NodeMaterialConnectionPoint;
  128379. /**
  128380. * Gets the bias input component
  128381. */
  128382. get bias(): NodeMaterialConnectionPoint;
  128383. /**
  128384. * Gets the camera (or eye) position component
  128385. */
  128386. get power(): NodeMaterialConnectionPoint;
  128387. /**
  128388. * Gets the fresnel output component
  128389. */
  128390. get fresnel(): NodeMaterialConnectionPoint;
  128391. autoConfigure(material: NodeMaterial): void;
  128392. protected _buildBlock(state: NodeMaterialBuildState): this;
  128393. }
  128394. }
  128395. declare module BABYLON {
  128396. /**
  128397. * Block used to get the max of 2 values
  128398. */
  128399. export class MaxBlock extends NodeMaterialBlock {
  128400. /**
  128401. * Creates a new MaxBlock
  128402. * @param name defines the block name
  128403. */
  128404. constructor(name: string);
  128405. /**
  128406. * Gets the current class name
  128407. * @returns the class name
  128408. */
  128409. getClassName(): string;
  128410. /**
  128411. * Gets the left operand input component
  128412. */
  128413. get left(): NodeMaterialConnectionPoint;
  128414. /**
  128415. * Gets the right operand input component
  128416. */
  128417. get right(): NodeMaterialConnectionPoint;
  128418. /**
  128419. * Gets the output component
  128420. */
  128421. get output(): NodeMaterialConnectionPoint;
  128422. protected _buildBlock(state: NodeMaterialBuildState): this;
  128423. }
  128424. }
  128425. declare module BABYLON {
  128426. /**
  128427. * Block used to get the min of 2 values
  128428. */
  128429. export class MinBlock extends NodeMaterialBlock {
  128430. /**
  128431. * Creates a new MinBlock
  128432. * @param name defines the block name
  128433. */
  128434. constructor(name: string);
  128435. /**
  128436. * Gets the current class name
  128437. * @returns the class name
  128438. */
  128439. getClassName(): string;
  128440. /**
  128441. * Gets the left operand input component
  128442. */
  128443. get left(): NodeMaterialConnectionPoint;
  128444. /**
  128445. * Gets the right operand input component
  128446. */
  128447. get right(): NodeMaterialConnectionPoint;
  128448. /**
  128449. * Gets the output component
  128450. */
  128451. get output(): NodeMaterialConnectionPoint;
  128452. protected _buildBlock(state: NodeMaterialBuildState): this;
  128453. }
  128454. }
  128455. declare module BABYLON {
  128456. /**
  128457. * Block used to get the distance between 2 values
  128458. */
  128459. export class DistanceBlock extends NodeMaterialBlock {
  128460. /**
  128461. * Creates a new DistanceBlock
  128462. * @param name defines the block name
  128463. */
  128464. constructor(name: string);
  128465. /**
  128466. * Gets the current class name
  128467. * @returns the class name
  128468. */
  128469. getClassName(): string;
  128470. /**
  128471. * Gets the left operand input component
  128472. */
  128473. get left(): NodeMaterialConnectionPoint;
  128474. /**
  128475. * Gets the right operand input component
  128476. */
  128477. get right(): NodeMaterialConnectionPoint;
  128478. /**
  128479. * Gets the output component
  128480. */
  128481. get output(): NodeMaterialConnectionPoint;
  128482. protected _buildBlock(state: NodeMaterialBuildState): this;
  128483. }
  128484. }
  128485. declare module BABYLON {
  128486. /**
  128487. * Block used to get the length of a vector
  128488. */
  128489. export class LengthBlock extends NodeMaterialBlock {
  128490. /**
  128491. * Creates a new LengthBlock
  128492. * @param name defines the block name
  128493. */
  128494. constructor(name: string);
  128495. /**
  128496. * Gets the current class name
  128497. * @returns the class name
  128498. */
  128499. getClassName(): string;
  128500. /**
  128501. * Gets the value input component
  128502. */
  128503. get value(): NodeMaterialConnectionPoint;
  128504. /**
  128505. * Gets the output component
  128506. */
  128507. get output(): NodeMaterialConnectionPoint;
  128508. protected _buildBlock(state: NodeMaterialBuildState): this;
  128509. }
  128510. }
  128511. declare module BABYLON {
  128512. /**
  128513. * Block used to get negative version of a value (i.e. x * -1)
  128514. */
  128515. export class NegateBlock extends NodeMaterialBlock {
  128516. /**
  128517. * Creates a new NegateBlock
  128518. * @param name defines the block name
  128519. */
  128520. constructor(name: string);
  128521. /**
  128522. * Gets the current class name
  128523. * @returns the class name
  128524. */
  128525. getClassName(): string;
  128526. /**
  128527. * Gets the value input component
  128528. */
  128529. get value(): NodeMaterialConnectionPoint;
  128530. /**
  128531. * Gets the output component
  128532. */
  128533. get output(): NodeMaterialConnectionPoint;
  128534. protected _buildBlock(state: NodeMaterialBuildState): this;
  128535. }
  128536. }
  128537. declare module BABYLON {
  128538. /**
  128539. * Block used to get the value of the first parameter raised to the power of the second
  128540. */
  128541. export class PowBlock extends NodeMaterialBlock {
  128542. /**
  128543. * Creates a new PowBlock
  128544. * @param name defines the block name
  128545. */
  128546. constructor(name: string);
  128547. /**
  128548. * Gets the current class name
  128549. * @returns the class name
  128550. */
  128551. getClassName(): string;
  128552. /**
  128553. * Gets the value operand input component
  128554. */
  128555. get value(): NodeMaterialConnectionPoint;
  128556. /**
  128557. * Gets the power operand input component
  128558. */
  128559. get power(): NodeMaterialConnectionPoint;
  128560. /**
  128561. * Gets the output component
  128562. */
  128563. get output(): NodeMaterialConnectionPoint;
  128564. protected _buildBlock(state: NodeMaterialBuildState): this;
  128565. }
  128566. }
  128567. declare module BABYLON {
  128568. /**
  128569. * Block used to get a random number
  128570. */
  128571. export class RandomNumberBlock extends NodeMaterialBlock {
  128572. /**
  128573. * Creates a new RandomNumberBlock
  128574. * @param name defines the block name
  128575. */
  128576. constructor(name: string);
  128577. /**
  128578. * Gets the current class name
  128579. * @returns the class name
  128580. */
  128581. getClassName(): string;
  128582. /**
  128583. * Gets the seed input component
  128584. */
  128585. get seed(): NodeMaterialConnectionPoint;
  128586. /**
  128587. * Gets the output component
  128588. */
  128589. get output(): NodeMaterialConnectionPoint;
  128590. protected _buildBlock(state: NodeMaterialBuildState): this;
  128591. }
  128592. }
  128593. declare module BABYLON {
  128594. /**
  128595. * Block used to compute arc tangent of 2 values
  128596. */
  128597. export class ArcTan2Block extends NodeMaterialBlock {
  128598. /**
  128599. * Creates a new ArcTan2Block
  128600. * @param name defines the block name
  128601. */
  128602. constructor(name: string);
  128603. /**
  128604. * Gets the current class name
  128605. * @returns the class name
  128606. */
  128607. getClassName(): string;
  128608. /**
  128609. * Gets the x operand input component
  128610. */
  128611. get x(): NodeMaterialConnectionPoint;
  128612. /**
  128613. * Gets the y operand input component
  128614. */
  128615. get y(): NodeMaterialConnectionPoint;
  128616. /**
  128617. * Gets the output component
  128618. */
  128619. get output(): NodeMaterialConnectionPoint;
  128620. protected _buildBlock(state: NodeMaterialBuildState): this;
  128621. }
  128622. }
  128623. declare module BABYLON {
  128624. /**
  128625. * Block used to smooth step a value
  128626. */
  128627. export class SmoothStepBlock extends NodeMaterialBlock {
  128628. /**
  128629. * Creates a new SmoothStepBlock
  128630. * @param name defines the block name
  128631. */
  128632. constructor(name: string);
  128633. /**
  128634. * Gets the current class name
  128635. * @returns the class name
  128636. */
  128637. getClassName(): string;
  128638. /**
  128639. * Gets the value operand input component
  128640. */
  128641. get value(): NodeMaterialConnectionPoint;
  128642. /**
  128643. * Gets the first edge operand input component
  128644. */
  128645. get edge0(): NodeMaterialConnectionPoint;
  128646. /**
  128647. * Gets the second edge operand input component
  128648. */
  128649. get edge1(): NodeMaterialConnectionPoint;
  128650. /**
  128651. * Gets the output component
  128652. */
  128653. get output(): NodeMaterialConnectionPoint;
  128654. protected _buildBlock(state: NodeMaterialBuildState): this;
  128655. }
  128656. }
  128657. declare module BABYLON {
  128658. /**
  128659. * Block used to get the reciprocal (1 / x) of a value
  128660. */
  128661. export class ReciprocalBlock extends NodeMaterialBlock {
  128662. /**
  128663. * Creates a new ReciprocalBlock
  128664. * @param name defines the block name
  128665. */
  128666. constructor(name: string);
  128667. /**
  128668. * Gets the current class name
  128669. * @returns the class name
  128670. */
  128671. getClassName(): string;
  128672. /**
  128673. * Gets the input component
  128674. */
  128675. get input(): NodeMaterialConnectionPoint;
  128676. /**
  128677. * Gets the output component
  128678. */
  128679. get output(): NodeMaterialConnectionPoint;
  128680. protected _buildBlock(state: NodeMaterialBuildState): this;
  128681. }
  128682. }
  128683. declare module BABYLON {
  128684. /**
  128685. * Block used to replace a color by another one
  128686. */
  128687. export class ReplaceColorBlock extends NodeMaterialBlock {
  128688. /**
  128689. * Creates a new ReplaceColorBlock
  128690. * @param name defines the block name
  128691. */
  128692. constructor(name: string);
  128693. /**
  128694. * Gets the current class name
  128695. * @returns the class name
  128696. */
  128697. getClassName(): string;
  128698. /**
  128699. * Gets the value input component
  128700. */
  128701. get value(): NodeMaterialConnectionPoint;
  128702. /**
  128703. * Gets the reference input component
  128704. */
  128705. get reference(): NodeMaterialConnectionPoint;
  128706. /**
  128707. * Gets the distance input component
  128708. */
  128709. get distance(): NodeMaterialConnectionPoint;
  128710. /**
  128711. * Gets the replacement input component
  128712. */
  128713. get replacement(): NodeMaterialConnectionPoint;
  128714. /**
  128715. * Gets the output component
  128716. */
  128717. get output(): NodeMaterialConnectionPoint;
  128718. protected _buildBlock(state: NodeMaterialBuildState): this;
  128719. }
  128720. }
  128721. declare module BABYLON {
  128722. /**
  128723. * Block used to posterize a value
  128724. * @see https://en.wikipedia.org/wiki/Posterization
  128725. */
  128726. export class PosterizeBlock extends NodeMaterialBlock {
  128727. /**
  128728. * Creates a new PosterizeBlock
  128729. * @param name defines the block name
  128730. */
  128731. constructor(name: string);
  128732. /**
  128733. * Gets the current class name
  128734. * @returns the class name
  128735. */
  128736. getClassName(): string;
  128737. /**
  128738. * Gets the value input component
  128739. */
  128740. get value(): NodeMaterialConnectionPoint;
  128741. /**
  128742. * Gets the steps input component
  128743. */
  128744. get steps(): NodeMaterialConnectionPoint;
  128745. /**
  128746. * Gets the output component
  128747. */
  128748. get output(): NodeMaterialConnectionPoint;
  128749. protected _buildBlock(state: NodeMaterialBuildState): this;
  128750. }
  128751. }
  128752. declare module BABYLON {
  128753. /**
  128754. * Operations supported by the Wave block
  128755. */
  128756. export enum WaveBlockKind {
  128757. /** SawTooth */
  128758. SawTooth = 0,
  128759. /** Square */
  128760. Square = 1,
  128761. /** Triangle */
  128762. Triangle = 2
  128763. }
  128764. /**
  128765. * Block used to apply wave operation to floats
  128766. */
  128767. export class WaveBlock extends NodeMaterialBlock {
  128768. /**
  128769. * Gets or sets the kibnd of wave to be applied by the block
  128770. */
  128771. kind: WaveBlockKind;
  128772. /**
  128773. * Creates a new WaveBlock
  128774. * @param name defines the block name
  128775. */
  128776. constructor(name: string);
  128777. /**
  128778. * Gets the current class name
  128779. * @returns the class name
  128780. */
  128781. getClassName(): string;
  128782. /**
  128783. * Gets the input component
  128784. */
  128785. get input(): NodeMaterialConnectionPoint;
  128786. /**
  128787. * Gets the output component
  128788. */
  128789. get output(): NodeMaterialConnectionPoint;
  128790. protected _buildBlock(state: NodeMaterialBuildState): this;
  128791. serialize(): any;
  128792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128793. }
  128794. }
  128795. declare module BABYLON {
  128796. /**
  128797. * Class used to store a color step for the GradientBlock
  128798. */
  128799. export class GradientBlockColorStep {
  128800. /**
  128801. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128802. */
  128803. step: number;
  128804. /**
  128805. * Gets or sets the color associated with this step
  128806. */
  128807. color: Color3;
  128808. /**
  128809. * Creates a new GradientBlockColorStep
  128810. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128811. * @param color defines the color associated with this step
  128812. */
  128813. constructor(
  128814. /**
  128815. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128816. */
  128817. step: number,
  128818. /**
  128819. * Gets or sets the color associated with this step
  128820. */
  128821. color: Color3);
  128822. }
  128823. /**
  128824. * Block used to return a color from a gradient based on an input value between 0 and 1
  128825. */
  128826. export class GradientBlock extends NodeMaterialBlock {
  128827. /**
  128828. * Gets or sets the list of color steps
  128829. */
  128830. colorSteps: GradientBlockColorStep[];
  128831. /**
  128832. * Creates a new GradientBlock
  128833. * @param name defines the block name
  128834. */
  128835. constructor(name: string);
  128836. /**
  128837. * Gets the current class name
  128838. * @returns the class name
  128839. */
  128840. getClassName(): string;
  128841. /**
  128842. * Gets the gradient input component
  128843. */
  128844. get gradient(): NodeMaterialConnectionPoint;
  128845. /**
  128846. * Gets the output component
  128847. */
  128848. get output(): NodeMaterialConnectionPoint;
  128849. private _writeColorConstant;
  128850. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128851. serialize(): any;
  128852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128853. protected _dumpPropertiesCode(): string;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /**
  128858. * Block used to normalize lerp between 2 values
  128859. */
  128860. export class NLerpBlock extends NodeMaterialBlock {
  128861. /**
  128862. * Creates a new NLerpBlock
  128863. * @param name defines the block name
  128864. */
  128865. constructor(name: string);
  128866. /**
  128867. * Gets the current class name
  128868. * @returns the class name
  128869. */
  128870. getClassName(): string;
  128871. /**
  128872. * Gets the left operand input component
  128873. */
  128874. get left(): NodeMaterialConnectionPoint;
  128875. /**
  128876. * Gets the right operand input component
  128877. */
  128878. get right(): NodeMaterialConnectionPoint;
  128879. /**
  128880. * Gets the gradient operand input component
  128881. */
  128882. get gradient(): NodeMaterialConnectionPoint;
  128883. /**
  128884. * Gets the output component
  128885. */
  128886. get output(): NodeMaterialConnectionPoint;
  128887. protected _buildBlock(state: NodeMaterialBuildState): this;
  128888. }
  128889. }
  128890. declare module BABYLON {
  128891. /**
  128892. * block used to Generate a Worley Noise 3D Noise Pattern
  128893. */
  128894. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128895. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128896. manhattanDistance: boolean;
  128897. /**
  128898. * Creates a new WorleyNoise3DBlock
  128899. * @param name defines the block name
  128900. */
  128901. constructor(name: string);
  128902. /**
  128903. * Gets the current class name
  128904. * @returns the class name
  128905. */
  128906. getClassName(): string;
  128907. /**
  128908. * Gets the seed input component
  128909. */
  128910. get seed(): NodeMaterialConnectionPoint;
  128911. /**
  128912. * Gets the jitter input component
  128913. */
  128914. get jitter(): NodeMaterialConnectionPoint;
  128915. /**
  128916. * Gets the output component
  128917. */
  128918. get output(): NodeMaterialConnectionPoint;
  128919. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128920. /**
  128921. * Exposes the properties to the UI?
  128922. */
  128923. protected _dumpPropertiesCode(): string;
  128924. /**
  128925. * Exposes the properties to the Seralize?
  128926. */
  128927. serialize(): any;
  128928. /**
  128929. * Exposes the properties to the deseralize?
  128930. */
  128931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128932. }
  128933. }
  128934. declare module BABYLON {
  128935. /**
  128936. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128937. */
  128938. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128939. /**
  128940. * Creates a new SimplexPerlin3DBlock
  128941. * @param name defines the block name
  128942. */
  128943. constructor(name: string);
  128944. /**
  128945. * Gets the current class name
  128946. * @returns the class name
  128947. */
  128948. getClassName(): string;
  128949. /**
  128950. * Gets the seed operand input component
  128951. */
  128952. get seed(): NodeMaterialConnectionPoint;
  128953. /**
  128954. * Gets the output component
  128955. */
  128956. get output(): NodeMaterialConnectionPoint;
  128957. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128958. }
  128959. }
  128960. declare module BABYLON {
  128961. /**
  128962. * Block used to blend normals
  128963. */
  128964. export class NormalBlendBlock extends NodeMaterialBlock {
  128965. /**
  128966. * Creates a new NormalBlendBlock
  128967. * @param name defines the block name
  128968. */
  128969. constructor(name: string);
  128970. /**
  128971. * Gets the current class name
  128972. * @returns the class name
  128973. */
  128974. getClassName(): string;
  128975. /**
  128976. * Gets the first input component
  128977. */
  128978. get normalMap0(): NodeMaterialConnectionPoint;
  128979. /**
  128980. * Gets the second input component
  128981. */
  128982. get normalMap1(): NodeMaterialConnectionPoint;
  128983. /**
  128984. * Gets the output component
  128985. */
  128986. get output(): NodeMaterialConnectionPoint;
  128987. protected _buildBlock(state: NodeMaterialBuildState): this;
  128988. }
  128989. }
  128990. declare module BABYLON {
  128991. /**
  128992. * Block used to rotate a 2d vector by a given angle
  128993. */
  128994. export class Rotate2dBlock extends NodeMaterialBlock {
  128995. /**
  128996. * Creates a new Rotate2dBlock
  128997. * @param name defines the block name
  128998. */
  128999. constructor(name: string);
  129000. /**
  129001. * Gets the current class name
  129002. * @returns the class name
  129003. */
  129004. getClassName(): string;
  129005. /**
  129006. * Gets the input vector
  129007. */
  129008. get input(): NodeMaterialConnectionPoint;
  129009. /**
  129010. * Gets the input angle
  129011. */
  129012. get angle(): NodeMaterialConnectionPoint;
  129013. /**
  129014. * Gets the output component
  129015. */
  129016. get output(): NodeMaterialConnectionPoint;
  129017. autoConfigure(material: NodeMaterial): void;
  129018. protected _buildBlock(state: NodeMaterialBuildState): this;
  129019. }
  129020. }
  129021. declare module BABYLON {
  129022. /**
  129023. * Block used to get the reflected vector from a direction and a normal
  129024. */
  129025. export class ReflectBlock extends NodeMaterialBlock {
  129026. /**
  129027. * Creates a new ReflectBlock
  129028. * @param name defines the block name
  129029. */
  129030. constructor(name: string);
  129031. /**
  129032. * Gets the current class name
  129033. * @returns the class name
  129034. */
  129035. getClassName(): string;
  129036. /**
  129037. * Gets the incident component
  129038. */
  129039. get incident(): NodeMaterialConnectionPoint;
  129040. /**
  129041. * Gets the normal component
  129042. */
  129043. get normal(): NodeMaterialConnectionPoint;
  129044. /**
  129045. * Gets the output component
  129046. */
  129047. get output(): NodeMaterialConnectionPoint;
  129048. protected _buildBlock(state: NodeMaterialBuildState): this;
  129049. }
  129050. }
  129051. declare module BABYLON {
  129052. /**
  129053. * Block used to get the refracted vector from a direction and a normal
  129054. */
  129055. export class RefractBlock extends NodeMaterialBlock {
  129056. /**
  129057. * Creates a new RefractBlock
  129058. * @param name defines the block name
  129059. */
  129060. constructor(name: string);
  129061. /**
  129062. * Gets the current class name
  129063. * @returns the class name
  129064. */
  129065. getClassName(): string;
  129066. /**
  129067. * Gets the incident component
  129068. */
  129069. get incident(): NodeMaterialConnectionPoint;
  129070. /**
  129071. * Gets the normal component
  129072. */
  129073. get normal(): NodeMaterialConnectionPoint;
  129074. /**
  129075. * Gets the index of refraction component
  129076. */
  129077. get ior(): NodeMaterialConnectionPoint;
  129078. /**
  129079. * Gets the output component
  129080. */
  129081. get output(): NodeMaterialConnectionPoint;
  129082. protected _buildBlock(state: NodeMaterialBuildState): this;
  129083. }
  129084. }
  129085. declare module BABYLON {
  129086. /**
  129087. * Block used to desaturate a color
  129088. */
  129089. export class DesaturateBlock extends NodeMaterialBlock {
  129090. /**
  129091. * Creates a new DesaturateBlock
  129092. * @param name defines the block name
  129093. */
  129094. constructor(name: string);
  129095. /**
  129096. * Gets the current class name
  129097. * @returns the class name
  129098. */
  129099. getClassName(): string;
  129100. /**
  129101. * Gets the color operand input component
  129102. */
  129103. get color(): NodeMaterialConnectionPoint;
  129104. /**
  129105. * Gets the level operand input component
  129106. */
  129107. get level(): NodeMaterialConnectionPoint;
  129108. /**
  129109. * Gets the output component
  129110. */
  129111. get output(): NodeMaterialConnectionPoint;
  129112. protected _buildBlock(state: NodeMaterialBuildState): this;
  129113. }
  129114. }
  129115. declare module BABYLON {
  129116. /**
  129117. * Effect Render Options
  129118. */
  129119. export interface IEffectRendererOptions {
  129120. /**
  129121. * Defines the vertices positions.
  129122. */
  129123. positions?: number[];
  129124. /**
  129125. * Defines the indices.
  129126. */
  129127. indices?: number[];
  129128. }
  129129. /**
  129130. * Helper class to render one or more effects
  129131. */
  129132. export class EffectRenderer {
  129133. private engine;
  129134. private static _DefaultOptions;
  129135. private _vertexBuffers;
  129136. private _indexBuffer;
  129137. private _ringBufferIndex;
  129138. private _ringScreenBuffer;
  129139. private _fullscreenViewport;
  129140. private _getNextFrameBuffer;
  129141. /**
  129142. * Creates an effect renderer
  129143. * @param engine the engine to use for rendering
  129144. * @param options defines the options of the effect renderer
  129145. */
  129146. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  129147. /**
  129148. * Sets the current viewport in normalized coordinates 0-1
  129149. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  129150. */
  129151. setViewport(viewport?: Viewport): void;
  129152. /**
  129153. * Binds the embedded attributes buffer to the effect.
  129154. * @param effect Defines the effect to bind the attributes for
  129155. */
  129156. bindBuffers(effect: Effect): void;
  129157. /**
  129158. * Sets the current effect wrapper to use during draw.
  129159. * The effect needs to be ready before calling this api.
  129160. * This also sets the default full screen position attribute.
  129161. * @param effectWrapper Defines the effect to draw with
  129162. */
  129163. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  129164. /**
  129165. * Draws a full screen quad.
  129166. */
  129167. draw(): void;
  129168. /**
  129169. * renders one or more effects to a specified texture
  129170. * @param effectWrappers list of effects to renderer
  129171. * @param outputTexture texture to draw to, if null it will render to the screen
  129172. */
  129173. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  129174. /**
  129175. * Disposes of the effect renderer
  129176. */
  129177. dispose(): void;
  129178. }
  129179. /**
  129180. * Options to create an EffectWrapper
  129181. */
  129182. interface EffectWrapperCreationOptions {
  129183. /**
  129184. * Engine to use to create the effect
  129185. */
  129186. engine: ThinEngine;
  129187. /**
  129188. * Fragment shader for the effect
  129189. */
  129190. fragmentShader: string;
  129191. /**
  129192. * Vertex shader for the effect
  129193. */
  129194. vertexShader?: string;
  129195. /**
  129196. * Attributes to use in the shader
  129197. */
  129198. attributeNames?: Array<string>;
  129199. /**
  129200. * Uniforms to use in the shader
  129201. */
  129202. uniformNames?: Array<string>;
  129203. /**
  129204. * Texture sampler names to use in the shader
  129205. */
  129206. samplerNames?: Array<string>;
  129207. /**
  129208. * The friendly name of the effect displayed in Spector.
  129209. */
  129210. name?: string;
  129211. }
  129212. /**
  129213. * Wraps an effect to be used for rendering
  129214. */
  129215. export class EffectWrapper {
  129216. /**
  129217. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  129218. */
  129219. onApplyObservable: Observable<{}>;
  129220. /**
  129221. * The underlying effect
  129222. */
  129223. effect: Effect;
  129224. /**
  129225. * Creates an effect to be renderer
  129226. * @param creationOptions options to create the effect
  129227. */
  129228. constructor(creationOptions: EffectWrapperCreationOptions);
  129229. /**
  129230. * Disposes of the effect wrapper
  129231. */
  129232. dispose(): void;
  129233. }
  129234. }
  129235. declare module BABYLON {
  129236. /**
  129237. * Helper class to push actions to a pool of workers.
  129238. */
  129239. export class WorkerPool implements IDisposable {
  129240. private _workerInfos;
  129241. private _pendingActions;
  129242. /**
  129243. * Constructor
  129244. * @param workers Array of workers to use for actions
  129245. */
  129246. constructor(workers: Array<Worker>);
  129247. /**
  129248. * Terminates all workers and clears any pending actions.
  129249. */
  129250. dispose(): void;
  129251. /**
  129252. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129253. * pended until a worker has completed its action.
  129254. * @param action The action to perform. Call onComplete when the action is complete.
  129255. */
  129256. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129257. private _execute;
  129258. }
  129259. }
  129260. declare module BABYLON {
  129261. /**
  129262. * Configuration for Draco compression
  129263. */
  129264. export interface IDracoCompressionConfiguration {
  129265. /**
  129266. * Configuration for the decoder.
  129267. */
  129268. decoder: {
  129269. /**
  129270. * The url to the WebAssembly module.
  129271. */
  129272. wasmUrl?: string;
  129273. /**
  129274. * The url to the WebAssembly binary.
  129275. */
  129276. wasmBinaryUrl?: string;
  129277. /**
  129278. * The url to the fallback JavaScript module.
  129279. */
  129280. fallbackUrl?: string;
  129281. };
  129282. }
  129283. /**
  129284. * Draco compression (https://google.github.io/draco/)
  129285. *
  129286. * This class wraps the Draco module.
  129287. *
  129288. * **Encoder**
  129289. *
  129290. * The encoder is not currently implemented.
  129291. *
  129292. * **Decoder**
  129293. *
  129294. * 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.
  129295. *
  129296. * To update the configuration, use the following code:
  129297. * ```javascript
  129298. * DracoCompression.Configuration = {
  129299. * decoder: {
  129300. * wasmUrl: "<url to the WebAssembly library>",
  129301. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129302. * fallbackUrl: "<url to the fallback JavaScript library>",
  129303. * }
  129304. * };
  129305. * ```
  129306. *
  129307. * 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.
  129308. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129309. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129310. *
  129311. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129312. * ```javascript
  129313. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129314. * ```
  129315. *
  129316. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129317. */
  129318. export class DracoCompression implements IDisposable {
  129319. private _workerPoolPromise?;
  129320. private _decoderModulePromise?;
  129321. /**
  129322. * The configuration. Defaults to the following urls:
  129323. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129324. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129325. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129326. */
  129327. static Configuration: IDracoCompressionConfiguration;
  129328. /**
  129329. * Returns true if the decoder configuration is available.
  129330. */
  129331. static get DecoderAvailable(): boolean;
  129332. /**
  129333. * Default number of workers to create when creating the draco compression object.
  129334. */
  129335. static DefaultNumWorkers: number;
  129336. private static GetDefaultNumWorkers;
  129337. private static _Default;
  129338. /**
  129339. * Default instance for the draco compression object.
  129340. */
  129341. static get Default(): DracoCompression;
  129342. /**
  129343. * Constructor
  129344. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129345. */
  129346. constructor(numWorkers?: number);
  129347. /**
  129348. * Stop all async operations and release resources.
  129349. */
  129350. dispose(): void;
  129351. /**
  129352. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129353. * @returns a promise that resolves when ready
  129354. */
  129355. whenReadyAsync(): Promise<void>;
  129356. /**
  129357. * Decode Draco compressed mesh data to vertex data.
  129358. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129359. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129360. * @returns A promise that resolves with the decoded vertex data
  129361. */
  129362. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129363. [kind: string]: number;
  129364. }): Promise<VertexData>;
  129365. }
  129366. }
  129367. declare module BABYLON {
  129368. /**
  129369. * Class for building Constructive Solid Geometry
  129370. */
  129371. export class CSG {
  129372. private polygons;
  129373. /**
  129374. * The world matrix
  129375. */
  129376. matrix: Matrix;
  129377. /**
  129378. * Stores the position
  129379. */
  129380. position: Vector3;
  129381. /**
  129382. * Stores the rotation
  129383. */
  129384. rotation: Vector3;
  129385. /**
  129386. * Stores the rotation quaternion
  129387. */
  129388. rotationQuaternion: Nullable<Quaternion>;
  129389. /**
  129390. * Stores the scaling vector
  129391. */
  129392. scaling: Vector3;
  129393. /**
  129394. * Convert the Mesh to CSG
  129395. * @param mesh The Mesh to convert to CSG
  129396. * @returns A new CSG from the Mesh
  129397. */
  129398. static FromMesh(mesh: Mesh): CSG;
  129399. /**
  129400. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129401. * @param polygons Polygons used to construct a CSG solid
  129402. */
  129403. private static FromPolygons;
  129404. /**
  129405. * Clones, or makes a deep copy, of the CSG
  129406. * @returns A new CSG
  129407. */
  129408. clone(): CSG;
  129409. /**
  129410. * Unions this CSG with another CSG
  129411. * @param csg The CSG to union against this CSG
  129412. * @returns The unioned CSG
  129413. */
  129414. union(csg: CSG): CSG;
  129415. /**
  129416. * Unions this CSG with another CSG in place
  129417. * @param csg The CSG to union against this CSG
  129418. */
  129419. unionInPlace(csg: CSG): void;
  129420. /**
  129421. * Subtracts this CSG with another CSG
  129422. * @param csg The CSG to subtract against this CSG
  129423. * @returns A new CSG
  129424. */
  129425. subtract(csg: CSG): CSG;
  129426. /**
  129427. * Subtracts this CSG with another CSG in place
  129428. * @param csg The CSG to subtact against this CSG
  129429. */
  129430. subtractInPlace(csg: CSG): void;
  129431. /**
  129432. * Intersect this CSG with another CSG
  129433. * @param csg The CSG to intersect against this CSG
  129434. * @returns A new CSG
  129435. */
  129436. intersect(csg: CSG): CSG;
  129437. /**
  129438. * Intersects this CSG with another CSG in place
  129439. * @param csg The CSG to intersect against this CSG
  129440. */
  129441. intersectInPlace(csg: CSG): void;
  129442. /**
  129443. * Return a new CSG solid with solid and empty space switched. This solid is
  129444. * not modified.
  129445. * @returns A new CSG solid with solid and empty space switched
  129446. */
  129447. inverse(): CSG;
  129448. /**
  129449. * Inverses the CSG in place
  129450. */
  129451. inverseInPlace(): void;
  129452. /**
  129453. * This is used to keep meshes transformations so they can be restored
  129454. * when we build back a Babylon Mesh
  129455. * NB : All CSG operations are performed in world coordinates
  129456. * @param csg The CSG to copy the transform attributes from
  129457. * @returns This CSG
  129458. */
  129459. copyTransformAttributes(csg: CSG): CSG;
  129460. /**
  129461. * Build Raw mesh from CSG
  129462. * Coordinates here are in world space
  129463. * @param name The name of the mesh geometry
  129464. * @param scene The Scene
  129465. * @param keepSubMeshes Specifies if the submeshes should be kept
  129466. * @returns A new Mesh
  129467. */
  129468. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129469. /**
  129470. * Build Mesh from CSG taking material and transforms into account
  129471. * @param name The name of the Mesh
  129472. * @param material The material of the Mesh
  129473. * @param scene The Scene
  129474. * @param keepSubMeshes Specifies if submeshes should be kept
  129475. * @returns The new Mesh
  129476. */
  129477. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129478. }
  129479. }
  129480. declare module BABYLON {
  129481. /**
  129482. * Class used to create a trail following a mesh
  129483. */
  129484. export class TrailMesh extends Mesh {
  129485. private _generator;
  129486. private _autoStart;
  129487. private _running;
  129488. private _diameter;
  129489. private _length;
  129490. private _sectionPolygonPointsCount;
  129491. private _sectionVectors;
  129492. private _sectionNormalVectors;
  129493. private _beforeRenderObserver;
  129494. /**
  129495. * @constructor
  129496. * @param name The value used by scene.getMeshByName() to do a lookup.
  129497. * @param generator The mesh to generate a trail.
  129498. * @param scene The scene to add this mesh to.
  129499. * @param diameter Diameter of trailing mesh. Default is 1.
  129500. * @param length Length of trailing mesh. Default is 60.
  129501. * @param autoStart Automatically start trailing mesh. Default true.
  129502. */
  129503. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129504. /**
  129505. * "TrailMesh"
  129506. * @returns "TrailMesh"
  129507. */
  129508. getClassName(): string;
  129509. private _createMesh;
  129510. /**
  129511. * Start trailing mesh.
  129512. */
  129513. start(): void;
  129514. /**
  129515. * Stop trailing mesh.
  129516. */
  129517. stop(): void;
  129518. /**
  129519. * Update trailing mesh geometry.
  129520. */
  129521. update(): void;
  129522. /**
  129523. * Returns a new TrailMesh object.
  129524. * @param name is a string, the name given to the new mesh
  129525. * @param newGenerator use new generator object for cloned trail mesh
  129526. * @returns a new mesh
  129527. */
  129528. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129529. /**
  129530. * Serializes this trail mesh
  129531. * @param serializationObject object to write serialization to
  129532. */
  129533. serialize(serializationObject: any): void;
  129534. /**
  129535. * Parses a serialized trail mesh
  129536. * @param parsedMesh the serialized mesh
  129537. * @param scene the scene to create the trail mesh in
  129538. * @returns the created trail mesh
  129539. */
  129540. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129541. }
  129542. }
  129543. declare module BABYLON {
  129544. /**
  129545. * Class containing static functions to help procedurally build meshes
  129546. */
  129547. export class TiledBoxBuilder {
  129548. /**
  129549. * Creates a box mesh
  129550. * 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)
  129551. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129555. * @param name defines the name of the mesh
  129556. * @param options defines the options used to create the mesh
  129557. * @param scene defines the hosting scene
  129558. * @returns the box mesh
  129559. */
  129560. static CreateTiledBox(name: string, options: {
  129561. pattern?: number;
  129562. width?: number;
  129563. height?: number;
  129564. depth?: number;
  129565. tileSize?: number;
  129566. tileWidth?: number;
  129567. tileHeight?: number;
  129568. alignHorizontal?: number;
  129569. alignVertical?: number;
  129570. faceUV?: Vector4[];
  129571. faceColors?: Color4[];
  129572. sideOrientation?: number;
  129573. updatable?: boolean;
  129574. }, scene?: Nullable<Scene>): Mesh;
  129575. }
  129576. }
  129577. declare module BABYLON {
  129578. /**
  129579. * Class containing static functions to help procedurally build meshes
  129580. */
  129581. export class TorusKnotBuilder {
  129582. /**
  129583. * Creates a torus knot mesh
  129584. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129585. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129586. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129587. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129591. * @param name defines the name of the mesh
  129592. * @param options defines the options used to create the mesh
  129593. * @param scene defines the hosting scene
  129594. * @returns the torus knot mesh
  129595. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129596. */
  129597. static CreateTorusKnot(name: string, options: {
  129598. radius?: number;
  129599. tube?: number;
  129600. radialSegments?: number;
  129601. tubularSegments?: number;
  129602. p?: number;
  129603. q?: number;
  129604. updatable?: boolean;
  129605. sideOrientation?: number;
  129606. frontUVs?: Vector4;
  129607. backUVs?: Vector4;
  129608. }, scene: any): Mesh;
  129609. }
  129610. }
  129611. declare module BABYLON {
  129612. /**
  129613. * Polygon
  129614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129615. */
  129616. export class Polygon {
  129617. /**
  129618. * Creates a rectangle
  129619. * @param xmin bottom X coord
  129620. * @param ymin bottom Y coord
  129621. * @param xmax top X coord
  129622. * @param ymax top Y coord
  129623. * @returns points that make the resulting rectation
  129624. */
  129625. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129626. /**
  129627. * Creates a circle
  129628. * @param radius radius of circle
  129629. * @param cx scale in x
  129630. * @param cy scale in y
  129631. * @param numberOfSides number of sides that make up the circle
  129632. * @returns points that make the resulting circle
  129633. */
  129634. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129635. /**
  129636. * Creates a polygon from input string
  129637. * @param input Input polygon data
  129638. * @returns the parsed points
  129639. */
  129640. static Parse(input: string): Vector2[];
  129641. /**
  129642. * Starts building a polygon from x and y coordinates
  129643. * @param x x coordinate
  129644. * @param y y coordinate
  129645. * @returns the started path2
  129646. */
  129647. static StartingAt(x: number, y: number): Path2;
  129648. }
  129649. /**
  129650. * Builds a polygon
  129651. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129652. */
  129653. export class PolygonMeshBuilder {
  129654. private _points;
  129655. private _outlinepoints;
  129656. private _holes;
  129657. private _name;
  129658. private _scene;
  129659. private _epoints;
  129660. private _eholes;
  129661. private _addToepoint;
  129662. /**
  129663. * Babylon reference to the earcut plugin.
  129664. */
  129665. bjsEarcut: any;
  129666. /**
  129667. * Creates a PolygonMeshBuilder
  129668. * @param name name of the builder
  129669. * @param contours Path of the polygon
  129670. * @param scene scene to add to when creating the mesh
  129671. * @param earcutInjection can be used to inject your own earcut reference
  129672. */
  129673. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129674. /**
  129675. * Adds a whole within the polygon
  129676. * @param hole Array of points defining the hole
  129677. * @returns this
  129678. */
  129679. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129680. /**
  129681. * Creates the polygon
  129682. * @param updatable If the mesh should be updatable
  129683. * @param depth The depth of the mesh created
  129684. * @returns the created mesh
  129685. */
  129686. build(updatable?: boolean, depth?: number): Mesh;
  129687. /**
  129688. * Creates the polygon
  129689. * @param depth The depth of the mesh created
  129690. * @returns the created VertexData
  129691. */
  129692. buildVertexData(depth?: number): VertexData;
  129693. /**
  129694. * Adds a side to the polygon
  129695. * @param positions points that make the polygon
  129696. * @param normals normals of the polygon
  129697. * @param uvs uvs of the polygon
  129698. * @param indices indices of the polygon
  129699. * @param bounds bounds of the polygon
  129700. * @param points points of the polygon
  129701. * @param depth depth of the polygon
  129702. * @param flip flip of the polygon
  129703. */
  129704. private addSide;
  129705. }
  129706. }
  129707. declare module BABYLON {
  129708. /**
  129709. * Class containing static functions to help procedurally build meshes
  129710. */
  129711. export class PolygonBuilder {
  129712. /**
  129713. * Creates a polygon mesh
  129714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129715. * * 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
  129716. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129719. * * Remember you can only change the shape positions, not their number when updating a polygon
  129720. * @param name defines the name of the mesh
  129721. * @param options defines the options used to create the mesh
  129722. * @param scene defines the hosting scene
  129723. * @param earcutInjection can be used to inject your own earcut reference
  129724. * @returns the polygon mesh
  129725. */
  129726. static CreatePolygon(name: string, options: {
  129727. shape: Vector3[];
  129728. holes?: Vector3[][];
  129729. depth?: number;
  129730. faceUV?: Vector4[];
  129731. faceColors?: Color4[];
  129732. updatable?: boolean;
  129733. sideOrientation?: number;
  129734. frontUVs?: Vector4;
  129735. backUVs?: Vector4;
  129736. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129737. /**
  129738. * Creates an extruded polygon mesh, with depth in the Y direction.
  129739. * * 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)
  129740. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129741. * @param name defines the name of the mesh
  129742. * @param options defines the options used to create the mesh
  129743. * @param scene defines the hosting scene
  129744. * @param earcutInjection can be used to inject your own earcut reference
  129745. * @returns the polygon mesh
  129746. */
  129747. static ExtrudePolygon(name: string, options: {
  129748. shape: Vector3[];
  129749. holes?: Vector3[][];
  129750. depth?: number;
  129751. faceUV?: Vector4[];
  129752. faceColors?: Color4[];
  129753. updatable?: boolean;
  129754. sideOrientation?: number;
  129755. frontUVs?: Vector4;
  129756. backUVs?: Vector4;
  129757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129758. }
  129759. }
  129760. declare module BABYLON {
  129761. /**
  129762. * Class containing static functions to help procedurally build meshes
  129763. */
  129764. export class LatheBuilder {
  129765. /**
  129766. * Creates lathe mesh.
  129767. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129768. * * 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
  129769. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129770. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129771. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129772. * * 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
  129773. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129774. * * 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
  129775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129777. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129779. * @param name defines the name of the mesh
  129780. * @param options defines the options used to create the mesh
  129781. * @param scene defines the hosting scene
  129782. * @returns the lathe mesh
  129783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129784. */
  129785. static CreateLathe(name: string, options: {
  129786. shape: Vector3[];
  129787. radius?: number;
  129788. tessellation?: number;
  129789. clip?: number;
  129790. arc?: number;
  129791. closed?: boolean;
  129792. updatable?: boolean;
  129793. sideOrientation?: number;
  129794. frontUVs?: Vector4;
  129795. backUVs?: Vector4;
  129796. cap?: number;
  129797. invertUV?: boolean;
  129798. }, scene?: Nullable<Scene>): Mesh;
  129799. }
  129800. }
  129801. declare module BABYLON {
  129802. /**
  129803. * Class containing static functions to help procedurally build meshes
  129804. */
  129805. export class TiledPlaneBuilder {
  129806. /**
  129807. * Creates a tiled plane mesh
  129808. * * The parameter `pattern` will, depending on value, do nothing or
  129809. * * * flip (reflect about central vertical) alternate tiles across and up
  129810. * * * flip every tile on alternate rows
  129811. * * * rotate (180 degs) alternate tiles across and up
  129812. * * * rotate every tile on alternate rows
  129813. * * * flip and rotate alternate tiles across and up
  129814. * * * flip and rotate every tile on alternate rows
  129815. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129816. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129819. * * 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)
  129820. * * 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)
  129821. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129822. * @param name defines the name of the mesh
  129823. * @param options defines the options used to create the mesh
  129824. * @param scene defines the hosting scene
  129825. * @returns the box mesh
  129826. */
  129827. static CreateTiledPlane(name: string, options: {
  129828. pattern?: number;
  129829. tileSize?: number;
  129830. tileWidth?: number;
  129831. tileHeight?: number;
  129832. size?: number;
  129833. width?: number;
  129834. height?: number;
  129835. alignHorizontal?: number;
  129836. alignVertical?: number;
  129837. sideOrientation?: number;
  129838. frontUVs?: Vector4;
  129839. backUVs?: Vector4;
  129840. updatable?: boolean;
  129841. }, scene?: Nullable<Scene>): Mesh;
  129842. }
  129843. }
  129844. declare module BABYLON {
  129845. /**
  129846. * Class containing static functions to help procedurally build meshes
  129847. */
  129848. export class TubeBuilder {
  129849. /**
  129850. * Creates a tube mesh.
  129851. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129852. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129853. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129854. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129855. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129856. * * 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)
  129857. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129858. * * 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
  129859. * * 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
  129860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129864. * @param name defines the name of the mesh
  129865. * @param options defines the options used to create the mesh
  129866. * @param scene defines the hosting scene
  129867. * @returns the tube mesh
  129868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129869. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129870. */
  129871. static CreateTube(name: string, options: {
  129872. path: Vector3[];
  129873. radius?: number;
  129874. tessellation?: number;
  129875. radiusFunction?: {
  129876. (i: number, distance: number): number;
  129877. };
  129878. cap?: number;
  129879. arc?: number;
  129880. updatable?: boolean;
  129881. sideOrientation?: number;
  129882. frontUVs?: Vector4;
  129883. backUVs?: Vector4;
  129884. instance?: Mesh;
  129885. invertUV?: boolean;
  129886. }, scene?: Nullable<Scene>): Mesh;
  129887. }
  129888. }
  129889. declare module BABYLON {
  129890. /**
  129891. * Class containing static functions to help procedurally build meshes
  129892. */
  129893. export class IcoSphereBuilder {
  129894. /**
  129895. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129896. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129897. * * 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`)
  129898. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129899. * * 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
  129900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129903. * @param name defines the name of the mesh
  129904. * @param options defines the options used to create the mesh
  129905. * @param scene defines the hosting scene
  129906. * @returns the icosahedron mesh
  129907. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129908. */
  129909. static CreateIcoSphere(name: string, options: {
  129910. radius?: number;
  129911. radiusX?: number;
  129912. radiusY?: number;
  129913. radiusZ?: number;
  129914. flat?: boolean;
  129915. subdivisions?: number;
  129916. sideOrientation?: number;
  129917. frontUVs?: Vector4;
  129918. backUVs?: Vector4;
  129919. updatable?: boolean;
  129920. }, scene?: Nullable<Scene>): Mesh;
  129921. }
  129922. }
  129923. declare module BABYLON {
  129924. /**
  129925. * Class containing static functions to help procedurally build meshes
  129926. */
  129927. export class DecalBuilder {
  129928. /**
  129929. * Creates a decal mesh.
  129930. * 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
  129931. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129932. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129933. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129934. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129935. * @param name defines the name of the mesh
  129936. * @param sourceMesh defines the mesh where the decal must be applied
  129937. * @param options defines the options used to create the mesh
  129938. * @param scene defines the hosting scene
  129939. * @returns the decal mesh
  129940. * @see https://doc.babylonjs.com/how_to/decals
  129941. */
  129942. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129943. position?: Vector3;
  129944. normal?: Vector3;
  129945. size?: Vector3;
  129946. angle?: number;
  129947. }): Mesh;
  129948. }
  129949. }
  129950. declare module BABYLON {
  129951. /**
  129952. * Class containing static functions to help procedurally build meshes
  129953. */
  129954. export class MeshBuilder {
  129955. /**
  129956. * Creates a box mesh
  129957. * * The parameter `size` sets the size (float) of each box side (default 1)
  129958. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129959. * * 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)
  129960. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129964. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129965. * @param name defines the name of the mesh
  129966. * @param options defines the options used to create the mesh
  129967. * @param scene defines the hosting scene
  129968. * @returns the box mesh
  129969. */
  129970. static CreateBox(name: string, options: {
  129971. size?: number;
  129972. width?: number;
  129973. height?: number;
  129974. depth?: number;
  129975. faceUV?: Vector4[];
  129976. faceColors?: Color4[];
  129977. sideOrientation?: number;
  129978. frontUVs?: Vector4;
  129979. backUVs?: Vector4;
  129980. updatable?: boolean;
  129981. }, scene?: Nullable<Scene>): Mesh;
  129982. /**
  129983. * Creates a tiled box mesh
  129984. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129986. * @param name defines the name of the mesh
  129987. * @param options defines the options used to create the mesh
  129988. * @param scene defines the hosting scene
  129989. * @returns the tiled box mesh
  129990. */
  129991. static CreateTiledBox(name: string, options: {
  129992. pattern?: number;
  129993. size?: number;
  129994. width?: number;
  129995. height?: number;
  129996. depth: number;
  129997. tileSize?: number;
  129998. tileWidth?: number;
  129999. tileHeight?: number;
  130000. faceUV?: Vector4[];
  130001. faceColors?: Color4[];
  130002. alignHorizontal?: number;
  130003. alignVertical?: number;
  130004. sideOrientation?: number;
  130005. updatable?: boolean;
  130006. }, scene?: Nullable<Scene>): Mesh;
  130007. /**
  130008. * Creates a sphere mesh
  130009. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  130010. * * 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`)
  130011. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  130012. * * 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
  130013. * * 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)
  130014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130017. * @param name defines the name of the mesh
  130018. * @param options defines the options used to create the mesh
  130019. * @param scene defines the hosting scene
  130020. * @returns the sphere mesh
  130021. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  130022. */
  130023. static CreateSphere(name: string, options: {
  130024. segments?: number;
  130025. diameter?: number;
  130026. diameterX?: number;
  130027. diameterY?: number;
  130028. diameterZ?: number;
  130029. arc?: number;
  130030. slice?: number;
  130031. sideOrientation?: number;
  130032. frontUVs?: Vector4;
  130033. backUVs?: Vector4;
  130034. updatable?: boolean;
  130035. }, scene?: Nullable<Scene>): Mesh;
  130036. /**
  130037. * Creates a plane polygonal mesh. By default, this is a disc
  130038. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  130039. * * 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
  130040. * * 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
  130041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130044. * @param name defines the name of the mesh
  130045. * @param options defines the options used to create the mesh
  130046. * @param scene defines the hosting scene
  130047. * @returns the plane polygonal mesh
  130048. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  130049. */
  130050. static CreateDisc(name: string, options: {
  130051. radius?: number;
  130052. tessellation?: number;
  130053. arc?: number;
  130054. updatable?: boolean;
  130055. sideOrientation?: number;
  130056. frontUVs?: Vector4;
  130057. backUVs?: Vector4;
  130058. }, scene?: Nullable<Scene>): Mesh;
  130059. /**
  130060. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  130061. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  130062. * * 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`)
  130063. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  130064. * * 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
  130065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130068. * @param name defines the name of the mesh
  130069. * @param options defines the options used to create the mesh
  130070. * @param scene defines the hosting scene
  130071. * @returns the icosahedron mesh
  130072. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  130073. */
  130074. static CreateIcoSphere(name: string, options: {
  130075. radius?: number;
  130076. radiusX?: number;
  130077. radiusY?: number;
  130078. radiusZ?: number;
  130079. flat?: boolean;
  130080. subdivisions?: number;
  130081. sideOrientation?: number;
  130082. frontUVs?: Vector4;
  130083. backUVs?: Vector4;
  130084. updatable?: boolean;
  130085. }, scene?: Nullable<Scene>): Mesh;
  130086. /**
  130087. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130088. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130089. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130090. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130091. * * 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
  130092. * * 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
  130093. * * 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
  130094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130097. * * 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
  130098. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130099. * * 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
  130100. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130102. * @param name defines the name of the mesh
  130103. * @param options defines the options used to create the mesh
  130104. * @param scene defines the hosting scene
  130105. * @returns the ribbon mesh
  130106. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130108. */
  130109. static CreateRibbon(name: string, options: {
  130110. pathArray: Vector3[][];
  130111. closeArray?: boolean;
  130112. closePath?: boolean;
  130113. offset?: number;
  130114. updatable?: boolean;
  130115. sideOrientation?: number;
  130116. frontUVs?: Vector4;
  130117. backUVs?: Vector4;
  130118. instance?: Mesh;
  130119. invertUV?: boolean;
  130120. uvs?: Vector2[];
  130121. colors?: Color4[];
  130122. }, scene?: Nullable<Scene>): Mesh;
  130123. /**
  130124. * Creates a cylinder or a cone mesh
  130125. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130126. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130127. * * 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.
  130128. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130129. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130130. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130131. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130132. * * 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).
  130133. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130134. * * 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).
  130135. * * 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
  130136. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130137. * * 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
  130138. * * 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.
  130139. * * If `enclose` is false, a ring surface is one element.
  130140. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130141. * * 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
  130142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130145. * @param name defines the name of the mesh
  130146. * @param options defines the options used to create the mesh
  130147. * @param scene defines the hosting scene
  130148. * @returns the cylinder mesh
  130149. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130150. */
  130151. static CreateCylinder(name: string, options: {
  130152. height?: number;
  130153. diameterTop?: number;
  130154. diameterBottom?: number;
  130155. diameter?: number;
  130156. tessellation?: number;
  130157. subdivisions?: number;
  130158. arc?: number;
  130159. faceColors?: Color4[];
  130160. faceUV?: Vector4[];
  130161. updatable?: boolean;
  130162. hasRings?: boolean;
  130163. enclose?: boolean;
  130164. cap?: number;
  130165. sideOrientation?: number;
  130166. frontUVs?: Vector4;
  130167. backUVs?: Vector4;
  130168. }, scene?: Nullable<Scene>): Mesh;
  130169. /**
  130170. * Creates a torus mesh
  130171. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130172. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130173. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130177. * @param name defines the name of the mesh
  130178. * @param options defines the options used to create the mesh
  130179. * @param scene defines the hosting scene
  130180. * @returns the torus mesh
  130181. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130182. */
  130183. static CreateTorus(name: string, options: {
  130184. diameter?: number;
  130185. thickness?: number;
  130186. tessellation?: number;
  130187. updatable?: boolean;
  130188. sideOrientation?: number;
  130189. frontUVs?: Vector4;
  130190. backUVs?: Vector4;
  130191. }, scene?: Nullable<Scene>): Mesh;
  130192. /**
  130193. * Creates a torus knot mesh
  130194. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130195. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130196. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130197. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130201. * @param name defines the name of the mesh
  130202. * @param options defines the options used to create the mesh
  130203. * @param scene defines the hosting scene
  130204. * @returns the torus knot mesh
  130205. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130206. */
  130207. static CreateTorusKnot(name: string, options: {
  130208. radius?: number;
  130209. tube?: number;
  130210. radialSegments?: number;
  130211. tubularSegments?: number;
  130212. p?: number;
  130213. q?: number;
  130214. updatable?: boolean;
  130215. sideOrientation?: number;
  130216. frontUVs?: Vector4;
  130217. backUVs?: Vector4;
  130218. }, scene?: Nullable<Scene>): Mesh;
  130219. /**
  130220. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  130221. * * 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
  130222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  130223. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  130224. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  130225. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  130226. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  130227. * * 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
  130228. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130231. * @param name defines the name of the new line system
  130232. * @param options defines the options used to create the line system
  130233. * @param scene defines the hosting scene
  130234. * @returns a new line system mesh
  130235. */
  130236. static CreateLineSystem(name: string, options: {
  130237. lines: Vector3[][];
  130238. updatable?: boolean;
  130239. instance?: Nullable<LinesMesh>;
  130240. colors?: Nullable<Color4[][]>;
  130241. useVertexAlpha?: boolean;
  130242. }, scene: Nullable<Scene>): LinesMesh;
  130243. /**
  130244. * Creates a line mesh
  130245. * 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
  130246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130247. * * The parameter `points` is an array successive Vector3
  130248. * * 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
  130249. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130250. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130251. * * When updating an instance, remember that only point positions can change, not the number of points
  130252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130254. * @param name defines the name of the new line system
  130255. * @param options defines the options used to create the line system
  130256. * @param scene defines the hosting scene
  130257. * @returns a new line mesh
  130258. */
  130259. static CreateLines(name: string, options: {
  130260. points: Vector3[];
  130261. updatable?: boolean;
  130262. instance?: Nullable<LinesMesh>;
  130263. colors?: Color4[];
  130264. useVertexAlpha?: boolean;
  130265. }, scene?: Nullable<Scene>): LinesMesh;
  130266. /**
  130267. * Creates a dashed line mesh
  130268. * * 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
  130269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130270. * * The parameter `points` is an array successive Vector3
  130271. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130272. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130273. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130274. * * 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
  130275. * * When updating an instance, remember that only point positions can change, not the number of points
  130276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130277. * @param name defines the name of the mesh
  130278. * @param options defines the options used to create the mesh
  130279. * @param scene defines the hosting scene
  130280. * @returns the dashed line mesh
  130281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130282. */
  130283. static CreateDashedLines(name: string, options: {
  130284. points: Vector3[];
  130285. dashSize?: number;
  130286. gapSize?: number;
  130287. dashNb?: number;
  130288. updatable?: boolean;
  130289. instance?: LinesMesh;
  130290. }, scene?: Nullable<Scene>): LinesMesh;
  130291. /**
  130292. * 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.
  130293. * * 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.
  130294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130295. * * 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.
  130296. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130297. * * 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
  130298. * * 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
  130299. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130304. * @param name defines the name of the mesh
  130305. * @param options defines the options used to create the mesh
  130306. * @param scene defines the hosting scene
  130307. * @returns the extruded shape mesh
  130308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130310. */
  130311. static ExtrudeShape(name: string, options: {
  130312. shape: Vector3[];
  130313. path: Vector3[];
  130314. scale?: number;
  130315. rotation?: number;
  130316. cap?: number;
  130317. updatable?: boolean;
  130318. sideOrientation?: number;
  130319. frontUVs?: Vector4;
  130320. backUVs?: Vector4;
  130321. instance?: Mesh;
  130322. invertUV?: boolean;
  130323. }, scene?: Nullable<Scene>): Mesh;
  130324. /**
  130325. * Creates an custom extruded shape mesh.
  130326. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130327. * * 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.
  130328. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130329. * * 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
  130330. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130331. * * 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
  130332. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130333. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130334. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130335. * * 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
  130336. * * 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
  130337. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130342. * @param name defines the name of the mesh
  130343. * @param options defines the options used to create the mesh
  130344. * @param scene defines the hosting scene
  130345. * @returns the custom extruded shape mesh
  130346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130349. */
  130350. static ExtrudeShapeCustom(name: string, options: {
  130351. shape: Vector3[];
  130352. path: Vector3[];
  130353. scaleFunction?: any;
  130354. rotationFunction?: any;
  130355. ribbonCloseArray?: boolean;
  130356. ribbonClosePath?: boolean;
  130357. cap?: number;
  130358. updatable?: boolean;
  130359. sideOrientation?: number;
  130360. frontUVs?: Vector4;
  130361. backUVs?: Vector4;
  130362. instance?: Mesh;
  130363. invertUV?: boolean;
  130364. }, scene?: Nullable<Scene>): Mesh;
  130365. /**
  130366. * Creates lathe mesh.
  130367. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130368. * * 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
  130369. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130370. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130371. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130372. * * 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
  130373. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130374. * * 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
  130375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130379. * @param name defines the name of the mesh
  130380. * @param options defines the options used to create the mesh
  130381. * @param scene defines the hosting scene
  130382. * @returns the lathe mesh
  130383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130384. */
  130385. static CreateLathe(name: string, options: {
  130386. shape: Vector3[];
  130387. radius?: number;
  130388. tessellation?: number;
  130389. clip?: number;
  130390. arc?: number;
  130391. closed?: boolean;
  130392. updatable?: boolean;
  130393. sideOrientation?: number;
  130394. frontUVs?: Vector4;
  130395. backUVs?: Vector4;
  130396. cap?: number;
  130397. invertUV?: boolean;
  130398. }, scene?: Nullable<Scene>): Mesh;
  130399. /**
  130400. * Creates a tiled plane mesh
  130401. * * You can set a limited pattern arrangement with the tiles
  130402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130405. * @param name defines the name of the mesh
  130406. * @param options defines the options used to create the mesh
  130407. * @param scene defines the hosting scene
  130408. * @returns the plane mesh
  130409. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130410. */
  130411. static CreateTiledPlane(name: string, options: {
  130412. pattern?: number;
  130413. tileSize?: number;
  130414. tileWidth?: number;
  130415. tileHeight?: number;
  130416. size?: number;
  130417. width?: number;
  130418. height?: number;
  130419. alignHorizontal?: number;
  130420. alignVertical?: number;
  130421. sideOrientation?: number;
  130422. frontUVs?: Vector4;
  130423. backUVs?: Vector4;
  130424. updatable?: boolean;
  130425. }, scene?: Nullable<Scene>): Mesh;
  130426. /**
  130427. * Creates a plane mesh
  130428. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130429. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130430. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130434. * @param name defines the name of the mesh
  130435. * @param options defines the options used to create the mesh
  130436. * @param scene defines the hosting scene
  130437. * @returns the plane mesh
  130438. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130439. */
  130440. static CreatePlane(name: string, options: {
  130441. size?: number;
  130442. width?: number;
  130443. height?: number;
  130444. sideOrientation?: number;
  130445. frontUVs?: Vector4;
  130446. backUVs?: Vector4;
  130447. updatable?: boolean;
  130448. sourcePlane?: Plane;
  130449. }, scene?: Nullable<Scene>): Mesh;
  130450. /**
  130451. * Creates a ground mesh
  130452. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130453. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130455. * @param name defines the name of the mesh
  130456. * @param options defines the options used to create the mesh
  130457. * @param scene defines the hosting scene
  130458. * @returns the ground mesh
  130459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130460. */
  130461. static CreateGround(name: string, options: {
  130462. width?: number;
  130463. height?: number;
  130464. subdivisions?: number;
  130465. subdivisionsX?: number;
  130466. subdivisionsY?: number;
  130467. updatable?: boolean;
  130468. }, scene?: Nullable<Scene>): Mesh;
  130469. /**
  130470. * Creates a tiled ground mesh
  130471. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130472. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130473. * * 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
  130474. * * 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
  130475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130476. * @param name defines the name of the mesh
  130477. * @param options defines the options used to create the mesh
  130478. * @param scene defines the hosting scene
  130479. * @returns the tiled ground mesh
  130480. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130481. */
  130482. static CreateTiledGround(name: string, options: {
  130483. xmin: number;
  130484. zmin: number;
  130485. xmax: number;
  130486. zmax: number;
  130487. subdivisions?: {
  130488. w: number;
  130489. h: number;
  130490. };
  130491. precision?: {
  130492. w: number;
  130493. h: number;
  130494. };
  130495. updatable?: boolean;
  130496. }, scene?: Nullable<Scene>): Mesh;
  130497. /**
  130498. * Creates a ground mesh from a height map
  130499. * * The parameter `url` sets the URL of the height map image resource.
  130500. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130501. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130502. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130503. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130504. * * 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.
  130505. * * 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).
  130506. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130508. * @param name defines the name of the mesh
  130509. * @param url defines the url to the height map
  130510. * @param options defines the options used to create the mesh
  130511. * @param scene defines the hosting scene
  130512. * @returns the ground mesh
  130513. * @see https://doc.babylonjs.com/babylon101/height_map
  130514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130515. */
  130516. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130517. width?: number;
  130518. height?: number;
  130519. subdivisions?: number;
  130520. minHeight?: number;
  130521. maxHeight?: number;
  130522. colorFilter?: Color3;
  130523. alphaFilter?: number;
  130524. updatable?: boolean;
  130525. onReady?: (mesh: GroundMesh) => void;
  130526. }, scene?: Nullable<Scene>): GroundMesh;
  130527. /**
  130528. * Creates a polygon mesh
  130529. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130530. * * 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
  130531. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130534. * * Remember you can only change the shape positions, not their number when updating a polygon
  130535. * @param name defines the name of the mesh
  130536. * @param options defines the options used to create the mesh
  130537. * @param scene defines the hosting scene
  130538. * @param earcutInjection can be used to inject your own earcut reference
  130539. * @returns the polygon mesh
  130540. */
  130541. static CreatePolygon(name: string, options: {
  130542. shape: Vector3[];
  130543. holes?: Vector3[][];
  130544. depth?: number;
  130545. faceUV?: Vector4[];
  130546. faceColors?: Color4[];
  130547. updatable?: boolean;
  130548. sideOrientation?: number;
  130549. frontUVs?: Vector4;
  130550. backUVs?: Vector4;
  130551. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130552. /**
  130553. * Creates an extruded polygon mesh, with depth in the Y direction.
  130554. * * 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)
  130555. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130556. * @param name defines the name of the mesh
  130557. * @param options defines the options used to create the mesh
  130558. * @param scene defines the hosting scene
  130559. * @param earcutInjection can be used to inject your own earcut reference
  130560. * @returns the polygon mesh
  130561. */
  130562. static ExtrudePolygon(name: string, options: {
  130563. shape: Vector3[];
  130564. holes?: Vector3[][];
  130565. depth?: number;
  130566. faceUV?: Vector4[];
  130567. faceColors?: Color4[];
  130568. updatable?: boolean;
  130569. sideOrientation?: number;
  130570. frontUVs?: Vector4;
  130571. backUVs?: Vector4;
  130572. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130573. /**
  130574. * Creates a tube mesh.
  130575. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130576. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130577. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130578. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130579. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130580. * * 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)
  130581. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130582. * * 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
  130583. * * 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
  130584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130588. * @param name defines the name of the mesh
  130589. * @param options defines the options used to create the mesh
  130590. * @param scene defines the hosting scene
  130591. * @returns the tube mesh
  130592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130593. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130594. */
  130595. static CreateTube(name: string, options: {
  130596. path: Vector3[];
  130597. radius?: number;
  130598. tessellation?: number;
  130599. radiusFunction?: {
  130600. (i: number, distance: number): number;
  130601. };
  130602. cap?: number;
  130603. arc?: number;
  130604. updatable?: boolean;
  130605. sideOrientation?: number;
  130606. frontUVs?: Vector4;
  130607. backUVs?: Vector4;
  130608. instance?: Mesh;
  130609. invertUV?: boolean;
  130610. }, scene?: Nullable<Scene>): Mesh;
  130611. /**
  130612. * Creates a polyhedron mesh
  130613. * * 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
  130614. * * The parameter `size` (positive float, default 1) sets the polygon size
  130615. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130616. * * 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`
  130617. * * 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
  130618. * * 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)`)
  130619. * * 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
  130620. * * 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
  130621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130624. * @param name defines the name of the mesh
  130625. * @param options defines the options used to create the mesh
  130626. * @param scene defines the hosting scene
  130627. * @returns the polyhedron mesh
  130628. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130629. */
  130630. static CreatePolyhedron(name: string, options: {
  130631. type?: number;
  130632. size?: number;
  130633. sizeX?: number;
  130634. sizeY?: number;
  130635. sizeZ?: number;
  130636. custom?: any;
  130637. faceUV?: Vector4[];
  130638. faceColors?: Color4[];
  130639. flat?: boolean;
  130640. updatable?: boolean;
  130641. sideOrientation?: number;
  130642. frontUVs?: Vector4;
  130643. backUVs?: Vector4;
  130644. }, scene?: Nullable<Scene>): Mesh;
  130645. /**
  130646. * Creates a decal mesh.
  130647. * 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
  130648. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130649. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130650. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130651. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130652. * @param name defines the name of the mesh
  130653. * @param sourceMesh defines the mesh where the decal must be applied
  130654. * @param options defines the options used to create the mesh
  130655. * @param scene defines the hosting scene
  130656. * @returns the decal mesh
  130657. * @see https://doc.babylonjs.com/how_to/decals
  130658. */
  130659. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130660. position?: Vector3;
  130661. normal?: Vector3;
  130662. size?: Vector3;
  130663. angle?: number;
  130664. }): Mesh;
  130665. }
  130666. }
  130667. declare module BABYLON {
  130668. /**
  130669. * A simplifier interface for future simplification implementations
  130670. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130671. */
  130672. export interface ISimplifier {
  130673. /**
  130674. * Simplification of a given mesh according to the given settings.
  130675. * Since this requires computation, it is assumed that the function runs async.
  130676. * @param settings The settings of the simplification, including quality and distance
  130677. * @param successCallback A callback that will be called after the mesh was simplified.
  130678. * @param errorCallback in case of an error, this callback will be called. optional.
  130679. */
  130680. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130681. }
  130682. /**
  130683. * Expected simplification settings.
  130684. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130685. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130686. */
  130687. export interface ISimplificationSettings {
  130688. /**
  130689. * Gets or sets the expected quality
  130690. */
  130691. quality: number;
  130692. /**
  130693. * Gets or sets the distance when this optimized version should be used
  130694. */
  130695. distance: number;
  130696. /**
  130697. * Gets an already optimized mesh
  130698. */
  130699. optimizeMesh?: boolean;
  130700. }
  130701. /**
  130702. * Class used to specify simplification options
  130703. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130704. */
  130705. export class SimplificationSettings implements ISimplificationSettings {
  130706. /** expected quality */
  130707. quality: number;
  130708. /** distance when this optimized version should be used */
  130709. distance: number;
  130710. /** already optimized mesh */
  130711. optimizeMesh?: boolean | undefined;
  130712. /**
  130713. * Creates a SimplificationSettings
  130714. * @param quality expected quality
  130715. * @param distance distance when this optimized version should be used
  130716. * @param optimizeMesh already optimized mesh
  130717. */
  130718. constructor(
  130719. /** expected quality */
  130720. quality: number,
  130721. /** distance when this optimized version should be used */
  130722. distance: number,
  130723. /** already optimized mesh */
  130724. optimizeMesh?: boolean | undefined);
  130725. }
  130726. /**
  130727. * Interface used to define a simplification task
  130728. */
  130729. export interface ISimplificationTask {
  130730. /**
  130731. * Array of settings
  130732. */
  130733. settings: Array<ISimplificationSettings>;
  130734. /**
  130735. * Simplification type
  130736. */
  130737. simplificationType: SimplificationType;
  130738. /**
  130739. * Mesh to simplify
  130740. */
  130741. mesh: Mesh;
  130742. /**
  130743. * Callback called on success
  130744. */
  130745. successCallback?: () => void;
  130746. /**
  130747. * Defines if parallel processing can be used
  130748. */
  130749. parallelProcessing: boolean;
  130750. }
  130751. /**
  130752. * Queue used to order the simplification tasks
  130753. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130754. */
  130755. export class SimplificationQueue {
  130756. private _simplificationArray;
  130757. /**
  130758. * Gets a boolean indicating that the process is still running
  130759. */
  130760. running: boolean;
  130761. /**
  130762. * Creates a new queue
  130763. */
  130764. constructor();
  130765. /**
  130766. * Adds a new simplification task
  130767. * @param task defines a task to add
  130768. */
  130769. addTask(task: ISimplificationTask): void;
  130770. /**
  130771. * Execute next task
  130772. */
  130773. executeNext(): void;
  130774. /**
  130775. * Execute a simplification task
  130776. * @param task defines the task to run
  130777. */
  130778. runSimplification(task: ISimplificationTask): void;
  130779. private getSimplifier;
  130780. }
  130781. /**
  130782. * The implemented types of simplification
  130783. * At the moment only Quadratic Error Decimation is implemented
  130784. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130785. */
  130786. export enum SimplificationType {
  130787. /** Quadratic error decimation */
  130788. QUADRATIC = 0
  130789. }
  130790. }
  130791. declare module BABYLON {
  130792. interface Scene {
  130793. /** @hidden (Backing field) */
  130794. _simplificationQueue: SimplificationQueue;
  130795. /**
  130796. * Gets or sets the simplification queue attached to the scene
  130797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130798. */
  130799. simplificationQueue: SimplificationQueue;
  130800. }
  130801. interface Mesh {
  130802. /**
  130803. * Simplify the mesh according to the given array of settings.
  130804. * Function will return immediately and will simplify async
  130805. * @param settings a collection of simplification settings
  130806. * @param parallelProcessing should all levels calculate parallel or one after the other
  130807. * @param simplificationType the type of simplification to run
  130808. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130809. * @returns the current mesh
  130810. */
  130811. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130812. }
  130813. /**
  130814. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130815. * created in a scene
  130816. */
  130817. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130818. /**
  130819. * The component name helpfull to identify the component in the list of scene components.
  130820. */
  130821. readonly name: string;
  130822. /**
  130823. * The scene the component belongs to.
  130824. */
  130825. scene: Scene;
  130826. /**
  130827. * Creates a new instance of the component for the given scene
  130828. * @param scene Defines the scene to register the component in
  130829. */
  130830. constructor(scene: Scene);
  130831. /**
  130832. * Registers the component in a given scene
  130833. */
  130834. register(): void;
  130835. /**
  130836. * Rebuilds the elements related to this component in case of
  130837. * context lost for instance.
  130838. */
  130839. rebuild(): void;
  130840. /**
  130841. * Disposes the component and the associated ressources
  130842. */
  130843. dispose(): void;
  130844. private _beforeCameraUpdate;
  130845. }
  130846. }
  130847. declare module BABYLON {
  130848. /**
  130849. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130850. */
  130851. export interface INavigationEnginePlugin {
  130852. /**
  130853. * plugin name
  130854. */
  130855. name: string;
  130856. /**
  130857. * Creates a navigation mesh
  130858. * @param meshes array of all the geometry used to compute the navigatio mesh
  130859. * @param parameters bunch of parameters used to filter geometry
  130860. */
  130861. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130862. /**
  130863. * Create a navigation mesh debug mesh
  130864. * @param scene is where the mesh will be added
  130865. * @returns debug display mesh
  130866. */
  130867. createDebugNavMesh(scene: Scene): Mesh;
  130868. /**
  130869. * Get a navigation mesh constrained position, closest to the parameter position
  130870. * @param position world position
  130871. * @returns the closest point to position constrained by the navigation mesh
  130872. */
  130873. getClosestPoint(position: Vector3): Vector3;
  130874. /**
  130875. * Get a navigation mesh constrained position, within a particular radius
  130876. * @param position world position
  130877. * @param maxRadius the maximum distance to the constrained world position
  130878. * @returns the closest point to position constrained by the navigation mesh
  130879. */
  130880. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130881. /**
  130882. * Compute the final position from a segment made of destination-position
  130883. * @param position world position
  130884. * @param destination world position
  130885. * @returns the resulting point along the navmesh
  130886. */
  130887. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130888. /**
  130889. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130890. * @param start world position
  130891. * @param end world position
  130892. * @returns array containing world position composing the path
  130893. */
  130894. computePath(start: Vector3, end: Vector3): Vector3[];
  130895. /**
  130896. * If this plugin is supported
  130897. * @returns true if plugin is supported
  130898. */
  130899. isSupported(): boolean;
  130900. /**
  130901. * Create a new Crowd so you can add agents
  130902. * @param maxAgents the maximum agent count in the crowd
  130903. * @param maxAgentRadius the maximum radius an agent can have
  130904. * @param scene to attach the crowd to
  130905. * @returns the crowd you can add agents to
  130906. */
  130907. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130908. /**
  130909. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130910. * The queries will try to find a solution within those bounds
  130911. * default is (1,1,1)
  130912. * @param extent x,y,z value that define the extent around the queries point of reference
  130913. */
  130914. setDefaultQueryExtent(extent: Vector3): void;
  130915. /**
  130916. * Get the Bounding box extent specified by setDefaultQueryExtent
  130917. * @returns the box extent values
  130918. */
  130919. getDefaultQueryExtent(): Vector3;
  130920. /**
  130921. * Release all resources
  130922. */
  130923. dispose(): void;
  130924. }
  130925. /**
  130926. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130927. */
  130928. export interface ICrowd {
  130929. /**
  130930. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130931. * You can attach anything to that node. The node position is updated in the scene update tick.
  130932. * @param pos world position that will be constrained by the navigation mesh
  130933. * @param parameters agent parameters
  130934. * @param transform hooked to the agent that will be update by the scene
  130935. * @returns agent index
  130936. */
  130937. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130938. /**
  130939. * Returns the agent position in world space
  130940. * @param index agent index returned by addAgent
  130941. * @returns world space position
  130942. */
  130943. getAgentPosition(index: number): Vector3;
  130944. /**
  130945. * Gets the agent velocity in world space
  130946. * @param index agent index returned by addAgent
  130947. * @returns world space velocity
  130948. */
  130949. getAgentVelocity(index: number): Vector3;
  130950. /**
  130951. * remove a particular agent previously created
  130952. * @param index agent index returned by addAgent
  130953. */
  130954. removeAgent(index: number): void;
  130955. /**
  130956. * get the list of all agents attached to this crowd
  130957. * @returns list of agent indices
  130958. */
  130959. getAgents(): number[];
  130960. /**
  130961. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130962. * @param deltaTime in seconds
  130963. */
  130964. update(deltaTime: number): void;
  130965. /**
  130966. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130967. * @param index agent index returned by addAgent
  130968. * @param destination targeted world position
  130969. */
  130970. agentGoto(index: number, destination: Vector3): void;
  130971. /**
  130972. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130973. * The queries will try to find a solution within those bounds
  130974. * default is (1,1,1)
  130975. * @param extent x,y,z value that define the extent around the queries point of reference
  130976. */
  130977. setDefaultQueryExtent(extent: Vector3): void;
  130978. /**
  130979. * Get the Bounding box extent specified by setDefaultQueryExtent
  130980. * @returns the box extent values
  130981. */
  130982. getDefaultQueryExtent(): Vector3;
  130983. /**
  130984. * Release all resources
  130985. */
  130986. dispose(): void;
  130987. }
  130988. /**
  130989. * Configures an agent
  130990. */
  130991. export interface IAgentParameters {
  130992. /**
  130993. * Agent radius. [Limit: >= 0]
  130994. */
  130995. radius: number;
  130996. /**
  130997. * Agent height. [Limit: > 0]
  130998. */
  130999. height: number;
  131000. /**
  131001. * Maximum allowed acceleration. [Limit: >= 0]
  131002. */
  131003. maxAcceleration: number;
  131004. /**
  131005. * Maximum allowed speed. [Limit: >= 0]
  131006. */
  131007. maxSpeed: number;
  131008. /**
  131009. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  131010. */
  131011. collisionQueryRange: number;
  131012. /**
  131013. * The path visibility optimization range. [Limit: > 0]
  131014. */
  131015. pathOptimizationRange: number;
  131016. /**
  131017. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  131018. */
  131019. separationWeight: number;
  131020. }
  131021. /**
  131022. * Configures the navigation mesh creation
  131023. */
  131024. export interface INavMeshParameters {
  131025. /**
  131026. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  131027. */
  131028. cs: number;
  131029. /**
  131030. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  131031. */
  131032. ch: number;
  131033. /**
  131034. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  131035. */
  131036. walkableSlopeAngle: number;
  131037. /**
  131038. * Minimum floor to 'ceiling' height that will still allow the floor area to
  131039. * be considered walkable. [Limit: >= 3] [Units: vx]
  131040. */
  131041. walkableHeight: number;
  131042. /**
  131043. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  131044. */
  131045. walkableClimb: number;
  131046. /**
  131047. * The distance to erode/shrink the walkable area of the heightfield away from
  131048. * obstructions. [Limit: >=0] [Units: vx]
  131049. */
  131050. walkableRadius: number;
  131051. /**
  131052. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  131053. */
  131054. maxEdgeLen: number;
  131055. /**
  131056. * The maximum distance a simplfied contour's border edges should deviate
  131057. * the original raw contour. [Limit: >=0] [Units: vx]
  131058. */
  131059. maxSimplificationError: number;
  131060. /**
  131061. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  131062. */
  131063. minRegionArea: number;
  131064. /**
  131065. * Any regions with a span count smaller than this value will, if possible,
  131066. * be merged with larger regions. [Limit: >=0] [Units: vx]
  131067. */
  131068. mergeRegionArea: number;
  131069. /**
  131070. * The maximum number of vertices allowed for polygons generated during the
  131071. * contour to polygon conversion process. [Limit: >= 3]
  131072. */
  131073. maxVertsPerPoly: number;
  131074. /**
  131075. * Sets the sampling distance to use when generating the detail mesh.
  131076. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  131077. */
  131078. detailSampleDist: number;
  131079. /**
  131080. * The maximum distance the detail mesh surface should deviate from heightfield
  131081. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  131082. */
  131083. detailSampleMaxError: number;
  131084. }
  131085. }
  131086. declare module BABYLON {
  131087. /**
  131088. * RecastJS navigation plugin
  131089. */
  131090. export class RecastJSPlugin implements INavigationEnginePlugin {
  131091. /**
  131092. * Reference to the Recast library
  131093. */
  131094. bjsRECAST: any;
  131095. /**
  131096. * plugin name
  131097. */
  131098. name: string;
  131099. /**
  131100. * the first navmesh created. We might extend this to support multiple navmeshes
  131101. */
  131102. navMesh: any;
  131103. /**
  131104. * Initializes the recastJS plugin
  131105. * @param recastInjection can be used to inject your own recast reference
  131106. */
  131107. constructor(recastInjection?: any);
  131108. /**
  131109. * Creates a navigation mesh
  131110. * @param meshes array of all the geometry used to compute the navigatio mesh
  131111. * @param parameters bunch of parameters used to filter geometry
  131112. */
  131113. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  131114. /**
  131115. * Create a navigation mesh debug mesh
  131116. * @param scene is where the mesh will be added
  131117. * @returns debug display mesh
  131118. */
  131119. createDebugNavMesh(scene: Scene): Mesh;
  131120. /**
  131121. * Get a navigation mesh constrained position, closest to the parameter position
  131122. * @param position world position
  131123. * @returns the closest point to position constrained by the navigation mesh
  131124. */
  131125. getClosestPoint(position: Vector3): Vector3;
  131126. /**
  131127. * Get a navigation mesh constrained position, within a particular radius
  131128. * @param position world position
  131129. * @param maxRadius the maximum distance to the constrained world position
  131130. * @returns the closest point to position constrained by the navigation mesh
  131131. */
  131132. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  131133. /**
  131134. * Compute the final position from a segment made of destination-position
  131135. * @param position world position
  131136. * @param destination world position
  131137. * @returns the resulting point along the navmesh
  131138. */
  131139. moveAlong(position: Vector3, destination: Vector3): Vector3;
  131140. /**
  131141. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  131142. * @param start world position
  131143. * @param end world position
  131144. * @returns array containing world position composing the path
  131145. */
  131146. computePath(start: Vector3, end: Vector3): Vector3[];
  131147. /**
  131148. * Create a new Crowd so you can add agents
  131149. * @param maxAgents the maximum agent count in the crowd
  131150. * @param maxAgentRadius the maximum radius an agent can have
  131151. * @param scene to attach the crowd to
  131152. * @returns the crowd you can add agents to
  131153. */
  131154. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  131155. /**
  131156. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131157. * The queries will try to find a solution within those bounds
  131158. * default is (1,1,1)
  131159. * @param extent x,y,z value that define the extent around the queries point of reference
  131160. */
  131161. setDefaultQueryExtent(extent: Vector3): void;
  131162. /**
  131163. * Get the Bounding box extent specified by setDefaultQueryExtent
  131164. * @returns the box extent values
  131165. */
  131166. getDefaultQueryExtent(): Vector3;
  131167. /**
  131168. * Disposes
  131169. */
  131170. dispose(): void;
  131171. /**
  131172. * If this plugin is supported
  131173. * @returns true if plugin is supported
  131174. */
  131175. isSupported(): boolean;
  131176. }
  131177. /**
  131178. * Recast detour crowd implementation
  131179. */
  131180. export class RecastJSCrowd implements ICrowd {
  131181. /**
  131182. * Recast/detour plugin
  131183. */
  131184. bjsRECASTPlugin: RecastJSPlugin;
  131185. /**
  131186. * Link to the detour crowd
  131187. */
  131188. recastCrowd: any;
  131189. /**
  131190. * One transform per agent
  131191. */
  131192. transforms: TransformNode[];
  131193. /**
  131194. * All agents created
  131195. */
  131196. agents: number[];
  131197. /**
  131198. * Link to the scene is kept to unregister the crowd from the scene
  131199. */
  131200. private _scene;
  131201. /**
  131202. * Observer for crowd updates
  131203. */
  131204. private _onBeforeAnimationsObserver;
  131205. /**
  131206. * Constructor
  131207. * @param plugin recastJS plugin
  131208. * @param maxAgents the maximum agent count in the crowd
  131209. * @param maxAgentRadius the maximum radius an agent can have
  131210. * @param scene to attach the crowd to
  131211. * @returns the crowd you can add agents to
  131212. */
  131213. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  131214. /**
  131215. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  131216. * You can attach anything to that node. The node position is updated in the scene update tick.
  131217. * @param pos world position that will be constrained by the navigation mesh
  131218. * @param parameters agent parameters
  131219. * @param transform hooked to the agent that will be update by the scene
  131220. * @returns agent index
  131221. */
  131222. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  131223. /**
  131224. * Returns the agent position in world space
  131225. * @param index agent index returned by addAgent
  131226. * @returns world space position
  131227. */
  131228. getAgentPosition(index: number): Vector3;
  131229. /**
  131230. * Returns the agent velocity in world space
  131231. * @param index agent index returned by addAgent
  131232. * @returns world space velocity
  131233. */
  131234. getAgentVelocity(index: number): Vector3;
  131235. /**
  131236. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131237. * @param index agent index returned by addAgent
  131238. * @param destination targeted world position
  131239. */
  131240. agentGoto(index: number, destination: Vector3): void;
  131241. /**
  131242. * remove a particular agent previously created
  131243. * @param index agent index returned by addAgent
  131244. */
  131245. removeAgent(index: number): void;
  131246. /**
  131247. * get the list of all agents attached to this crowd
  131248. * @returns list of agent indices
  131249. */
  131250. getAgents(): number[];
  131251. /**
  131252. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131253. * @param deltaTime in seconds
  131254. */
  131255. update(deltaTime: number): void;
  131256. /**
  131257. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131258. * The queries will try to find a solution within those bounds
  131259. * default is (1,1,1)
  131260. * @param extent x,y,z value that define the extent around the queries point of reference
  131261. */
  131262. setDefaultQueryExtent(extent: Vector3): void;
  131263. /**
  131264. * Get the Bounding box extent specified by setDefaultQueryExtent
  131265. * @returns the box extent values
  131266. */
  131267. getDefaultQueryExtent(): Vector3;
  131268. /**
  131269. * Release all resources
  131270. */
  131271. dispose(): void;
  131272. }
  131273. }
  131274. declare module BABYLON {
  131275. /**
  131276. * Class used to enable access to IndexedDB
  131277. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131278. */
  131279. export class Database implements IOfflineProvider {
  131280. private _callbackManifestChecked;
  131281. private _currentSceneUrl;
  131282. private _db;
  131283. private _enableSceneOffline;
  131284. private _enableTexturesOffline;
  131285. private _manifestVersionFound;
  131286. private _mustUpdateRessources;
  131287. private _hasReachedQuota;
  131288. private _isSupported;
  131289. private _idbFactory;
  131290. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131291. private static IsUASupportingBlobStorage;
  131292. /**
  131293. * Gets a boolean indicating if Database storate is enabled (off by default)
  131294. */
  131295. static IDBStorageEnabled: boolean;
  131296. /**
  131297. * Gets a boolean indicating if scene must be saved in the database
  131298. */
  131299. get enableSceneOffline(): boolean;
  131300. /**
  131301. * Gets a boolean indicating if textures must be saved in the database
  131302. */
  131303. get enableTexturesOffline(): boolean;
  131304. /**
  131305. * Creates a new Database
  131306. * @param urlToScene defines the url to load the scene
  131307. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131308. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131309. */
  131310. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131311. private static _ParseURL;
  131312. private static _ReturnFullUrlLocation;
  131313. private _checkManifestFile;
  131314. /**
  131315. * Open the database and make it available
  131316. * @param successCallback defines the callback to call on success
  131317. * @param errorCallback defines the callback to call on error
  131318. */
  131319. open(successCallback: () => void, errorCallback: () => void): void;
  131320. /**
  131321. * Loads an image from the database
  131322. * @param url defines the url to load from
  131323. * @param image defines the target DOM image
  131324. */
  131325. loadImage(url: string, image: HTMLImageElement): void;
  131326. private _loadImageFromDBAsync;
  131327. private _saveImageIntoDBAsync;
  131328. private _checkVersionFromDB;
  131329. private _loadVersionFromDBAsync;
  131330. private _saveVersionIntoDBAsync;
  131331. /**
  131332. * Loads a file from database
  131333. * @param url defines the URL to load from
  131334. * @param sceneLoaded defines a callback to call on success
  131335. * @param progressCallBack defines a callback to call when progress changed
  131336. * @param errorCallback defines a callback to call on error
  131337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131338. */
  131339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131340. private _loadFileAsync;
  131341. private _saveFileAsync;
  131342. /**
  131343. * Validates if xhr data is correct
  131344. * @param xhr defines the request to validate
  131345. * @param dataType defines the expected data type
  131346. * @returns true if data is correct
  131347. */
  131348. private static _ValidateXHRData;
  131349. }
  131350. }
  131351. declare module BABYLON {
  131352. /** @hidden */
  131353. export var gpuUpdateParticlesPixelShader: {
  131354. name: string;
  131355. shader: string;
  131356. };
  131357. }
  131358. declare module BABYLON {
  131359. /** @hidden */
  131360. export var gpuUpdateParticlesVertexShader: {
  131361. name: string;
  131362. shader: string;
  131363. };
  131364. }
  131365. declare module BABYLON {
  131366. /** @hidden */
  131367. export var clipPlaneFragmentDeclaration2: {
  131368. name: string;
  131369. shader: string;
  131370. };
  131371. }
  131372. declare module BABYLON {
  131373. /** @hidden */
  131374. export var gpuRenderParticlesPixelShader: {
  131375. name: string;
  131376. shader: string;
  131377. };
  131378. }
  131379. declare module BABYLON {
  131380. /** @hidden */
  131381. export var clipPlaneVertexDeclaration2: {
  131382. name: string;
  131383. shader: string;
  131384. };
  131385. }
  131386. declare module BABYLON {
  131387. /** @hidden */
  131388. export var gpuRenderParticlesVertexShader: {
  131389. name: string;
  131390. shader: string;
  131391. };
  131392. }
  131393. declare module BABYLON {
  131394. /**
  131395. * This represents a GPU particle system in Babylon
  131396. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131397. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131398. */
  131399. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131400. /**
  131401. * The layer mask we are rendering the particles through.
  131402. */
  131403. layerMask: number;
  131404. private _capacity;
  131405. private _activeCount;
  131406. private _currentActiveCount;
  131407. private _accumulatedCount;
  131408. private _renderEffect;
  131409. private _updateEffect;
  131410. private _buffer0;
  131411. private _buffer1;
  131412. private _spriteBuffer;
  131413. private _updateVAO;
  131414. private _renderVAO;
  131415. private _targetIndex;
  131416. private _sourceBuffer;
  131417. private _targetBuffer;
  131418. private _engine;
  131419. private _currentRenderId;
  131420. private _started;
  131421. private _stopped;
  131422. private _timeDelta;
  131423. private _randomTexture;
  131424. private _randomTexture2;
  131425. private _attributesStrideSize;
  131426. private _updateEffectOptions;
  131427. private _randomTextureSize;
  131428. private _actualFrame;
  131429. private readonly _rawTextureWidth;
  131430. /**
  131431. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131432. */
  131433. static get IsSupported(): boolean;
  131434. /**
  131435. * An event triggered when the system is disposed.
  131436. */
  131437. onDisposeObservable: Observable<GPUParticleSystem>;
  131438. /**
  131439. * Gets the maximum number of particles active at the same time.
  131440. * @returns The max number of active particles.
  131441. */
  131442. getCapacity(): number;
  131443. /**
  131444. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131445. * to override the particles.
  131446. */
  131447. forceDepthWrite: boolean;
  131448. /**
  131449. * Gets or set the number of active particles
  131450. */
  131451. get activeParticleCount(): number;
  131452. set activeParticleCount(value: number);
  131453. private _preWarmDone;
  131454. /**
  131455. * Is this system ready to be used/rendered
  131456. * @return true if the system is ready
  131457. */
  131458. isReady(): boolean;
  131459. /**
  131460. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131461. * @returns True if it has been started, otherwise false.
  131462. */
  131463. isStarted(): boolean;
  131464. /**
  131465. * Starts the particle system and begins to emit
  131466. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131467. */
  131468. start(delay?: number): void;
  131469. /**
  131470. * Stops the particle system.
  131471. */
  131472. stop(): void;
  131473. /**
  131474. * Remove all active particles
  131475. */
  131476. reset(): void;
  131477. /**
  131478. * Returns the string "GPUParticleSystem"
  131479. * @returns a string containing the class name
  131480. */
  131481. getClassName(): string;
  131482. private _colorGradientsTexture;
  131483. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131484. /**
  131485. * Adds a new color gradient
  131486. * @param gradient defines the gradient to use (between 0 and 1)
  131487. * @param color1 defines the color to affect to the specified gradient
  131488. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131489. * @returns the current particle system
  131490. */
  131491. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131492. /**
  131493. * Remove a specific color gradient
  131494. * @param gradient defines the gradient to remove
  131495. * @returns the current particle system
  131496. */
  131497. removeColorGradient(gradient: number): GPUParticleSystem;
  131498. private _angularSpeedGradientsTexture;
  131499. private _sizeGradientsTexture;
  131500. private _velocityGradientsTexture;
  131501. private _limitVelocityGradientsTexture;
  131502. private _dragGradientsTexture;
  131503. private _addFactorGradient;
  131504. /**
  131505. * Adds a new size gradient
  131506. * @param gradient defines the gradient to use (between 0 and 1)
  131507. * @param factor defines the size factor to affect to the specified gradient
  131508. * @returns the current particle system
  131509. */
  131510. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131511. /**
  131512. * Remove a specific size gradient
  131513. * @param gradient defines the gradient to remove
  131514. * @returns the current particle system
  131515. */
  131516. removeSizeGradient(gradient: number): GPUParticleSystem;
  131517. /**
  131518. * Adds a new angular speed gradient
  131519. * @param gradient defines the gradient to use (between 0 and 1)
  131520. * @param factor defines the angular speed to affect to the specified gradient
  131521. * @returns the current particle system
  131522. */
  131523. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131524. /**
  131525. * Remove a specific angular speed gradient
  131526. * @param gradient defines the gradient to remove
  131527. * @returns the current particle system
  131528. */
  131529. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131530. /**
  131531. * Adds a new velocity gradient
  131532. * @param gradient defines the gradient to use (between 0 and 1)
  131533. * @param factor defines the velocity to affect to the specified gradient
  131534. * @returns the current particle system
  131535. */
  131536. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131537. /**
  131538. * Remove a specific velocity gradient
  131539. * @param gradient defines the gradient to remove
  131540. * @returns the current particle system
  131541. */
  131542. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131543. /**
  131544. * Adds a new limit velocity gradient
  131545. * @param gradient defines the gradient to use (between 0 and 1)
  131546. * @param factor defines the limit velocity value to affect to the specified gradient
  131547. * @returns the current particle system
  131548. */
  131549. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131550. /**
  131551. * Remove a specific limit velocity gradient
  131552. * @param gradient defines the gradient to remove
  131553. * @returns the current particle system
  131554. */
  131555. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131556. /**
  131557. * Adds a new drag gradient
  131558. * @param gradient defines the gradient to use (between 0 and 1)
  131559. * @param factor defines the drag value to affect to the specified gradient
  131560. * @returns the current particle system
  131561. */
  131562. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131563. /**
  131564. * Remove a specific drag gradient
  131565. * @param gradient defines the gradient to remove
  131566. * @returns the current particle system
  131567. */
  131568. removeDragGradient(gradient: number): GPUParticleSystem;
  131569. /**
  131570. * Not supported by GPUParticleSystem
  131571. * @param gradient defines the gradient to use (between 0 and 1)
  131572. * @param factor defines the emit rate value to affect to the specified gradient
  131573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131574. * @returns the current particle system
  131575. */
  131576. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131577. /**
  131578. * Not supported by GPUParticleSystem
  131579. * @param gradient defines the gradient to remove
  131580. * @returns the current particle system
  131581. */
  131582. removeEmitRateGradient(gradient: number): IParticleSystem;
  131583. /**
  131584. * Not supported by GPUParticleSystem
  131585. * @param gradient defines the gradient to use (between 0 and 1)
  131586. * @param factor defines the start size value to affect to the specified gradient
  131587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131588. * @returns the current particle system
  131589. */
  131590. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131591. /**
  131592. * Not supported by GPUParticleSystem
  131593. * @param gradient defines the gradient to remove
  131594. * @returns the current particle system
  131595. */
  131596. removeStartSizeGradient(gradient: number): IParticleSystem;
  131597. /**
  131598. * Not supported by GPUParticleSystem
  131599. * @param gradient defines the gradient to use (between 0 and 1)
  131600. * @param min defines the color remap minimal range
  131601. * @param max defines the color remap maximal range
  131602. * @returns the current particle system
  131603. */
  131604. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131605. /**
  131606. * Not supported by GPUParticleSystem
  131607. * @param gradient defines the gradient to remove
  131608. * @returns the current particle system
  131609. */
  131610. removeColorRemapGradient(): IParticleSystem;
  131611. /**
  131612. * Not supported by GPUParticleSystem
  131613. * @param gradient defines the gradient to use (between 0 and 1)
  131614. * @param min defines the alpha remap minimal range
  131615. * @param max defines the alpha remap maximal range
  131616. * @returns the current particle system
  131617. */
  131618. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131619. /**
  131620. * Not supported by GPUParticleSystem
  131621. * @param gradient defines the gradient to remove
  131622. * @returns the current particle system
  131623. */
  131624. removeAlphaRemapGradient(): IParticleSystem;
  131625. /**
  131626. * Not supported by GPUParticleSystem
  131627. * @param gradient defines the gradient to use (between 0 and 1)
  131628. * @param color defines the color to affect to the specified gradient
  131629. * @returns the current particle system
  131630. */
  131631. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131632. /**
  131633. * Not supported by GPUParticleSystem
  131634. * @param gradient defines the gradient to remove
  131635. * @returns the current particle system
  131636. */
  131637. removeRampGradient(): IParticleSystem;
  131638. /**
  131639. * Not supported by GPUParticleSystem
  131640. * @returns the list of ramp gradients
  131641. */
  131642. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131643. /**
  131644. * Not supported by GPUParticleSystem
  131645. * Gets or sets a boolean indicating that ramp gradients must be used
  131646. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131647. */
  131648. get useRampGradients(): boolean;
  131649. set useRampGradients(value: boolean);
  131650. /**
  131651. * Not supported by GPUParticleSystem
  131652. * @param gradient defines the gradient to use (between 0 and 1)
  131653. * @param factor defines the life time factor to affect to the specified gradient
  131654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131655. * @returns the current particle system
  131656. */
  131657. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131658. /**
  131659. * Not supported by GPUParticleSystem
  131660. * @param gradient defines the gradient to remove
  131661. * @returns the current particle system
  131662. */
  131663. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131664. /**
  131665. * Instantiates a GPU particle system.
  131666. * 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.
  131667. * @param name The name of the particle system
  131668. * @param options The options used to create the system
  131669. * @param scene The scene the particle system belongs to
  131670. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131671. */
  131672. constructor(name: string, options: Partial<{
  131673. capacity: number;
  131674. randomTextureSize: number;
  131675. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131676. protected _reset(): void;
  131677. private _createUpdateVAO;
  131678. private _createRenderVAO;
  131679. private _initialize;
  131680. /** @hidden */
  131681. _recreateUpdateEffect(): void;
  131682. /** @hidden */
  131683. _recreateRenderEffect(): void;
  131684. /**
  131685. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131686. * @param preWarm defines if we are in the pre-warmimg phase
  131687. */
  131688. animate(preWarm?: boolean): void;
  131689. private _createFactorGradientTexture;
  131690. private _createSizeGradientTexture;
  131691. private _createAngularSpeedGradientTexture;
  131692. private _createVelocityGradientTexture;
  131693. private _createLimitVelocityGradientTexture;
  131694. private _createDragGradientTexture;
  131695. private _createColorGradientTexture;
  131696. /**
  131697. * Renders the particle system in its current state
  131698. * @param preWarm defines if the system should only update the particles but not render them
  131699. * @returns the current number of particles
  131700. */
  131701. render(preWarm?: boolean): number;
  131702. /**
  131703. * Rebuilds the particle system
  131704. */
  131705. rebuild(): void;
  131706. private _releaseBuffers;
  131707. private _releaseVAOs;
  131708. /**
  131709. * Disposes the particle system and free the associated resources
  131710. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131711. */
  131712. dispose(disposeTexture?: boolean): void;
  131713. /**
  131714. * Clones the particle system.
  131715. * @param name The name of the cloned object
  131716. * @param newEmitter The new emitter to use
  131717. * @returns the cloned particle system
  131718. */
  131719. clone(name: string, newEmitter: any): GPUParticleSystem;
  131720. /**
  131721. * Serializes the particle system to a JSON object.
  131722. * @returns the JSON object
  131723. */
  131724. serialize(): any;
  131725. /**
  131726. * Parses a JSON object to create a GPU particle system.
  131727. * @param parsedParticleSystem The JSON object to parse
  131728. * @param scene The scene to create the particle system in
  131729. * @param rootUrl The root url to use to load external dependencies like texture
  131730. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131731. * @returns the parsed GPU particle system
  131732. */
  131733. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131734. }
  131735. }
  131736. declare module BABYLON {
  131737. /**
  131738. * Represents a set of particle systems working together to create a specific effect
  131739. */
  131740. export class ParticleSystemSet implements IDisposable {
  131741. /**
  131742. * Gets or sets base Assets URL
  131743. */
  131744. static BaseAssetsUrl: string;
  131745. private _emitterCreationOptions;
  131746. private _emitterNode;
  131747. /**
  131748. * Gets the particle system list
  131749. */
  131750. systems: IParticleSystem[];
  131751. /**
  131752. * Gets the emitter node used with this set
  131753. */
  131754. get emitterNode(): Nullable<TransformNode>;
  131755. /**
  131756. * Creates a new emitter mesh as a sphere
  131757. * @param options defines the options used to create the sphere
  131758. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131759. * @param scene defines the hosting scene
  131760. */
  131761. setEmitterAsSphere(options: {
  131762. diameter: number;
  131763. segments: number;
  131764. color: Color3;
  131765. }, renderingGroupId: number, scene: Scene): void;
  131766. /**
  131767. * Starts all particle systems of the set
  131768. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131769. */
  131770. start(emitter?: AbstractMesh): void;
  131771. /**
  131772. * Release all associated resources
  131773. */
  131774. dispose(): void;
  131775. /**
  131776. * Serialize the set into a JSON compatible object
  131777. * @returns a JSON compatible representation of the set
  131778. */
  131779. serialize(): any;
  131780. /**
  131781. * Parse a new ParticleSystemSet from a serialized source
  131782. * @param data defines a JSON compatible representation of the set
  131783. * @param scene defines the hosting scene
  131784. * @param gpu defines if we want GPU particles or CPU particles
  131785. * @returns a new ParticleSystemSet
  131786. */
  131787. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131788. }
  131789. }
  131790. declare module BABYLON {
  131791. /**
  131792. * This class is made for on one-liner static method to help creating particle system set.
  131793. */
  131794. export class ParticleHelper {
  131795. /**
  131796. * Gets or sets base Assets URL
  131797. */
  131798. static BaseAssetsUrl: string;
  131799. /**
  131800. * Create a default particle system that you can tweak
  131801. * @param emitter defines the emitter to use
  131802. * @param capacity defines the system capacity (default is 500 particles)
  131803. * @param scene defines the hosting scene
  131804. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131805. * @returns the new Particle system
  131806. */
  131807. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131808. /**
  131809. * This is the main static method (one-liner) of this helper to create different particle systems
  131810. * @param type This string represents the type to the particle system to create
  131811. * @param scene The scene where the particle system should live
  131812. * @param gpu If the system will use gpu
  131813. * @returns the ParticleSystemSet created
  131814. */
  131815. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131816. /**
  131817. * Static function used to export a particle system to a ParticleSystemSet variable.
  131818. * Please note that the emitter shape is not exported
  131819. * @param systems defines the particle systems to export
  131820. * @returns the created particle system set
  131821. */
  131822. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131823. }
  131824. }
  131825. declare module BABYLON {
  131826. interface Engine {
  131827. /**
  131828. * Create an effect to use with particle systems.
  131829. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131830. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131831. * @param uniformsNames defines a list of attribute names
  131832. * @param samplers defines an array of string used to represent textures
  131833. * @param defines defines the string containing the defines to use to compile the shaders
  131834. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131835. * @param onCompiled defines a function to call when the effect creation is successful
  131836. * @param onError defines a function to call when the effect creation has failed
  131837. * @returns the new Effect
  131838. */
  131839. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131840. }
  131841. interface Mesh {
  131842. /**
  131843. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131844. * @returns an array of IParticleSystem
  131845. */
  131846. getEmittedParticleSystems(): IParticleSystem[];
  131847. /**
  131848. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131849. * @returns an array of IParticleSystem
  131850. */
  131851. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131852. }
  131853. /**
  131854. * @hidden
  131855. */
  131856. export var _IDoNeedToBeInTheBuild: number;
  131857. }
  131858. declare module BABYLON {
  131859. /** Defines the 4 color options */
  131860. export enum PointColor {
  131861. /** color value */
  131862. Color = 2,
  131863. /** uv value */
  131864. UV = 1,
  131865. /** random value */
  131866. Random = 0,
  131867. /** stated value */
  131868. Stated = 3
  131869. }
  131870. /**
  131871. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131872. * 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.
  131873. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131874. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131875. *
  131876. * Full documentation here : TO BE ENTERED
  131877. */
  131878. export class PointsCloudSystem implements IDisposable {
  131879. /**
  131880. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131881. * Example : var p = SPS.particles[i];
  131882. */
  131883. particles: CloudPoint[];
  131884. /**
  131885. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131886. */
  131887. nbParticles: number;
  131888. /**
  131889. * This a counter for your own usage. It's not set by any SPS functions.
  131890. */
  131891. counter: number;
  131892. /**
  131893. * The PCS name. This name is also given to the underlying mesh.
  131894. */
  131895. name: string;
  131896. /**
  131897. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131898. */
  131899. mesh: Mesh;
  131900. /**
  131901. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131902. * Please read :
  131903. */
  131904. vars: any;
  131905. /**
  131906. * @hidden
  131907. */
  131908. _size: number;
  131909. private _scene;
  131910. private _promises;
  131911. private _positions;
  131912. private _indices;
  131913. private _normals;
  131914. private _colors;
  131915. private _uvs;
  131916. private _indices32;
  131917. private _positions32;
  131918. private _colors32;
  131919. private _uvs32;
  131920. private _updatable;
  131921. private _isVisibilityBoxLocked;
  131922. private _alwaysVisible;
  131923. private _groups;
  131924. private _groupCounter;
  131925. private _computeParticleColor;
  131926. private _computeParticleTexture;
  131927. private _computeParticleRotation;
  131928. private _computeBoundingBox;
  131929. private _isReady;
  131930. /**
  131931. * Creates a PCS (Points Cloud System) object
  131932. * @param name (String) is the PCS name, this will be the underlying mesh name
  131933. * @param pointSize (number) is the size for each point
  131934. * @param scene (Scene) is the scene in which the PCS is added
  131935. * @param options defines the options of the PCS e.g.
  131936. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131937. */
  131938. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131939. updatable?: boolean;
  131940. });
  131941. /**
  131942. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131943. * If no points were added to the PCS, the returned mesh is just a single point.
  131944. * @returns a promise for the created mesh
  131945. */
  131946. buildMeshAsync(): Promise<Mesh>;
  131947. /**
  131948. * @hidden
  131949. */
  131950. private _buildMesh;
  131951. private _addParticle;
  131952. private _randomUnitVector;
  131953. private _getColorIndicesForCoord;
  131954. private _setPointsColorOrUV;
  131955. private _colorFromTexture;
  131956. private _calculateDensity;
  131957. /**
  131958. * Adds points to the PCS in random positions within a unit sphere
  131959. * @param nb (positive integer) the number of particles to be created from this model
  131960. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131961. * @returns the number of groups in the system
  131962. */
  131963. addPoints(nb: number, pointFunction?: any): number;
  131964. /**
  131965. * Adds points to the PCS from the surface of 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. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131974. /**
  131975. * Adds points to the PCS inside the model shape
  131976. * @param mesh is any Mesh object that will be used as a surface model for the points
  131977. * @param nb (positive integer) the number of particles to be created from this model
  131978. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131979. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131980. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131981. * @returns the number of groups in the system
  131982. */
  131983. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131984. /**
  131985. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131986. * This method calls `updateParticle()` for each particle of the SPS.
  131987. * For an animated SPS, it is usually called within the render loop.
  131988. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131989. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131990. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131991. * @returns the PCS.
  131992. */
  131993. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131994. /**
  131995. * Disposes the PCS.
  131996. */
  131997. dispose(): void;
  131998. /**
  131999. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  132000. * doc :
  132001. * @returns the PCS.
  132002. */
  132003. refreshVisibleSize(): PointsCloudSystem;
  132004. /**
  132005. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  132006. * @param size the size (float) of the visibility box
  132007. * note : this doesn't lock the PCS mesh bounding box.
  132008. * doc :
  132009. */
  132010. setVisibilityBox(size: number): void;
  132011. /**
  132012. * Gets whether the PCS is always visible or not
  132013. * doc :
  132014. */
  132015. get isAlwaysVisible(): boolean;
  132016. /**
  132017. * Sets the PCS as always visible or not
  132018. * doc :
  132019. */
  132020. set isAlwaysVisible(val: boolean);
  132021. /**
  132022. * Tells to `setParticles()` to compute the particle rotations or not
  132023. * Default value : false. The PCS is faster when it's set to false
  132024. * Note : particle rotations are only applied to parent particles
  132025. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  132026. */
  132027. set computeParticleRotation(val: boolean);
  132028. /**
  132029. * Tells to `setParticles()` to compute the particle colors or not.
  132030. * Default value : true. The PCS is faster when it's set to false.
  132031. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  132032. */
  132033. set computeParticleColor(val: boolean);
  132034. set computeParticleTexture(val: boolean);
  132035. /**
  132036. * Gets if `setParticles()` computes the particle colors or not.
  132037. * Default value : false. The PCS is faster when it's set to false.
  132038. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  132039. */
  132040. get computeParticleColor(): boolean;
  132041. /**
  132042. * Gets if `setParticles()` computes the particle textures or not.
  132043. * Default value : false. The PCS is faster when it's set to false.
  132044. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  132045. */
  132046. get computeParticleTexture(): boolean;
  132047. /**
  132048. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  132049. */
  132050. set computeBoundingBox(val: boolean);
  132051. /**
  132052. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  132053. */
  132054. get computeBoundingBox(): boolean;
  132055. /**
  132056. * This function does nothing. It may be overwritten to set all the particle first values.
  132057. * The PCS doesn't call this function, you may have to call it by your own.
  132058. * doc :
  132059. */
  132060. initParticles(): void;
  132061. /**
  132062. * This function does nothing. It may be overwritten to recycle a particle
  132063. * The PCS doesn't call this function, you can to call it
  132064. * doc :
  132065. * @param particle The particle to recycle
  132066. * @returns the recycled particle
  132067. */
  132068. recycleParticle(particle: CloudPoint): CloudPoint;
  132069. /**
  132070. * Updates a particle : this function should be overwritten by the user.
  132071. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  132072. * doc :
  132073. * @example : just set a particle position or velocity and recycle conditions
  132074. * @param particle The particle to update
  132075. * @returns the updated particle
  132076. */
  132077. updateParticle(particle: CloudPoint): CloudPoint;
  132078. /**
  132079. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  132080. * This does nothing and may be overwritten by the user.
  132081. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132082. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132083. * @param update the boolean update value actually passed to setParticles()
  132084. */
  132085. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132086. /**
  132087. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  132088. * This will be passed three parameters.
  132089. * This does nothing and may be overwritten by the user.
  132090. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132091. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132092. * @param update the boolean update value actually passed to setParticles()
  132093. */
  132094. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132095. }
  132096. }
  132097. declare module BABYLON {
  132098. /**
  132099. * Represents one particle of a points cloud system.
  132100. */
  132101. export class CloudPoint {
  132102. /**
  132103. * particle global index
  132104. */
  132105. idx: number;
  132106. /**
  132107. * The color of the particle
  132108. */
  132109. color: Nullable<Color4>;
  132110. /**
  132111. * The world space position of the particle.
  132112. */
  132113. position: Vector3;
  132114. /**
  132115. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  132116. */
  132117. rotation: Vector3;
  132118. /**
  132119. * The world space rotation quaternion of the particle.
  132120. */
  132121. rotationQuaternion: Nullable<Quaternion>;
  132122. /**
  132123. * The uv of the particle.
  132124. */
  132125. uv: Nullable<Vector2>;
  132126. /**
  132127. * The current speed of the particle.
  132128. */
  132129. velocity: Vector3;
  132130. /**
  132131. * The pivot point in the particle local space.
  132132. */
  132133. pivot: Vector3;
  132134. /**
  132135. * Must the particle be translated from its pivot point in its local space ?
  132136. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  132137. * Default : false
  132138. */
  132139. translateFromPivot: boolean;
  132140. /**
  132141. * Index of this particle in the global "positions" array (Internal use)
  132142. * @hidden
  132143. */
  132144. _pos: number;
  132145. /**
  132146. * @hidden Index of this particle in the global "indices" array (Internal use)
  132147. */
  132148. _ind: number;
  132149. /**
  132150. * Group this particle belongs to
  132151. */
  132152. _group: PointsGroup;
  132153. /**
  132154. * Group id of this particle
  132155. */
  132156. groupId: number;
  132157. /**
  132158. * Index of the particle in its group id (Internal use)
  132159. */
  132160. idxInGroup: number;
  132161. /**
  132162. * @hidden Particle BoundingInfo object (Internal use)
  132163. */
  132164. _boundingInfo: BoundingInfo;
  132165. /**
  132166. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  132167. */
  132168. _pcs: PointsCloudSystem;
  132169. /**
  132170. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  132171. */
  132172. _stillInvisible: boolean;
  132173. /**
  132174. * @hidden Last computed particle rotation matrix
  132175. */
  132176. _rotationMatrix: number[];
  132177. /**
  132178. * Parent particle Id, if any.
  132179. * Default null.
  132180. */
  132181. parentId: Nullable<number>;
  132182. /**
  132183. * @hidden Internal global position in the PCS.
  132184. */
  132185. _globalPosition: Vector3;
  132186. /**
  132187. * Creates a Point Cloud object.
  132188. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  132189. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  132190. * @param group (PointsGroup) is the group the particle belongs to
  132191. * @param groupId (integer) is the group identifier in the PCS.
  132192. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  132193. * @param pcs defines the PCS it is associated to
  132194. */
  132195. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  132196. /**
  132197. * get point size
  132198. */
  132199. get size(): Vector3;
  132200. /**
  132201. * Set point size
  132202. */
  132203. set size(scale: Vector3);
  132204. /**
  132205. * Legacy support, changed quaternion to rotationQuaternion
  132206. */
  132207. get quaternion(): Nullable<Quaternion>;
  132208. /**
  132209. * Legacy support, changed quaternion to rotationQuaternion
  132210. */
  132211. set quaternion(q: Nullable<Quaternion>);
  132212. /**
  132213. * Returns a boolean. True if the particle intersects a mesh, else false
  132214. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  132215. * @param target is the object (point or mesh) what the intersection is computed against
  132216. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  132217. * @returns true if it intersects
  132218. */
  132219. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  132220. /**
  132221. * get the rotation matrix of the particle
  132222. * @hidden
  132223. */
  132224. getRotationMatrix(m: Matrix): void;
  132225. }
  132226. /**
  132227. * Represents a group of points in a points cloud system
  132228. * * PCS internal tool, don't use it manually.
  132229. */
  132230. export class PointsGroup {
  132231. /**
  132232. * The group id
  132233. * @hidden
  132234. */
  132235. groupID: number;
  132236. /**
  132237. * image data for group (internal use)
  132238. * @hidden
  132239. */
  132240. _groupImageData: Nullable<ArrayBufferView>;
  132241. /**
  132242. * Image Width (internal use)
  132243. * @hidden
  132244. */
  132245. _groupImgWidth: number;
  132246. /**
  132247. * Image Height (internal use)
  132248. * @hidden
  132249. */
  132250. _groupImgHeight: number;
  132251. /**
  132252. * Custom position function (internal use)
  132253. * @hidden
  132254. */
  132255. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132256. /**
  132257. * density per facet for surface points
  132258. * @hidden
  132259. */
  132260. _groupDensity: number[];
  132261. /**
  132262. * Only when points are colored by texture carries pointer to texture list array
  132263. * @hidden
  132264. */
  132265. _textureNb: number;
  132266. /**
  132267. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132268. * PCS internal tool, don't use it manually.
  132269. * @hidden
  132270. */
  132271. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132272. }
  132273. }
  132274. declare module BABYLON {
  132275. interface Scene {
  132276. /** @hidden (Backing field) */
  132277. _physicsEngine: Nullable<IPhysicsEngine>;
  132278. /** @hidden */
  132279. _physicsTimeAccumulator: number;
  132280. /**
  132281. * Gets the current physics engine
  132282. * @returns a IPhysicsEngine or null if none attached
  132283. */
  132284. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132285. /**
  132286. * Enables physics to the current scene
  132287. * @param gravity defines the scene's gravity for the physics engine
  132288. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132289. * @return a boolean indicating if the physics engine was initialized
  132290. */
  132291. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132292. /**
  132293. * Disables and disposes the physics engine associated with the scene
  132294. */
  132295. disablePhysicsEngine(): void;
  132296. /**
  132297. * Gets a boolean indicating if there is an active physics engine
  132298. * @returns a boolean indicating if there is an active physics engine
  132299. */
  132300. isPhysicsEnabled(): boolean;
  132301. /**
  132302. * Deletes a physics compound impostor
  132303. * @param compound defines the compound to delete
  132304. */
  132305. deleteCompoundImpostor(compound: any): void;
  132306. /**
  132307. * An event triggered when physic simulation is about to be run
  132308. */
  132309. onBeforePhysicsObservable: Observable<Scene>;
  132310. /**
  132311. * An event triggered when physic simulation has been done
  132312. */
  132313. onAfterPhysicsObservable: Observable<Scene>;
  132314. }
  132315. interface AbstractMesh {
  132316. /** @hidden */
  132317. _physicsImpostor: Nullable<PhysicsImpostor>;
  132318. /**
  132319. * Gets or sets impostor used for physic simulation
  132320. * @see http://doc.babylonjs.com/features/physics_engine
  132321. */
  132322. physicsImpostor: Nullable<PhysicsImpostor>;
  132323. /**
  132324. * Gets the current physics impostor
  132325. * @see http://doc.babylonjs.com/features/physics_engine
  132326. * @returns a physics impostor or null
  132327. */
  132328. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132329. /** Apply a physic impulse to the mesh
  132330. * @param force defines the force to apply
  132331. * @param contactPoint defines where to apply the force
  132332. * @returns the current mesh
  132333. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132334. */
  132335. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132336. /**
  132337. * Creates a physic joint between two meshes
  132338. * @param otherMesh defines the other mesh to use
  132339. * @param pivot1 defines the pivot to use on this mesh
  132340. * @param pivot2 defines the pivot to use on the other mesh
  132341. * @param options defines additional options (can be plugin dependent)
  132342. * @returns the current mesh
  132343. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132344. */
  132345. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132346. /** @hidden */
  132347. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132348. }
  132349. /**
  132350. * Defines the physics engine scene component responsible to manage a physics engine
  132351. */
  132352. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132353. /**
  132354. * The component name helpful to identify the component in the list of scene components.
  132355. */
  132356. readonly name: string;
  132357. /**
  132358. * The scene the component belongs to.
  132359. */
  132360. scene: Scene;
  132361. /**
  132362. * Creates a new instance of the component for the given scene
  132363. * @param scene Defines the scene to register the component in
  132364. */
  132365. constructor(scene: Scene);
  132366. /**
  132367. * Registers the component in a given scene
  132368. */
  132369. register(): void;
  132370. /**
  132371. * Rebuilds the elements related to this component in case of
  132372. * context lost for instance.
  132373. */
  132374. rebuild(): void;
  132375. /**
  132376. * Disposes the component and the associated ressources
  132377. */
  132378. dispose(): void;
  132379. }
  132380. }
  132381. declare module BABYLON {
  132382. /**
  132383. * A helper for physics simulations
  132384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132385. */
  132386. export class PhysicsHelper {
  132387. private _scene;
  132388. private _physicsEngine;
  132389. /**
  132390. * Initializes the Physics helper
  132391. * @param scene Babylon.js scene
  132392. */
  132393. constructor(scene: Scene);
  132394. /**
  132395. * Applies a radial explosion impulse
  132396. * @param origin the origin of the explosion
  132397. * @param radiusOrEventOptions the radius or the options of radial explosion
  132398. * @param strength the explosion strength
  132399. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132400. * @returns A physics radial explosion event, or null
  132401. */
  132402. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132403. /**
  132404. * Applies a radial explosion force
  132405. * @param origin the origin of the explosion
  132406. * @param radiusOrEventOptions the radius or the options of radial explosion
  132407. * @param strength the explosion strength
  132408. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132409. * @returns A physics radial explosion event, or null
  132410. */
  132411. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132412. /**
  132413. * Creates a gravitational field
  132414. * @param origin the origin of the explosion
  132415. * @param radiusOrEventOptions the radius or the options of radial explosion
  132416. * @param strength the explosion strength
  132417. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132418. * @returns A physics gravitational field event, or null
  132419. */
  132420. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132421. /**
  132422. * Creates a physics updraft event
  132423. * @param origin the origin of the updraft
  132424. * @param radiusOrEventOptions the radius or the options of the updraft
  132425. * @param strength the strength of the updraft
  132426. * @param height the height of the updraft
  132427. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132428. * @returns A physics updraft event, or null
  132429. */
  132430. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132431. /**
  132432. * Creates a physics vortex event
  132433. * @param origin the of the vortex
  132434. * @param radiusOrEventOptions the radius or the options of the vortex
  132435. * @param strength the strength of the vortex
  132436. * @param height the height of the vortex
  132437. * @returns a Physics vortex event, or null
  132438. * A physics vortex event or null
  132439. */
  132440. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132441. }
  132442. /**
  132443. * Represents a physics radial explosion event
  132444. */
  132445. class PhysicsRadialExplosionEvent {
  132446. private _scene;
  132447. private _options;
  132448. private _sphere;
  132449. private _dataFetched;
  132450. /**
  132451. * Initializes a radial explosioin event
  132452. * @param _scene BabylonJS scene
  132453. * @param _options The options for the vortex event
  132454. */
  132455. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132456. /**
  132457. * Returns the data related to the radial explosion event (sphere).
  132458. * @returns The radial explosion event data
  132459. */
  132460. getData(): PhysicsRadialExplosionEventData;
  132461. /**
  132462. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132463. * @param impostor A physics imposter
  132464. * @param origin the origin of the explosion
  132465. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132466. */
  132467. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132468. /**
  132469. * Triggers affecterd impostors callbacks
  132470. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132471. */
  132472. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132473. /**
  132474. * Disposes the sphere.
  132475. * @param force Specifies if the sphere should be disposed by force
  132476. */
  132477. dispose(force?: boolean): void;
  132478. /*** Helpers ***/
  132479. private _prepareSphere;
  132480. private _intersectsWithSphere;
  132481. }
  132482. /**
  132483. * Represents a gravitational field event
  132484. */
  132485. class PhysicsGravitationalFieldEvent {
  132486. private _physicsHelper;
  132487. private _scene;
  132488. private _origin;
  132489. private _options;
  132490. private _tickCallback;
  132491. private _sphere;
  132492. private _dataFetched;
  132493. /**
  132494. * Initializes the physics gravitational field event
  132495. * @param _physicsHelper A physics helper
  132496. * @param _scene BabylonJS scene
  132497. * @param _origin The origin position of the gravitational field event
  132498. * @param _options The options for the vortex event
  132499. */
  132500. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132501. /**
  132502. * Returns the data related to the gravitational field event (sphere).
  132503. * @returns A gravitational field event
  132504. */
  132505. getData(): PhysicsGravitationalFieldEventData;
  132506. /**
  132507. * Enables the gravitational field.
  132508. */
  132509. enable(): void;
  132510. /**
  132511. * Disables the gravitational field.
  132512. */
  132513. disable(): void;
  132514. /**
  132515. * Disposes the sphere.
  132516. * @param force The force to dispose from the gravitational field event
  132517. */
  132518. dispose(force?: boolean): void;
  132519. private _tick;
  132520. }
  132521. /**
  132522. * Represents a physics updraft event
  132523. */
  132524. class PhysicsUpdraftEvent {
  132525. private _scene;
  132526. private _origin;
  132527. private _options;
  132528. private _physicsEngine;
  132529. private _originTop;
  132530. private _originDirection;
  132531. private _tickCallback;
  132532. private _cylinder;
  132533. private _cylinderPosition;
  132534. private _dataFetched;
  132535. /**
  132536. * Initializes the physics updraft event
  132537. * @param _scene BabylonJS scene
  132538. * @param _origin The origin position of the updraft
  132539. * @param _options The options for the updraft event
  132540. */
  132541. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132542. /**
  132543. * Returns the data related to the updraft event (cylinder).
  132544. * @returns A physics updraft event
  132545. */
  132546. getData(): PhysicsUpdraftEventData;
  132547. /**
  132548. * Enables the updraft.
  132549. */
  132550. enable(): void;
  132551. /**
  132552. * Disables the updraft.
  132553. */
  132554. disable(): void;
  132555. /**
  132556. * Disposes the cylinder.
  132557. * @param force Specifies if the updraft should be disposed by force
  132558. */
  132559. dispose(force?: boolean): void;
  132560. private getImpostorHitData;
  132561. private _tick;
  132562. /*** Helpers ***/
  132563. private _prepareCylinder;
  132564. private _intersectsWithCylinder;
  132565. }
  132566. /**
  132567. * Represents a physics vortex event
  132568. */
  132569. class PhysicsVortexEvent {
  132570. private _scene;
  132571. private _origin;
  132572. private _options;
  132573. private _physicsEngine;
  132574. private _originTop;
  132575. private _tickCallback;
  132576. private _cylinder;
  132577. private _cylinderPosition;
  132578. private _dataFetched;
  132579. /**
  132580. * Initializes the physics vortex event
  132581. * @param _scene The BabylonJS scene
  132582. * @param _origin The origin position of the vortex
  132583. * @param _options The options for the vortex event
  132584. */
  132585. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132586. /**
  132587. * Returns the data related to the vortex event (cylinder).
  132588. * @returns The physics vortex event data
  132589. */
  132590. getData(): PhysicsVortexEventData;
  132591. /**
  132592. * Enables the vortex.
  132593. */
  132594. enable(): void;
  132595. /**
  132596. * Disables the cortex.
  132597. */
  132598. disable(): void;
  132599. /**
  132600. * Disposes the sphere.
  132601. * @param force
  132602. */
  132603. dispose(force?: boolean): void;
  132604. private getImpostorHitData;
  132605. private _tick;
  132606. /*** Helpers ***/
  132607. private _prepareCylinder;
  132608. private _intersectsWithCylinder;
  132609. }
  132610. /**
  132611. * Options fot the radial explosion event
  132612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132613. */
  132614. export class PhysicsRadialExplosionEventOptions {
  132615. /**
  132616. * The radius of the sphere for the radial explosion.
  132617. */
  132618. radius: number;
  132619. /**
  132620. * The strenth of the explosion.
  132621. */
  132622. strength: number;
  132623. /**
  132624. * The strenght of the force in correspondence to the distance of the affected object
  132625. */
  132626. falloff: PhysicsRadialImpulseFalloff;
  132627. /**
  132628. * Sphere options for the radial explosion.
  132629. */
  132630. sphere: {
  132631. segments: number;
  132632. diameter: number;
  132633. };
  132634. /**
  132635. * Sphere options for the radial explosion.
  132636. */
  132637. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132638. }
  132639. /**
  132640. * Options fot the updraft event
  132641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132642. */
  132643. export class PhysicsUpdraftEventOptions {
  132644. /**
  132645. * The radius of the cylinder for the vortex
  132646. */
  132647. radius: number;
  132648. /**
  132649. * The strenth of the updraft.
  132650. */
  132651. strength: number;
  132652. /**
  132653. * The height of the cylinder for the updraft.
  132654. */
  132655. height: number;
  132656. /**
  132657. * The mode for the the updraft.
  132658. */
  132659. updraftMode: PhysicsUpdraftMode;
  132660. }
  132661. /**
  132662. * Options fot the vortex event
  132663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132664. */
  132665. export class PhysicsVortexEventOptions {
  132666. /**
  132667. * The radius of the cylinder for the vortex
  132668. */
  132669. radius: number;
  132670. /**
  132671. * The strenth of the vortex.
  132672. */
  132673. strength: number;
  132674. /**
  132675. * The height of the cylinder for the vortex.
  132676. */
  132677. height: number;
  132678. /**
  132679. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132680. */
  132681. centripetalForceThreshold: number;
  132682. /**
  132683. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132684. */
  132685. centripetalForceMultiplier: number;
  132686. /**
  132687. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132688. */
  132689. centrifugalForceMultiplier: number;
  132690. /**
  132691. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132692. */
  132693. updraftForceMultiplier: number;
  132694. }
  132695. /**
  132696. * The strenght 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 PhysicsRadialImpulseFalloff {
  132700. /** Defines that impulse is constant in strength across it's whole radius */
  132701. Constant = 0,
  132702. /** Defines that impulse gets weaker if it's further from the origin */
  132703. Linear = 1
  132704. }
  132705. /**
  132706. * The strength of the force in correspondence to the distance of the affected object
  132707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132708. */
  132709. export enum PhysicsUpdraftMode {
  132710. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132711. Center = 0,
  132712. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132713. Perpendicular = 1
  132714. }
  132715. /**
  132716. * Interface for a physics hit data
  132717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132718. */
  132719. export interface PhysicsHitData {
  132720. /**
  132721. * The force applied at the contact point
  132722. */
  132723. force: Vector3;
  132724. /**
  132725. * The contact point
  132726. */
  132727. contactPoint: Vector3;
  132728. /**
  132729. * The distance from the origin to the contact point
  132730. */
  132731. distanceFromOrigin: number;
  132732. }
  132733. /**
  132734. * Interface for radial explosion event data
  132735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132736. */
  132737. export interface PhysicsRadialExplosionEventData {
  132738. /**
  132739. * A sphere used for the radial explosion event
  132740. */
  132741. sphere: Mesh;
  132742. }
  132743. /**
  132744. * Interface for gravitational field event data
  132745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132746. */
  132747. export interface PhysicsGravitationalFieldEventData {
  132748. /**
  132749. * A sphere mesh used for the gravitational field event
  132750. */
  132751. sphere: Mesh;
  132752. }
  132753. /**
  132754. * Interface for updraft event data
  132755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132756. */
  132757. export interface PhysicsUpdraftEventData {
  132758. /**
  132759. * A cylinder used for the updraft event
  132760. */
  132761. cylinder: Mesh;
  132762. }
  132763. /**
  132764. * Interface for vortex event data
  132765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132766. */
  132767. export interface PhysicsVortexEventData {
  132768. /**
  132769. * A cylinder used for the vortex event
  132770. */
  132771. cylinder: Mesh;
  132772. }
  132773. /**
  132774. * Interface for an affected physics impostor
  132775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132776. */
  132777. export interface PhysicsAffectedImpostorWithData {
  132778. /**
  132779. * The impostor affected by the effect
  132780. */
  132781. impostor: PhysicsImpostor;
  132782. /**
  132783. * The data about the hit/horce from the explosion
  132784. */
  132785. hitData: PhysicsHitData;
  132786. }
  132787. }
  132788. declare module BABYLON {
  132789. /** @hidden */
  132790. export var blackAndWhitePixelShader: {
  132791. name: string;
  132792. shader: string;
  132793. };
  132794. }
  132795. declare module BABYLON {
  132796. /**
  132797. * Post process used to render in black and white
  132798. */
  132799. export class BlackAndWhitePostProcess extends PostProcess {
  132800. /**
  132801. * Linear about to convert he result to black and white (default: 1)
  132802. */
  132803. degree: number;
  132804. /**
  132805. * Creates a black and white post process
  132806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132807. * @param name The name of the effect.
  132808. * @param options The required width/height ratio to downsize to before computing the render pass.
  132809. * @param camera The camera to apply the render pass to.
  132810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132811. * @param engine The engine which the post process will be applied. (default: current engine)
  132812. * @param reusable If the post process can be reused on the same frame. (default: false)
  132813. */
  132814. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132815. }
  132816. }
  132817. declare module BABYLON {
  132818. /**
  132819. * This represents a set of one or more post processes in Babylon.
  132820. * A post process can be used to apply a shader to a texture after it is rendered.
  132821. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132822. */
  132823. export class PostProcessRenderEffect {
  132824. private _postProcesses;
  132825. private _getPostProcesses;
  132826. private _singleInstance;
  132827. private _cameras;
  132828. private _indicesForCamera;
  132829. /**
  132830. * Name of the effect
  132831. * @hidden
  132832. */
  132833. _name: string;
  132834. /**
  132835. * Instantiates a post process render effect.
  132836. * A post process can be used to apply a shader to a texture after it is rendered.
  132837. * @param engine The engine the effect is tied to
  132838. * @param name The name of the effect
  132839. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132840. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132841. */
  132842. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132843. /**
  132844. * Checks if all the post processes in the effect are supported.
  132845. */
  132846. get isSupported(): boolean;
  132847. /**
  132848. * Updates the current state of the effect
  132849. * @hidden
  132850. */
  132851. _update(): void;
  132852. /**
  132853. * Attaches the effect on cameras
  132854. * @param cameras The camera to attach to.
  132855. * @hidden
  132856. */
  132857. _attachCameras(cameras: Camera): void;
  132858. /**
  132859. * Attaches the effect on cameras
  132860. * @param cameras The camera to attach to.
  132861. * @hidden
  132862. */
  132863. _attachCameras(cameras: Camera[]): void;
  132864. /**
  132865. * Detaches the effect on cameras
  132866. * @param cameras The camera to detatch from.
  132867. * @hidden
  132868. */
  132869. _detachCameras(cameras: Camera): void;
  132870. /**
  132871. * Detatches the effect on cameras
  132872. * @param cameras The camera to detatch from.
  132873. * @hidden
  132874. */
  132875. _detachCameras(cameras: Camera[]): void;
  132876. /**
  132877. * Enables the effect on given cameras
  132878. * @param cameras The camera to enable.
  132879. * @hidden
  132880. */
  132881. _enable(cameras: Camera): void;
  132882. /**
  132883. * Enables the effect on given cameras
  132884. * @param cameras The camera to enable.
  132885. * @hidden
  132886. */
  132887. _enable(cameras: Nullable<Camera[]>): void;
  132888. /**
  132889. * Disables the effect on the given cameras
  132890. * @param cameras The camera to disable.
  132891. * @hidden
  132892. */
  132893. _disable(cameras: Camera): void;
  132894. /**
  132895. * Disables the effect on the given cameras
  132896. * @param cameras The camera to disable.
  132897. * @hidden
  132898. */
  132899. _disable(cameras: Nullable<Camera[]>): void;
  132900. /**
  132901. * Gets a list of the post processes contained in the effect.
  132902. * @param camera The camera to get the post processes on.
  132903. * @returns The list of the post processes in the effect.
  132904. */
  132905. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132906. }
  132907. }
  132908. declare module BABYLON {
  132909. /** @hidden */
  132910. export var extractHighlightsPixelShader: {
  132911. name: string;
  132912. shader: string;
  132913. };
  132914. }
  132915. declare module BABYLON {
  132916. /**
  132917. * 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.
  132918. */
  132919. export class ExtractHighlightsPostProcess extends PostProcess {
  132920. /**
  132921. * The luminance threshold, pixels below this value will be set to black.
  132922. */
  132923. threshold: number;
  132924. /** @hidden */
  132925. _exposure: number;
  132926. /**
  132927. * Post process which has the input texture to be used when performing highlight extraction
  132928. * @hidden
  132929. */
  132930. _inputPostProcess: Nullable<PostProcess>;
  132931. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132932. }
  132933. }
  132934. declare module BABYLON {
  132935. /** @hidden */
  132936. export var bloomMergePixelShader: {
  132937. name: string;
  132938. shader: string;
  132939. };
  132940. }
  132941. declare module BABYLON {
  132942. /**
  132943. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132944. */
  132945. export class BloomMergePostProcess extends PostProcess {
  132946. /** Weight of the bloom to be added to the original input. */
  132947. weight: number;
  132948. /**
  132949. * Creates a new instance of @see BloomMergePostProcess
  132950. * @param name The name of the effect.
  132951. * @param originalFromInput Post process which's input will be used for the merge.
  132952. * @param blurred Blurred highlights post process which's output will be used.
  132953. * @param weight Weight of the bloom to be added to the original input.
  132954. * @param options The required width/height ratio to downsize to before computing the render pass.
  132955. * @param camera The camera to apply the render pass to.
  132956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132957. * @param engine The engine which the post process will be applied. (default: current engine)
  132958. * @param reusable If the post process can be reused on the same frame. (default: false)
  132959. * @param textureType Type of textures used when performing the post process. (default: 0)
  132960. * @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)
  132961. */
  132962. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132963. /** Weight of the bloom to be added to the original input. */
  132964. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132965. }
  132966. }
  132967. declare module BABYLON {
  132968. /**
  132969. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132970. */
  132971. export class BloomEffect extends PostProcessRenderEffect {
  132972. private bloomScale;
  132973. /**
  132974. * @hidden Internal
  132975. */
  132976. _effects: Array<PostProcess>;
  132977. /**
  132978. * @hidden Internal
  132979. */
  132980. _downscale: ExtractHighlightsPostProcess;
  132981. private _blurX;
  132982. private _blurY;
  132983. private _merge;
  132984. /**
  132985. * The luminance threshold to find bright areas of the image to bloom.
  132986. */
  132987. get threshold(): number;
  132988. set threshold(value: number);
  132989. /**
  132990. * The strength of the bloom.
  132991. */
  132992. get weight(): number;
  132993. set weight(value: number);
  132994. /**
  132995. * Specifies the size of the bloom blur kernel, relative to the final output size
  132996. */
  132997. get kernel(): number;
  132998. set kernel(value: number);
  132999. /**
  133000. * Creates a new instance of @see BloomEffect
  133001. * @param scene The scene the effect belongs to.
  133002. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  133003. * @param bloomKernel The size of the kernel to be used when applying the blur.
  133004. * @param bloomWeight The the strength of bloom.
  133005. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133006. * @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)
  133007. */
  133008. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  133009. /**
  133010. * Disposes each of the internal effects for a given camera.
  133011. * @param camera The camera to dispose the effect on.
  133012. */
  133013. disposeEffects(camera: Camera): void;
  133014. /**
  133015. * @hidden Internal
  133016. */
  133017. _updateEffects(): void;
  133018. /**
  133019. * Internal
  133020. * @returns if all the contained post processes are ready.
  133021. * @hidden
  133022. */
  133023. _isReady(): boolean;
  133024. }
  133025. }
  133026. declare module BABYLON {
  133027. /** @hidden */
  133028. export var chromaticAberrationPixelShader: {
  133029. name: string;
  133030. shader: string;
  133031. };
  133032. }
  133033. declare module BABYLON {
  133034. /**
  133035. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  133036. */
  133037. export class ChromaticAberrationPostProcess extends PostProcess {
  133038. /**
  133039. * The amount of seperation of rgb channels (default: 30)
  133040. */
  133041. aberrationAmount: number;
  133042. /**
  133043. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  133044. */
  133045. radialIntensity: number;
  133046. /**
  133047. * 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))
  133048. */
  133049. direction: Vector2;
  133050. /**
  133051. * 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))
  133052. */
  133053. centerPosition: Vector2;
  133054. /**
  133055. * Creates a new instance ChromaticAberrationPostProcess
  133056. * @param name The name of the effect.
  133057. * @param screenWidth The width of the screen to apply the effect on.
  133058. * @param screenHeight The height of the screen to apply the effect on.
  133059. * @param options The required width/height ratio to downsize to before computing the render pass.
  133060. * @param camera The camera to apply the render pass to.
  133061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133062. * @param engine The engine which the post process will be applied. (default: current engine)
  133063. * @param reusable If the post process can be reused on the same frame. (default: false)
  133064. * @param textureType Type of textures used when performing the post process. (default: 0)
  133065. * @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)
  133066. */
  133067. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133068. }
  133069. }
  133070. declare module BABYLON {
  133071. /** @hidden */
  133072. export var circleOfConfusionPixelShader: {
  133073. name: string;
  133074. shader: string;
  133075. };
  133076. }
  133077. declare module BABYLON {
  133078. /**
  133079. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  133080. */
  133081. export class CircleOfConfusionPostProcess extends PostProcess {
  133082. /**
  133083. * 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.
  133084. */
  133085. lensSize: number;
  133086. /**
  133087. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133088. */
  133089. fStop: number;
  133090. /**
  133091. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133092. */
  133093. focusDistance: number;
  133094. /**
  133095. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  133096. */
  133097. focalLength: number;
  133098. private _depthTexture;
  133099. /**
  133100. * Creates a new instance CircleOfConfusionPostProcess
  133101. * @param name The name of the effect.
  133102. * @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.
  133103. * @param options The required width/height ratio to downsize to before computing the render pass.
  133104. * @param camera The camera to apply the render pass to.
  133105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133106. * @param engine The engine which the post process will be applied. (default: current engine)
  133107. * @param reusable If the post process can be reused on the same frame. (default: false)
  133108. * @param textureType Type of textures used when performing the post process. (default: 0)
  133109. * @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)
  133110. */
  133111. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133112. /**
  133113. * 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.
  133114. */
  133115. set depthTexture(value: RenderTargetTexture);
  133116. }
  133117. }
  133118. declare module BABYLON {
  133119. /** @hidden */
  133120. export var colorCorrectionPixelShader: {
  133121. name: string;
  133122. shader: string;
  133123. };
  133124. }
  133125. declare module BABYLON {
  133126. /**
  133127. *
  133128. * This post-process allows the modification of rendered colors by using
  133129. * a 'look-up table' (LUT). This effect is also called Color Grading.
  133130. *
  133131. * The object needs to be provided an url to a texture containing the color
  133132. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  133133. * Use an image editing software to tweak the LUT to match your needs.
  133134. *
  133135. * For an example of a color LUT, see here:
  133136. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  133137. * For explanations on color grading, see here:
  133138. * @see http://udn.epicgames.com/Three/ColorGrading.html
  133139. *
  133140. */
  133141. export class ColorCorrectionPostProcess extends PostProcess {
  133142. private _colorTableTexture;
  133143. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133144. }
  133145. }
  133146. declare module BABYLON {
  133147. /** @hidden */
  133148. export var convolutionPixelShader: {
  133149. name: string;
  133150. shader: string;
  133151. };
  133152. }
  133153. declare module BABYLON {
  133154. /**
  133155. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  133156. * input texture to perform effects such as edge detection or sharpening
  133157. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133158. */
  133159. export class ConvolutionPostProcess extends PostProcess {
  133160. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133161. kernel: number[];
  133162. /**
  133163. * Creates a new instance ConvolutionPostProcess
  133164. * @param name The name of the effect.
  133165. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  133166. * @param options The required width/height ratio to downsize to before computing the render pass.
  133167. * @param camera The camera to apply the render pass to.
  133168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133169. * @param engine The engine which the post process will be applied. (default: current engine)
  133170. * @param reusable If the post process can be reused on the same frame. (default: false)
  133171. * @param textureType Type of textures used when performing the post process. (default: 0)
  133172. */
  133173. constructor(name: string,
  133174. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133175. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133176. /**
  133177. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133178. */
  133179. static EdgeDetect0Kernel: number[];
  133180. /**
  133181. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133182. */
  133183. static EdgeDetect1Kernel: number[];
  133184. /**
  133185. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133186. */
  133187. static EdgeDetect2Kernel: number[];
  133188. /**
  133189. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133190. */
  133191. static SharpenKernel: number[];
  133192. /**
  133193. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133194. */
  133195. static EmbossKernel: number[];
  133196. /**
  133197. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133198. */
  133199. static GaussianKernel: number[];
  133200. }
  133201. }
  133202. declare module BABYLON {
  133203. /**
  133204. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  133205. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  133206. * based on samples that have a large difference in distance than the center pixel.
  133207. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  133208. */
  133209. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  133210. direction: Vector2;
  133211. /**
  133212. * Creates a new instance CircleOfConfusionPostProcess
  133213. * @param name The name of the effect.
  133214. * @param scene The scene the effect belongs to.
  133215. * @param direction The direction the blur should be applied.
  133216. * @param kernel The size of the kernel used to blur.
  133217. * @param options The required width/height ratio to downsize to before computing the render pass.
  133218. * @param camera The camera to apply the render pass to.
  133219. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  133220. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  133221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133222. * @param engine The engine which the post process will be applied. (default: current engine)
  133223. * @param reusable If the post process can be reused on the same frame. (default: false)
  133224. * @param textureType Type of textures used when performing the post process. (default: 0)
  133225. * @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)
  133226. */
  133227. 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);
  133228. }
  133229. }
  133230. declare module BABYLON {
  133231. /** @hidden */
  133232. export var depthOfFieldMergePixelShader: {
  133233. name: string;
  133234. shader: string;
  133235. };
  133236. }
  133237. declare module BABYLON {
  133238. /**
  133239. * Options to be set when merging outputs from the default pipeline.
  133240. */
  133241. export class DepthOfFieldMergePostProcessOptions {
  133242. /**
  133243. * The original image to merge on top of
  133244. */
  133245. originalFromInput: PostProcess;
  133246. /**
  133247. * Parameters to perform the merge of the depth of field effect
  133248. */
  133249. depthOfField?: {
  133250. circleOfConfusion: PostProcess;
  133251. blurSteps: Array<PostProcess>;
  133252. };
  133253. /**
  133254. * Parameters to perform the merge of bloom effect
  133255. */
  133256. bloom?: {
  133257. blurred: PostProcess;
  133258. weight: number;
  133259. };
  133260. }
  133261. /**
  133262. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133263. */
  133264. export class DepthOfFieldMergePostProcess extends PostProcess {
  133265. private blurSteps;
  133266. /**
  133267. * Creates a new instance of DepthOfFieldMergePostProcess
  133268. * @param name The name of the effect.
  133269. * @param originalFromInput Post process which's input will be used for the merge.
  133270. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133271. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133272. * @param options The required width/height ratio to downsize to before computing the render pass.
  133273. * @param camera The camera to apply the render pass to.
  133274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133275. * @param engine The engine which the post process will be applied. (default: current engine)
  133276. * @param reusable If the post process can be reused on the same frame. (default: false)
  133277. * @param textureType Type of textures used when performing the post process. (default: 0)
  133278. * @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)
  133279. */
  133280. 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);
  133281. /**
  133282. * Updates the effect with the current post process compile time values and recompiles the shader.
  133283. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133284. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133285. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133286. * @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
  133287. * @param onCompiled Called when the shader has been compiled.
  133288. * @param onError Called if there is an error when compiling a shader.
  133289. */
  133290. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133291. }
  133292. }
  133293. declare module BABYLON {
  133294. /**
  133295. * Specifies the level of max blur that should be applied when using the depth of field effect
  133296. */
  133297. export enum DepthOfFieldEffectBlurLevel {
  133298. /**
  133299. * Subtle blur
  133300. */
  133301. Low = 0,
  133302. /**
  133303. * Medium blur
  133304. */
  133305. Medium = 1,
  133306. /**
  133307. * Large blur
  133308. */
  133309. High = 2
  133310. }
  133311. /**
  133312. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133313. */
  133314. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133315. private _circleOfConfusion;
  133316. /**
  133317. * @hidden Internal, blurs from high to low
  133318. */
  133319. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133320. private _depthOfFieldBlurY;
  133321. private _dofMerge;
  133322. /**
  133323. * @hidden Internal post processes in depth of field effect
  133324. */
  133325. _effects: Array<PostProcess>;
  133326. /**
  133327. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133328. */
  133329. set focalLength(value: number);
  133330. get focalLength(): number;
  133331. /**
  133332. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133333. */
  133334. set fStop(value: number);
  133335. get fStop(): number;
  133336. /**
  133337. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133338. */
  133339. set focusDistance(value: number);
  133340. get focusDistance(): number;
  133341. /**
  133342. * 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.
  133343. */
  133344. set lensSize(value: number);
  133345. get lensSize(): number;
  133346. /**
  133347. * Creates a new instance DepthOfFieldEffect
  133348. * @param scene The scene the effect belongs to.
  133349. * @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.
  133350. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133351. * @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)
  133352. */
  133353. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133354. /**
  133355. * Get the current class name of the current effet
  133356. * @returns "DepthOfFieldEffect"
  133357. */
  133358. getClassName(): string;
  133359. /**
  133360. * 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.
  133361. */
  133362. set depthTexture(value: RenderTargetTexture);
  133363. /**
  133364. * Disposes each of the internal effects for a given camera.
  133365. * @param camera The camera to dispose the effect on.
  133366. */
  133367. disposeEffects(camera: Camera): void;
  133368. /**
  133369. * @hidden Internal
  133370. */
  133371. _updateEffects(): void;
  133372. /**
  133373. * Internal
  133374. * @returns if all the contained post processes are ready.
  133375. * @hidden
  133376. */
  133377. _isReady(): boolean;
  133378. }
  133379. }
  133380. declare module BABYLON {
  133381. /** @hidden */
  133382. export var displayPassPixelShader: {
  133383. name: string;
  133384. shader: string;
  133385. };
  133386. }
  133387. declare module BABYLON {
  133388. /**
  133389. * DisplayPassPostProcess which produces an output the same as it's input
  133390. */
  133391. export class DisplayPassPostProcess extends PostProcess {
  133392. /**
  133393. * Creates the DisplayPassPostProcess
  133394. * @param name The name of the effect.
  133395. * @param options The required width/height ratio to downsize to before computing the render pass.
  133396. * @param camera The camera to apply the render pass to.
  133397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133398. * @param engine The engine which the post process will be applied. (default: current engine)
  133399. * @param reusable If the post process can be reused on the same frame. (default: false)
  133400. */
  133401. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133402. }
  133403. }
  133404. declare module BABYLON {
  133405. /** @hidden */
  133406. export var filterPixelShader: {
  133407. name: string;
  133408. shader: string;
  133409. };
  133410. }
  133411. declare module BABYLON {
  133412. /**
  133413. * Applies a kernel filter to the image
  133414. */
  133415. export class FilterPostProcess extends PostProcess {
  133416. /** The matrix to be applied to the image */
  133417. kernelMatrix: Matrix;
  133418. /**
  133419. *
  133420. * @param name The name of the effect.
  133421. * @param kernelMatrix The matrix to be applied to the image
  133422. * @param options The required width/height ratio to downsize to before computing the render pass.
  133423. * @param camera The camera to apply the render pass to.
  133424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133425. * @param engine The engine which the post process will be applied. (default: current engine)
  133426. * @param reusable If the post process can be reused on the same frame. (default: false)
  133427. */
  133428. constructor(name: string,
  133429. /** The matrix to be applied to the image */
  133430. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133431. }
  133432. }
  133433. declare module BABYLON {
  133434. /** @hidden */
  133435. export var fxaaPixelShader: {
  133436. name: string;
  133437. shader: string;
  133438. };
  133439. }
  133440. declare module BABYLON {
  133441. /** @hidden */
  133442. export var fxaaVertexShader: {
  133443. name: string;
  133444. shader: string;
  133445. };
  133446. }
  133447. declare module BABYLON {
  133448. /**
  133449. * Fxaa post process
  133450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133451. */
  133452. export class FxaaPostProcess extends PostProcess {
  133453. /** @hidden */
  133454. texelWidth: number;
  133455. /** @hidden */
  133456. texelHeight: number;
  133457. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133458. private _getDefines;
  133459. }
  133460. }
  133461. declare module BABYLON {
  133462. /** @hidden */
  133463. export var grainPixelShader: {
  133464. name: string;
  133465. shader: string;
  133466. };
  133467. }
  133468. declare module BABYLON {
  133469. /**
  133470. * The GrainPostProcess adds noise to the image at mid luminance levels
  133471. */
  133472. export class GrainPostProcess extends PostProcess {
  133473. /**
  133474. * The intensity of the grain added (default: 30)
  133475. */
  133476. intensity: number;
  133477. /**
  133478. * If the grain should be randomized on every frame
  133479. */
  133480. animated: boolean;
  133481. /**
  133482. * Creates a new instance of @see GrainPostProcess
  133483. * @param name The name of the effect.
  133484. * @param options The required width/height ratio to downsize to before computing the render pass.
  133485. * @param camera The camera to apply the render pass to.
  133486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133487. * @param engine The engine which the post process will be applied. (default: current engine)
  133488. * @param reusable If the post process can be reused on the same frame. (default: false)
  133489. * @param textureType Type of textures used when performing the post process. (default: 0)
  133490. * @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)
  133491. */
  133492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133493. }
  133494. }
  133495. declare module BABYLON {
  133496. /** @hidden */
  133497. export var highlightsPixelShader: {
  133498. name: string;
  133499. shader: string;
  133500. };
  133501. }
  133502. declare module BABYLON {
  133503. /**
  133504. * Extracts highlights from the image
  133505. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133506. */
  133507. export class HighlightsPostProcess extends PostProcess {
  133508. /**
  133509. * Extracts highlights from the image
  133510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133511. * @param name The name of the effect.
  133512. * @param options The required width/height ratio to downsize to before computing the render pass.
  133513. * @param camera The camera to apply the render pass to.
  133514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133515. * @param engine The engine which the post process will be applied. (default: current engine)
  133516. * @param reusable If the post process can be reused on the same frame. (default: false)
  133517. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133518. */
  133519. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133520. }
  133521. }
  133522. declare module BABYLON {
  133523. /** @hidden */
  133524. export var mrtFragmentDeclaration: {
  133525. name: string;
  133526. shader: string;
  133527. };
  133528. }
  133529. declare module BABYLON {
  133530. /** @hidden */
  133531. export var geometryPixelShader: {
  133532. name: string;
  133533. shader: string;
  133534. };
  133535. }
  133536. declare module BABYLON {
  133537. /** @hidden */
  133538. export var geometryVertexShader: {
  133539. name: string;
  133540. shader: string;
  133541. };
  133542. }
  133543. declare module BABYLON {
  133544. /** @hidden */
  133545. interface ISavedTransformationMatrix {
  133546. world: Matrix;
  133547. viewProjection: Matrix;
  133548. }
  133549. /**
  133550. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133551. */
  133552. export class GeometryBufferRenderer {
  133553. /**
  133554. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133555. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133556. */
  133557. static readonly POSITION_TEXTURE_TYPE: number;
  133558. /**
  133559. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133560. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133561. */
  133562. static readonly VELOCITY_TEXTURE_TYPE: number;
  133563. /**
  133564. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133565. * in order to compute objects velocities when enableVelocity is set to "true"
  133566. * @hidden
  133567. */
  133568. _previousTransformationMatrices: {
  133569. [index: number]: ISavedTransformationMatrix;
  133570. };
  133571. /**
  133572. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133573. * in order to compute objects velocities when enableVelocity is set to "true"
  133574. * @hidden
  133575. */
  133576. _previousBonesTransformationMatrices: {
  133577. [index: number]: Float32Array;
  133578. };
  133579. /**
  133580. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133581. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133582. */
  133583. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133584. private _scene;
  133585. private _multiRenderTarget;
  133586. private _ratio;
  133587. private _enablePosition;
  133588. private _enableVelocity;
  133589. private _positionIndex;
  133590. private _velocityIndex;
  133591. protected _effect: Effect;
  133592. protected _cachedDefines: string;
  133593. /**
  133594. * Set the render list (meshes to be rendered) used in the G buffer.
  133595. */
  133596. set renderList(meshes: Mesh[]);
  133597. /**
  133598. * Gets wether or not G buffer are supported by the running hardware.
  133599. * This requires draw buffer supports
  133600. */
  133601. get isSupported(): boolean;
  133602. /**
  133603. * Returns the index of the given texture type in the G-Buffer textures array
  133604. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133605. * @returns the index of the given texture type in the G-Buffer textures array
  133606. */
  133607. getTextureIndex(textureType: number): number;
  133608. /**
  133609. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133610. */
  133611. get enablePosition(): boolean;
  133612. /**
  133613. * Sets whether or not objects positions are enabled for the G buffer.
  133614. */
  133615. set enablePosition(enable: boolean);
  133616. /**
  133617. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133618. */
  133619. get enableVelocity(): boolean;
  133620. /**
  133621. * Sets wether or not objects velocities are enabled for the G buffer.
  133622. */
  133623. set enableVelocity(enable: boolean);
  133624. /**
  133625. * Gets the scene associated with the buffer.
  133626. */
  133627. get scene(): Scene;
  133628. /**
  133629. * Gets the ratio used by the buffer during its creation.
  133630. * How big is the buffer related to the main canvas.
  133631. */
  133632. get ratio(): number;
  133633. /** @hidden */
  133634. static _SceneComponentInitialization: (scene: Scene) => void;
  133635. /**
  133636. * Creates a new G Buffer for the scene
  133637. * @param scene The scene the buffer belongs to
  133638. * @param ratio How big is the buffer related to the main canvas.
  133639. */
  133640. constructor(scene: Scene, ratio?: number);
  133641. /**
  133642. * Checks wether everything is ready to render a submesh to the G buffer.
  133643. * @param subMesh the submesh to check readiness for
  133644. * @param useInstances is the mesh drawn using instance or not
  133645. * @returns true if ready otherwise false
  133646. */
  133647. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133648. /**
  133649. * Gets the current underlying G Buffer.
  133650. * @returns the buffer
  133651. */
  133652. getGBuffer(): MultiRenderTarget;
  133653. /**
  133654. * Gets the number of samples used to render the buffer (anti aliasing).
  133655. */
  133656. get samples(): number;
  133657. /**
  133658. * Sets the number of samples used to render the buffer (anti aliasing).
  133659. */
  133660. set samples(value: number);
  133661. /**
  133662. * Disposes the renderer and frees up associated resources.
  133663. */
  133664. dispose(): void;
  133665. protected _createRenderTargets(): void;
  133666. private _copyBonesTransformationMatrices;
  133667. }
  133668. }
  133669. declare module BABYLON {
  133670. interface Scene {
  133671. /** @hidden (Backing field) */
  133672. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133673. /**
  133674. * Gets or Sets the current geometry buffer associated to the scene.
  133675. */
  133676. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133677. /**
  133678. * Enables a GeometryBufferRender and associates it with the scene
  133679. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133680. * @returns the GeometryBufferRenderer
  133681. */
  133682. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133683. /**
  133684. * Disables the GeometryBufferRender associated with the scene
  133685. */
  133686. disableGeometryBufferRenderer(): void;
  133687. }
  133688. /**
  133689. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133690. * in several rendering techniques.
  133691. */
  133692. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133693. /**
  133694. * The component name helpful to identify the component in the list of scene components.
  133695. */
  133696. readonly name: string;
  133697. /**
  133698. * The scene the component belongs to.
  133699. */
  133700. scene: Scene;
  133701. /**
  133702. * Creates a new instance of the component for the given scene
  133703. * @param scene Defines the scene to register the component in
  133704. */
  133705. constructor(scene: Scene);
  133706. /**
  133707. * Registers the component in a given scene
  133708. */
  133709. register(): void;
  133710. /**
  133711. * Rebuilds the elements related to this component in case of
  133712. * context lost for instance.
  133713. */
  133714. rebuild(): void;
  133715. /**
  133716. * Disposes the component and the associated ressources
  133717. */
  133718. dispose(): void;
  133719. private _gatherRenderTargets;
  133720. }
  133721. }
  133722. declare module BABYLON {
  133723. /** @hidden */
  133724. export var motionBlurPixelShader: {
  133725. name: string;
  133726. shader: string;
  133727. };
  133728. }
  133729. declare module BABYLON {
  133730. /**
  133731. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133732. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133733. * As an example, all you have to do is to create the post-process:
  133734. * var mb = new BABYLON.MotionBlurPostProcess(
  133735. * 'mb', // The name of the effect.
  133736. * scene, // The scene containing the objects to blur according to their velocity.
  133737. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133738. * camera // The camera to apply the render pass to.
  133739. * );
  133740. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133741. */
  133742. export class MotionBlurPostProcess extends PostProcess {
  133743. /**
  133744. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133745. */
  133746. motionStrength: number;
  133747. /**
  133748. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133749. */
  133750. get motionBlurSamples(): number;
  133751. /**
  133752. * Sets the number of iterations to be used for motion blur quality
  133753. */
  133754. set motionBlurSamples(samples: number);
  133755. private _motionBlurSamples;
  133756. private _geometryBufferRenderer;
  133757. /**
  133758. * Creates a new instance MotionBlurPostProcess
  133759. * @param name The name of the effect.
  133760. * @param scene The scene containing the objects to blur according to their velocity.
  133761. * @param options The required width/height ratio to downsize to before computing the render pass.
  133762. * @param camera The camera to apply the render pass to.
  133763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133764. * @param engine The engine which the post process will be applied. (default: current engine)
  133765. * @param reusable If the post process can be reused on the same frame. (default: false)
  133766. * @param textureType Type of textures used when performing the post process. (default: 0)
  133767. * @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)
  133768. */
  133769. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133770. /**
  133771. * Excludes the given skinned mesh from computing bones velocities.
  133772. * 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.
  133773. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133774. */
  133775. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133776. /**
  133777. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133778. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133779. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133780. */
  133781. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133782. /**
  133783. * Disposes the post process.
  133784. * @param camera The camera to dispose the post process on.
  133785. */
  133786. dispose(camera?: Camera): void;
  133787. }
  133788. }
  133789. declare module BABYLON {
  133790. /** @hidden */
  133791. export var refractionPixelShader: {
  133792. name: string;
  133793. shader: string;
  133794. };
  133795. }
  133796. declare module BABYLON {
  133797. /**
  133798. * Post process which applies a refractin texture
  133799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133800. */
  133801. export class RefractionPostProcess extends PostProcess {
  133802. /** the base color of the refraction (used to taint the rendering) */
  133803. color: Color3;
  133804. /** simulated refraction depth */
  133805. depth: number;
  133806. /** the coefficient of the base color (0 to remove base color tainting) */
  133807. colorLevel: number;
  133808. private _refTexture;
  133809. private _ownRefractionTexture;
  133810. /**
  133811. * Gets or sets the refraction texture
  133812. * Please note that you are responsible for disposing the texture if you set it manually
  133813. */
  133814. get refractionTexture(): Texture;
  133815. set refractionTexture(value: Texture);
  133816. /**
  133817. * Initializes the RefractionPostProcess
  133818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133819. * @param name The name of the effect.
  133820. * @param refractionTextureUrl Url of the refraction texture to use
  133821. * @param color the base color of the refraction (used to taint the rendering)
  133822. * @param depth simulated refraction depth
  133823. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133824. * @param camera The camera to apply the render pass to.
  133825. * @param options The required width/height ratio to downsize to before computing the render pass.
  133826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133827. * @param engine The engine which the post process will be applied. (default: current engine)
  133828. * @param reusable If the post process can be reused on the same frame. (default: false)
  133829. */
  133830. constructor(name: string, refractionTextureUrl: string,
  133831. /** the base color of the refraction (used to taint the rendering) */
  133832. color: Color3,
  133833. /** simulated refraction depth */
  133834. depth: number,
  133835. /** the coefficient of the base color (0 to remove base color tainting) */
  133836. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133837. /**
  133838. * Disposes of the post process
  133839. * @param camera Camera to dispose post process on
  133840. */
  133841. dispose(camera: Camera): void;
  133842. }
  133843. }
  133844. declare module BABYLON {
  133845. /** @hidden */
  133846. export var sharpenPixelShader: {
  133847. name: string;
  133848. shader: string;
  133849. };
  133850. }
  133851. declare module BABYLON {
  133852. /**
  133853. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133854. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133855. */
  133856. export class SharpenPostProcess extends PostProcess {
  133857. /**
  133858. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133859. */
  133860. colorAmount: number;
  133861. /**
  133862. * How much sharpness should be applied (default: 0.3)
  133863. */
  133864. edgeAmount: number;
  133865. /**
  133866. * Creates a new instance ConvolutionPostProcess
  133867. * @param name The name of the effect.
  133868. * @param options The required width/height ratio to downsize to before computing the render pass.
  133869. * @param camera The camera to apply the render pass to.
  133870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133871. * @param engine The engine which the post process will be applied. (default: current engine)
  133872. * @param reusable If the post process can be reused on the same frame. (default: false)
  133873. * @param textureType Type of textures used when performing the post process. (default: 0)
  133874. * @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)
  133875. */
  133876. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133877. }
  133878. }
  133879. declare module BABYLON {
  133880. /**
  133881. * PostProcessRenderPipeline
  133882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133883. */
  133884. export class PostProcessRenderPipeline {
  133885. private engine;
  133886. private _renderEffects;
  133887. private _renderEffectsForIsolatedPass;
  133888. /**
  133889. * List of inspectable custom properties (used by the Inspector)
  133890. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133891. */
  133892. inspectableCustomProperties: IInspectable[];
  133893. /**
  133894. * @hidden
  133895. */
  133896. protected _cameras: Camera[];
  133897. /** @hidden */
  133898. _name: string;
  133899. /**
  133900. * Gets pipeline name
  133901. */
  133902. get name(): string;
  133903. /** Gets the list of attached cameras */
  133904. get cameras(): Camera[];
  133905. /**
  133906. * Initializes a PostProcessRenderPipeline
  133907. * @param engine engine to add the pipeline to
  133908. * @param name name of the pipeline
  133909. */
  133910. constructor(engine: Engine, name: string);
  133911. /**
  133912. * Gets the class name
  133913. * @returns "PostProcessRenderPipeline"
  133914. */
  133915. getClassName(): string;
  133916. /**
  133917. * If all the render effects in the pipeline are supported
  133918. */
  133919. get isSupported(): boolean;
  133920. /**
  133921. * Adds an effect to the pipeline
  133922. * @param renderEffect the effect to add
  133923. */
  133924. addEffect(renderEffect: PostProcessRenderEffect): void;
  133925. /** @hidden */
  133926. _rebuild(): void;
  133927. /** @hidden */
  133928. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133929. /** @hidden */
  133930. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133931. /** @hidden */
  133932. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133933. /** @hidden */
  133934. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133935. /** @hidden */
  133936. _attachCameras(cameras: Camera, unique: boolean): void;
  133937. /** @hidden */
  133938. _attachCameras(cameras: Camera[], unique: boolean): void;
  133939. /** @hidden */
  133940. _detachCameras(cameras: Camera): void;
  133941. /** @hidden */
  133942. _detachCameras(cameras: Nullable<Camera[]>): void;
  133943. /** @hidden */
  133944. _update(): void;
  133945. /** @hidden */
  133946. _reset(): void;
  133947. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133948. /**
  133949. * Disposes of the pipeline
  133950. */
  133951. dispose(): void;
  133952. }
  133953. }
  133954. declare module BABYLON {
  133955. /**
  133956. * PostProcessRenderPipelineManager class
  133957. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133958. */
  133959. export class PostProcessRenderPipelineManager {
  133960. private _renderPipelines;
  133961. /**
  133962. * Initializes a PostProcessRenderPipelineManager
  133963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133964. */
  133965. constructor();
  133966. /**
  133967. * Gets the list of supported render pipelines
  133968. */
  133969. get supportedPipelines(): PostProcessRenderPipeline[];
  133970. /**
  133971. * Adds a pipeline to the manager
  133972. * @param renderPipeline The pipeline to add
  133973. */
  133974. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133975. /**
  133976. * Attaches a camera to the pipeline
  133977. * @param renderPipelineName The name of the pipeline to attach to
  133978. * @param cameras the camera to attach
  133979. * @param unique if the camera can be attached multiple times to the pipeline
  133980. */
  133981. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133982. /**
  133983. * Detaches a camera from the pipeline
  133984. * @param renderPipelineName The name of the pipeline to detach from
  133985. * @param cameras the camera to detach
  133986. */
  133987. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133988. /**
  133989. * Enables an effect by name on a pipeline
  133990. * @param renderPipelineName the name of the pipeline to enable the effect in
  133991. * @param renderEffectName the name of the effect to enable
  133992. * @param cameras the cameras that the effect should be enabled on
  133993. */
  133994. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133995. /**
  133996. * Disables an effect by name on a pipeline
  133997. * @param renderPipelineName the name of the pipeline to disable the effect in
  133998. * @param renderEffectName the name of the effect to disable
  133999. * @param cameras the cameras that the effect should be disabled on
  134000. */
  134001. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  134002. /**
  134003. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  134004. */
  134005. update(): void;
  134006. /** @hidden */
  134007. _rebuild(): void;
  134008. /**
  134009. * Disposes of the manager and pipelines
  134010. */
  134011. dispose(): void;
  134012. }
  134013. }
  134014. declare module BABYLON {
  134015. interface Scene {
  134016. /** @hidden (Backing field) */
  134017. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  134018. /**
  134019. * Gets the postprocess render pipeline manager
  134020. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134021. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  134022. */
  134023. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  134024. }
  134025. /**
  134026. * Defines the Render Pipeline scene component responsible to rendering pipelines
  134027. */
  134028. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  134029. /**
  134030. * The component name helpfull to identify the component in the list of scene components.
  134031. */
  134032. readonly name: string;
  134033. /**
  134034. * The scene the component belongs to.
  134035. */
  134036. scene: Scene;
  134037. /**
  134038. * Creates a new instance of the component for the given scene
  134039. * @param scene Defines the scene to register the component in
  134040. */
  134041. constructor(scene: Scene);
  134042. /**
  134043. * Registers the component in a given scene
  134044. */
  134045. register(): void;
  134046. /**
  134047. * Rebuilds the elements related to this component in case of
  134048. * context lost for instance.
  134049. */
  134050. rebuild(): void;
  134051. /**
  134052. * Disposes the component and the associated ressources
  134053. */
  134054. dispose(): void;
  134055. private _gatherRenderTargets;
  134056. }
  134057. }
  134058. declare module BABYLON {
  134059. /**
  134060. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  134061. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  134062. */
  134063. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134064. private _scene;
  134065. private _camerasToBeAttached;
  134066. /**
  134067. * ID of the sharpen post process,
  134068. */
  134069. private readonly SharpenPostProcessId;
  134070. /**
  134071. * @ignore
  134072. * ID of the image processing post process;
  134073. */
  134074. readonly ImageProcessingPostProcessId: string;
  134075. /**
  134076. * @ignore
  134077. * ID of the Fast Approximate Anti-Aliasing post process;
  134078. */
  134079. readonly FxaaPostProcessId: string;
  134080. /**
  134081. * ID of the chromatic aberration post process,
  134082. */
  134083. private readonly ChromaticAberrationPostProcessId;
  134084. /**
  134085. * ID of the grain post process
  134086. */
  134087. private readonly GrainPostProcessId;
  134088. /**
  134089. * Sharpen post process which will apply a sharpen convolution to enhance edges
  134090. */
  134091. sharpen: SharpenPostProcess;
  134092. private _sharpenEffect;
  134093. private bloom;
  134094. /**
  134095. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  134096. */
  134097. depthOfField: DepthOfFieldEffect;
  134098. /**
  134099. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134100. */
  134101. fxaa: FxaaPostProcess;
  134102. /**
  134103. * Image post processing pass used to perform operations such as tone mapping or color grading.
  134104. */
  134105. imageProcessing: ImageProcessingPostProcess;
  134106. /**
  134107. * Chromatic aberration post process which will shift rgb colors in the image
  134108. */
  134109. chromaticAberration: ChromaticAberrationPostProcess;
  134110. private _chromaticAberrationEffect;
  134111. /**
  134112. * Grain post process which add noise to the image
  134113. */
  134114. grain: GrainPostProcess;
  134115. private _grainEffect;
  134116. /**
  134117. * Glow post process which adds a glow to emissive areas of the image
  134118. */
  134119. private _glowLayer;
  134120. /**
  134121. * Animations which can be used to tweak settings over a period of time
  134122. */
  134123. animations: Animation[];
  134124. private _imageProcessingConfigurationObserver;
  134125. private _sharpenEnabled;
  134126. private _bloomEnabled;
  134127. private _depthOfFieldEnabled;
  134128. private _depthOfFieldBlurLevel;
  134129. private _fxaaEnabled;
  134130. private _imageProcessingEnabled;
  134131. private _defaultPipelineTextureType;
  134132. private _bloomScale;
  134133. private _chromaticAberrationEnabled;
  134134. private _grainEnabled;
  134135. private _buildAllowed;
  134136. /**
  134137. * Gets active scene
  134138. */
  134139. get scene(): Scene;
  134140. /**
  134141. * Enable or disable the sharpen process from the pipeline
  134142. */
  134143. set sharpenEnabled(enabled: boolean);
  134144. get sharpenEnabled(): boolean;
  134145. private _resizeObserver;
  134146. private _hardwareScaleLevel;
  134147. private _bloomKernel;
  134148. /**
  134149. * Specifies the size of the bloom blur kernel, relative to the final output size
  134150. */
  134151. get bloomKernel(): number;
  134152. set bloomKernel(value: number);
  134153. /**
  134154. * Specifies the weight of the bloom in the final rendering
  134155. */
  134156. private _bloomWeight;
  134157. /**
  134158. * Specifies the luma threshold for the area that will be blurred by the bloom
  134159. */
  134160. private _bloomThreshold;
  134161. private _hdr;
  134162. /**
  134163. * The strength of the bloom.
  134164. */
  134165. set bloomWeight(value: number);
  134166. get bloomWeight(): number;
  134167. /**
  134168. * The strength of the bloom.
  134169. */
  134170. set bloomThreshold(value: number);
  134171. get bloomThreshold(): number;
  134172. /**
  134173. * The scale of the bloom, lower value will provide better performance.
  134174. */
  134175. set bloomScale(value: number);
  134176. get bloomScale(): number;
  134177. /**
  134178. * Enable or disable the bloom from the pipeline
  134179. */
  134180. set bloomEnabled(enabled: boolean);
  134181. get bloomEnabled(): boolean;
  134182. private _rebuildBloom;
  134183. /**
  134184. * If the depth of field is enabled.
  134185. */
  134186. get depthOfFieldEnabled(): boolean;
  134187. set depthOfFieldEnabled(enabled: boolean);
  134188. /**
  134189. * Blur level of the depth of field effect. (Higher blur will effect performance)
  134190. */
  134191. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  134192. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  134193. /**
  134194. * If the anti aliasing is enabled.
  134195. */
  134196. set fxaaEnabled(enabled: boolean);
  134197. get fxaaEnabled(): boolean;
  134198. private _samples;
  134199. /**
  134200. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134201. */
  134202. set samples(sampleCount: number);
  134203. get samples(): number;
  134204. /**
  134205. * If image processing is enabled.
  134206. */
  134207. set imageProcessingEnabled(enabled: boolean);
  134208. get imageProcessingEnabled(): boolean;
  134209. /**
  134210. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  134211. */
  134212. set glowLayerEnabled(enabled: boolean);
  134213. get glowLayerEnabled(): boolean;
  134214. /**
  134215. * Gets the glow layer (or null if not defined)
  134216. */
  134217. get glowLayer(): Nullable<GlowLayer>;
  134218. /**
  134219. * Enable or disable the chromaticAberration process from the pipeline
  134220. */
  134221. set chromaticAberrationEnabled(enabled: boolean);
  134222. get chromaticAberrationEnabled(): boolean;
  134223. /**
  134224. * Enable or disable the grain process from the pipeline
  134225. */
  134226. set grainEnabled(enabled: boolean);
  134227. get grainEnabled(): boolean;
  134228. /**
  134229. * @constructor
  134230. * @param name - The rendering pipeline name (default: "")
  134231. * @param hdr - If high dynamic range textures should be used (default: true)
  134232. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134233. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134234. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134235. */
  134236. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134237. /**
  134238. * Get the class name
  134239. * @returns "DefaultRenderingPipeline"
  134240. */
  134241. getClassName(): string;
  134242. /**
  134243. * Force the compilation of the entire pipeline.
  134244. */
  134245. prepare(): void;
  134246. private _hasCleared;
  134247. private _prevPostProcess;
  134248. private _prevPrevPostProcess;
  134249. private _setAutoClearAndTextureSharing;
  134250. private _depthOfFieldSceneObserver;
  134251. private _buildPipeline;
  134252. private _disposePostProcesses;
  134253. /**
  134254. * Adds a camera to the pipeline
  134255. * @param camera the camera to be added
  134256. */
  134257. addCamera(camera: Camera): void;
  134258. /**
  134259. * Removes a camera from the pipeline
  134260. * @param camera the camera to remove
  134261. */
  134262. removeCamera(camera: Camera): void;
  134263. /**
  134264. * Dispose of the pipeline and stop all post processes
  134265. */
  134266. dispose(): void;
  134267. /**
  134268. * Serialize the rendering pipeline (Used when exporting)
  134269. * @returns the serialized object
  134270. */
  134271. serialize(): any;
  134272. /**
  134273. * Parse the serialized pipeline
  134274. * @param source Source pipeline.
  134275. * @param scene The scene to load the pipeline to.
  134276. * @param rootUrl The URL of the serialized pipeline.
  134277. * @returns An instantiated pipeline from the serialized object.
  134278. */
  134279. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134280. }
  134281. }
  134282. declare module BABYLON {
  134283. /** @hidden */
  134284. export var lensHighlightsPixelShader: {
  134285. name: string;
  134286. shader: string;
  134287. };
  134288. }
  134289. declare module BABYLON {
  134290. /** @hidden */
  134291. export var depthOfFieldPixelShader: {
  134292. name: string;
  134293. shader: string;
  134294. };
  134295. }
  134296. declare module BABYLON {
  134297. /**
  134298. * BABYLON.JS Chromatic Aberration GLSL Shader
  134299. * Author: Olivier Guyot
  134300. * Separates very slightly R, G and B colors on the edges of the screen
  134301. * Inspired by Francois Tarlier & Martins Upitis
  134302. */
  134303. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134304. /**
  134305. * @ignore
  134306. * The chromatic aberration PostProcess id in the pipeline
  134307. */
  134308. LensChromaticAberrationEffect: string;
  134309. /**
  134310. * @ignore
  134311. * The highlights enhancing PostProcess id in the pipeline
  134312. */
  134313. HighlightsEnhancingEffect: string;
  134314. /**
  134315. * @ignore
  134316. * The depth-of-field PostProcess id in the pipeline
  134317. */
  134318. LensDepthOfFieldEffect: string;
  134319. private _scene;
  134320. private _depthTexture;
  134321. private _grainTexture;
  134322. private _chromaticAberrationPostProcess;
  134323. private _highlightsPostProcess;
  134324. private _depthOfFieldPostProcess;
  134325. private _edgeBlur;
  134326. private _grainAmount;
  134327. private _chromaticAberration;
  134328. private _distortion;
  134329. private _highlightsGain;
  134330. private _highlightsThreshold;
  134331. private _dofDistance;
  134332. private _dofAperture;
  134333. private _dofDarken;
  134334. private _dofPentagon;
  134335. private _blurNoise;
  134336. /**
  134337. * @constructor
  134338. *
  134339. * Effect parameters are as follow:
  134340. * {
  134341. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134342. * edge_blur: number; // from 0 to x (1 for realism)
  134343. * distortion: number; // from 0 to x (1 for realism)
  134344. * grain_amount: number; // from 0 to 1
  134345. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134346. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134347. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134348. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134349. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134350. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134351. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134352. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134353. * }
  134354. * Note: if an effect parameter is unset, effect is disabled
  134355. *
  134356. * @param name The rendering pipeline name
  134357. * @param parameters - An object containing all parameters (see above)
  134358. * @param scene The scene linked to this pipeline
  134359. * @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)
  134360. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134361. */
  134362. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134363. /**
  134364. * Get the class name
  134365. * @returns "LensRenderingPipeline"
  134366. */
  134367. getClassName(): string;
  134368. /**
  134369. * Gets associated scene
  134370. */
  134371. get scene(): Scene;
  134372. /**
  134373. * Gets or sets the edge blur
  134374. */
  134375. get edgeBlur(): number;
  134376. set edgeBlur(value: number);
  134377. /**
  134378. * Gets or sets the grain amount
  134379. */
  134380. get grainAmount(): number;
  134381. set grainAmount(value: number);
  134382. /**
  134383. * Gets or sets the chromatic aberration amount
  134384. */
  134385. get chromaticAberration(): number;
  134386. set chromaticAberration(value: number);
  134387. /**
  134388. * Gets or sets the depth of field aperture
  134389. */
  134390. get dofAperture(): number;
  134391. set dofAperture(value: number);
  134392. /**
  134393. * Gets or sets the edge distortion
  134394. */
  134395. get edgeDistortion(): number;
  134396. set edgeDistortion(value: number);
  134397. /**
  134398. * Gets or sets the depth of field distortion
  134399. */
  134400. get dofDistortion(): number;
  134401. set dofDistortion(value: number);
  134402. /**
  134403. * Gets or sets the darken out of focus amount
  134404. */
  134405. get darkenOutOfFocus(): number;
  134406. set darkenOutOfFocus(value: number);
  134407. /**
  134408. * Gets or sets a boolean indicating if blur noise is enabled
  134409. */
  134410. get blurNoise(): boolean;
  134411. set blurNoise(value: boolean);
  134412. /**
  134413. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134414. */
  134415. get pentagonBokeh(): boolean;
  134416. set pentagonBokeh(value: boolean);
  134417. /**
  134418. * Gets or sets the highlight grain amount
  134419. */
  134420. get highlightsGain(): number;
  134421. set highlightsGain(value: number);
  134422. /**
  134423. * Gets or sets the highlight threshold
  134424. */
  134425. get highlightsThreshold(): number;
  134426. set highlightsThreshold(value: number);
  134427. /**
  134428. * Sets the amount of blur at the edges
  134429. * @param amount blur amount
  134430. */
  134431. setEdgeBlur(amount: number): void;
  134432. /**
  134433. * Sets edge blur to 0
  134434. */
  134435. disableEdgeBlur(): void;
  134436. /**
  134437. * Sets the amout of grain
  134438. * @param amount Amount of grain
  134439. */
  134440. setGrainAmount(amount: number): void;
  134441. /**
  134442. * Set grain amount to 0
  134443. */
  134444. disableGrain(): void;
  134445. /**
  134446. * Sets the chromatic aberration amount
  134447. * @param amount amount of chromatic aberration
  134448. */
  134449. setChromaticAberration(amount: number): void;
  134450. /**
  134451. * Sets chromatic aberration amount to 0
  134452. */
  134453. disableChromaticAberration(): void;
  134454. /**
  134455. * Sets the EdgeDistortion amount
  134456. * @param amount amount of EdgeDistortion
  134457. */
  134458. setEdgeDistortion(amount: number): void;
  134459. /**
  134460. * Sets edge distortion to 0
  134461. */
  134462. disableEdgeDistortion(): void;
  134463. /**
  134464. * Sets the FocusDistance amount
  134465. * @param amount amount of FocusDistance
  134466. */
  134467. setFocusDistance(amount: number): void;
  134468. /**
  134469. * Disables depth of field
  134470. */
  134471. disableDepthOfField(): void;
  134472. /**
  134473. * Sets the Aperture amount
  134474. * @param amount amount of Aperture
  134475. */
  134476. setAperture(amount: number): void;
  134477. /**
  134478. * Sets the DarkenOutOfFocus amount
  134479. * @param amount amount of DarkenOutOfFocus
  134480. */
  134481. setDarkenOutOfFocus(amount: number): void;
  134482. private _pentagonBokehIsEnabled;
  134483. /**
  134484. * Creates a pentagon bokeh effect
  134485. */
  134486. enablePentagonBokeh(): void;
  134487. /**
  134488. * Disables the pentagon bokeh effect
  134489. */
  134490. disablePentagonBokeh(): void;
  134491. /**
  134492. * Enables noise blur
  134493. */
  134494. enableNoiseBlur(): void;
  134495. /**
  134496. * Disables noise blur
  134497. */
  134498. disableNoiseBlur(): void;
  134499. /**
  134500. * Sets the HighlightsGain amount
  134501. * @param amount amount of HighlightsGain
  134502. */
  134503. setHighlightsGain(amount: number): void;
  134504. /**
  134505. * Sets the HighlightsThreshold amount
  134506. * @param amount amount of HighlightsThreshold
  134507. */
  134508. setHighlightsThreshold(amount: number): void;
  134509. /**
  134510. * Disables highlights
  134511. */
  134512. disableHighlights(): void;
  134513. /**
  134514. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134515. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134516. */
  134517. dispose(disableDepthRender?: boolean): void;
  134518. private _createChromaticAberrationPostProcess;
  134519. private _createHighlightsPostProcess;
  134520. private _createDepthOfFieldPostProcess;
  134521. private _createGrainTexture;
  134522. }
  134523. }
  134524. declare module BABYLON {
  134525. /** @hidden */
  134526. export var ssao2PixelShader: {
  134527. name: string;
  134528. shader: string;
  134529. };
  134530. }
  134531. declare module BABYLON {
  134532. /** @hidden */
  134533. export var ssaoCombinePixelShader: {
  134534. name: string;
  134535. shader: string;
  134536. };
  134537. }
  134538. declare module BABYLON {
  134539. /**
  134540. * Render pipeline to produce ssao effect
  134541. */
  134542. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134543. /**
  134544. * @ignore
  134545. * The PassPostProcess id in the pipeline that contains the original scene color
  134546. */
  134547. SSAOOriginalSceneColorEffect: string;
  134548. /**
  134549. * @ignore
  134550. * The SSAO PostProcess id in the pipeline
  134551. */
  134552. SSAORenderEffect: string;
  134553. /**
  134554. * @ignore
  134555. * The horizontal blur PostProcess id in the pipeline
  134556. */
  134557. SSAOBlurHRenderEffect: string;
  134558. /**
  134559. * @ignore
  134560. * The vertical blur PostProcess id in the pipeline
  134561. */
  134562. SSAOBlurVRenderEffect: string;
  134563. /**
  134564. * @ignore
  134565. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134566. */
  134567. SSAOCombineRenderEffect: string;
  134568. /**
  134569. * The output strength of the SSAO post-process. Default value is 1.0.
  134570. */
  134571. totalStrength: number;
  134572. /**
  134573. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134574. */
  134575. maxZ: number;
  134576. /**
  134577. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134578. */
  134579. minZAspect: number;
  134580. private _samples;
  134581. /**
  134582. * Number of samples used for the SSAO calculations. Default value is 8
  134583. */
  134584. set samples(n: number);
  134585. get samples(): number;
  134586. private _textureSamples;
  134587. /**
  134588. * Number of samples to use for antialiasing
  134589. */
  134590. set textureSamples(n: number);
  134591. get textureSamples(): number;
  134592. /**
  134593. * Ratio object used for SSAO ratio and blur ratio
  134594. */
  134595. private _ratio;
  134596. /**
  134597. * Dynamically generated sphere sampler.
  134598. */
  134599. private _sampleSphere;
  134600. /**
  134601. * Blur filter offsets
  134602. */
  134603. private _samplerOffsets;
  134604. private _expensiveBlur;
  134605. /**
  134606. * If bilateral blur should be used
  134607. */
  134608. set expensiveBlur(b: boolean);
  134609. get expensiveBlur(): boolean;
  134610. /**
  134611. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134612. */
  134613. radius: number;
  134614. /**
  134615. * The base color of the SSAO post-process
  134616. * The final result is "base + ssao" between [0, 1]
  134617. */
  134618. base: number;
  134619. /**
  134620. * Support test.
  134621. */
  134622. static get IsSupported(): boolean;
  134623. private _scene;
  134624. private _depthTexture;
  134625. private _normalTexture;
  134626. private _randomTexture;
  134627. private _originalColorPostProcess;
  134628. private _ssaoPostProcess;
  134629. private _blurHPostProcess;
  134630. private _blurVPostProcess;
  134631. private _ssaoCombinePostProcess;
  134632. /**
  134633. * Gets active scene
  134634. */
  134635. get scene(): Scene;
  134636. /**
  134637. * @constructor
  134638. * @param name The rendering pipeline name
  134639. * @param scene The scene linked to this pipeline
  134640. * @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 }
  134641. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134642. */
  134643. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134644. /**
  134645. * Get the class name
  134646. * @returns "SSAO2RenderingPipeline"
  134647. */
  134648. getClassName(): string;
  134649. /**
  134650. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134651. */
  134652. dispose(disableGeometryBufferRenderer?: boolean): void;
  134653. private _createBlurPostProcess;
  134654. /** @hidden */
  134655. _rebuild(): void;
  134656. private _bits;
  134657. private _radicalInverse_VdC;
  134658. private _hammersley;
  134659. private _hemisphereSample_uniform;
  134660. private _generateHemisphere;
  134661. private _createSSAOPostProcess;
  134662. private _createSSAOCombinePostProcess;
  134663. private _createRandomTexture;
  134664. /**
  134665. * Serialize the rendering pipeline (Used when exporting)
  134666. * @returns the serialized object
  134667. */
  134668. serialize(): any;
  134669. /**
  134670. * Parse the serialized pipeline
  134671. * @param source Source pipeline.
  134672. * @param scene The scene to load the pipeline to.
  134673. * @param rootUrl The URL of the serialized pipeline.
  134674. * @returns An instantiated pipeline from the serialized object.
  134675. */
  134676. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134677. }
  134678. }
  134679. declare module BABYLON {
  134680. /** @hidden */
  134681. export var ssaoPixelShader: {
  134682. name: string;
  134683. shader: string;
  134684. };
  134685. }
  134686. declare module BABYLON {
  134687. /**
  134688. * Render pipeline to produce ssao effect
  134689. */
  134690. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134691. /**
  134692. * @ignore
  134693. * The PassPostProcess id in the pipeline that contains the original scene color
  134694. */
  134695. SSAOOriginalSceneColorEffect: string;
  134696. /**
  134697. * @ignore
  134698. * The SSAO PostProcess id in the pipeline
  134699. */
  134700. SSAORenderEffect: string;
  134701. /**
  134702. * @ignore
  134703. * The horizontal blur PostProcess id in the pipeline
  134704. */
  134705. SSAOBlurHRenderEffect: string;
  134706. /**
  134707. * @ignore
  134708. * The vertical blur PostProcess id in the pipeline
  134709. */
  134710. SSAOBlurVRenderEffect: string;
  134711. /**
  134712. * @ignore
  134713. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134714. */
  134715. SSAOCombineRenderEffect: string;
  134716. /**
  134717. * The output strength of the SSAO post-process. Default value is 1.0.
  134718. */
  134719. totalStrength: number;
  134720. /**
  134721. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134722. */
  134723. radius: number;
  134724. /**
  134725. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134726. * Must not be equal to fallOff and superior to fallOff.
  134727. * Default value is 0.0075
  134728. */
  134729. area: number;
  134730. /**
  134731. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134732. * Must not be equal to area and inferior to area.
  134733. * Default value is 0.000001
  134734. */
  134735. fallOff: number;
  134736. /**
  134737. * The base color of the SSAO post-process
  134738. * The final result is "base + ssao" between [0, 1]
  134739. */
  134740. base: number;
  134741. private _scene;
  134742. private _depthTexture;
  134743. private _randomTexture;
  134744. private _originalColorPostProcess;
  134745. private _ssaoPostProcess;
  134746. private _blurHPostProcess;
  134747. private _blurVPostProcess;
  134748. private _ssaoCombinePostProcess;
  134749. private _firstUpdate;
  134750. /**
  134751. * Gets active scene
  134752. */
  134753. get scene(): Scene;
  134754. /**
  134755. * @constructor
  134756. * @param name - The rendering pipeline name
  134757. * @param scene - The scene linked to this pipeline
  134758. * @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 }
  134759. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134760. */
  134761. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134762. /**
  134763. * Get the class name
  134764. * @returns "SSAORenderingPipeline"
  134765. */
  134766. getClassName(): string;
  134767. /**
  134768. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134769. */
  134770. dispose(disableDepthRender?: boolean): void;
  134771. private _createBlurPostProcess;
  134772. /** @hidden */
  134773. _rebuild(): void;
  134774. private _createSSAOPostProcess;
  134775. private _createSSAOCombinePostProcess;
  134776. private _createRandomTexture;
  134777. }
  134778. }
  134779. declare module BABYLON {
  134780. /** @hidden */
  134781. export var standardPixelShader: {
  134782. name: string;
  134783. shader: string;
  134784. };
  134785. }
  134786. declare module BABYLON {
  134787. /**
  134788. * Standard rendering pipeline
  134789. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134790. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134791. */
  134792. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134793. /**
  134794. * Public members
  134795. */
  134796. /**
  134797. * Post-process which contains the original scene color before the pipeline applies all the effects
  134798. */
  134799. originalPostProcess: Nullable<PostProcess>;
  134800. /**
  134801. * Post-process used to down scale an image x4
  134802. */
  134803. downSampleX4PostProcess: Nullable<PostProcess>;
  134804. /**
  134805. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134806. */
  134807. brightPassPostProcess: Nullable<PostProcess>;
  134808. /**
  134809. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134810. */
  134811. blurHPostProcesses: PostProcess[];
  134812. /**
  134813. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134814. */
  134815. blurVPostProcesses: PostProcess[];
  134816. /**
  134817. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134818. */
  134819. textureAdderPostProcess: Nullable<PostProcess>;
  134820. /**
  134821. * Post-process used to create volumetric lighting effect
  134822. */
  134823. volumetricLightPostProcess: Nullable<PostProcess>;
  134824. /**
  134825. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134826. */
  134827. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134828. /**
  134829. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134830. */
  134831. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134832. /**
  134833. * Post-process used to merge the volumetric light effect and the real scene color
  134834. */
  134835. volumetricLightMergePostProces: Nullable<PostProcess>;
  134836. /**
  134837. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134838. */
  134839. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134840. /**
  134841. * Base post-process used to calculate the average luminance of the final image for HDR
  134842. */
  134843. luminancePostProcess: Nullable<PostProcess>;
  134844. /**
  134845. * Post-processes used to create down sample post-processes in order to get
  134846. * the average luminance of the final image for HDR
  134847. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134848. */
  134849. luminanceDownSamplePostProcesses: PostProcess[];
  134850. /**
  134851. * Post-process used to create a HDR effect (light adaptation)
  134852. */
  134853. hdrPostProcess: Nullable<PostProcess>;
  134854. /**
  134855. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134856. */
  134857. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134858. /**
  134859. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134860. */
  134861. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134862. /**
  134863. * Post-process used to merge the final HDR post-process and the real scene color
  134864. */
  134865. hdrFinalPostProcess: Nullable<PostProcess>;
  134866. /**
  134867. * Post-process used to create a lens flare effect
  134868. */
  134869. lensFlarePostProcess: Nullable<PostProcess>;
  134870. /**
  134871. * Post-process that merges the result of the lens flare post-process and the real scene color
  134872. */
  134873. lensFlareComposePostProcess: Nullable<PostProcess>;
  134874. /**
  134875. * Post-process used to create a motion blur effect
  134876. */
  134877. motionBlurPostProcess: Nullable<PostProcess>;
  134878. /**
  134879. * Post-process used to create a depth of field effect
  134880. */
  134881. depthOfFieldPostProcess: Nullable<PostProcess>;
  134882. /**
  134883. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134884. */
  134885. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134886. /**
  134887. * Represents the brightness threshold in order to configure the illuminated surfaces
  134888. */
  134889. brightThreshold: number;
  134890. /**
  134891. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134892. */
  134893. blurWidth: number;
  134894. /**
  134895. * Sets if the blur for highlighted surfaces must be only horizontal
  134896. */
  134897. horizontalBlur: boolean;
  134898. /**
  134899. * Gets the overall exposure used by the pipeline
  134900. */
  134901. get exposure(): number;
  134902. /**
  134903. * Sets the overall exposure used by the pipeline
  134904. */
  134905. set exposure(value: number);
  134906. /**
  134907. * Texture used typically to simulate "dirty" on camera lens
  134908. */
  134909. lensTexture: Nullable<Texture>;
  134910. /**
  134911. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134912. */
  134913. volumetricLightCoefficient: number;
  134914. /**
  134915. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134916. */
  134917. volumetricLightPower: number;
  134918. /**
  134919. * Used the set the blur intensity to smooth the volumetric lights
  134920. */
  134921. volumetricLightBlurScale: number;
  134922. /**
  134923. * Light (spot or directional) used to generate the volumetric lights rays
  134924. * The source light must have a shadow generate so the pipeline can get its
  134925. * depth map
  134926. */
  134927. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134928. /**
  134929. * For eye adaptation, represents the minimum luminance the eye can see
  134930. */
  134931. hdrMinimumLuminance: number;
  134932. /**
  134933. * For eye adaptation, represents the decrease luminance speed
  134934. */
  134935. hdrDecreaseRate: number;
  134936. /**
  134937. * For eye adaptation, represents the increase luminance speed
  134938. */
  134939. hdrIncreaseRate: number;
  134940. /**
  134941. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134942. */
  134943. get hdrAutoExposure(): boolean;
  134944. /**
  134945. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134946. */
  134947. set hdrAutoExposure(value: boolean);
  134948. /**
  134949. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134950. */
  134951. lensColorTexture: Nullable<Texture>;
  134952. /**
  134953. * The overall strengh for the lens flare effect
  134954. */
  134955. lensFlareStrength: number;
  134956. /**
  134957. * Dispersion coefficient for lens flare ghosts
  134958. */
  134959. lensFlareGhostDispersal: number;
  134960. /**
  134961. * Main lens flare halo width
  134962. */
  134963. lensFlareHaloWidth: number;
  134964. /**
  134965. * Based on the lens distortion effect, defines how much the lens flare result
  134966. * is distorted
  134967. */
  134968. lensFlareDistortionStrength: number;
  134969. /**
  134970. * Configures the blur intensity used for for lens flare (halo)
  134971. */
  134972. lensFlareBlurWidth: number;
  134973. /**
  134974. * Lens star texture must be used to simulate rays on the flares and is available
  134975. * in the documentation
  134976. */
  134977. lensStarTexture: Nullable<Texture>;
  134978. /**
  134979. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134980. * flare effect by taking account of the dirt texture
  134981. */
  134982. lensFlareDirtTexture: Nullable<Texture>;
  134983. /**
  134984. * Represents the focal length for the depth of field effect
  134985. */
  134986. depthOfFieldDistance: number;
  134987. /**
  134988. * Represents the blur intensity for the blurred part of the depth of field effect
  134989. */
  134990. depthOfFieldBlurWidth: number;
  134991. /**
  134992. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134993. */
  134994. get motionStrength(): number;
  134995. /**
  134996. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134997. */
  134998. set motionStrength(strength: number);
  134999. /**
  135000. * Gets wether or not the motion blur post-process is object based or screen based.
  135001. */
  135002. get objectBasedMotionBlur(): boolean;
  135003. /**
  135004. * Sets wether or not the motion blur post-process should be object based or screen based
  135005. */
  135006. set objectBasedMotionBlur(value: boolean);
  135007. /**
  135008. * List of animations for the pipeline (IAnimatable implementation)
  135009. */
  135010. animations: Animation[];
  135011. /**
  135012. * Private members
  135013. */
  135014. private _scene;
  135015. private _currentDepthOfFieldSource;
  135016. private _basePostProcess;
  135017. private _fixedExposure;
  135018. private _currentExposure;
  135019. private _hdrAutoExposure;
  135020. private _hdrCurrentLuminance;
  135021. private _motionStrength;
  135022. private _isObjectBasedMotionBlur;
  135023. private _floatTextureType;
  135024. private _camerasToBeAttached;
  135025. private _ratio;
  135026. private _bloomEnabled;
  135027. private _depthOfFieldEnabled;
  135028. private _vlsEnabled;
  135029. private _lensFlareEnabled;
  135030. private _hdrEnabled;
  135031. private _motionBlurEnabled;
  135032. private _fxaaEnabled;
  135033. private _motionBlurSamples;
  135034. private _volumetricLightStepsCount;
  135035. private _samples;
  135036. /**
  135037. * @ignore
  135038. * Specifies if the bloom pipeline is enabled
  135039. */
  135040. get BloomEnabled(): boolean;
  135041. set BloomEnabled(enabled: boolean);
  135042. /**
  135043. * @ignore
  135044. * Specifies if the depth of field pipeline is enabed
  135045. */
  135046. get DepthOfFieldEnabled(): boolean;
  135047. set DepthOfFieldEnabled(enabled: boolean);
  135048. /**
  135049. * @ignore
  135050. * Specifies if the lens flare pipeline is enabed
  135051. */
  135052. get LensFlareEnabled(): boolean;
  135053. set LensFlareEnabled(enabled: boolean);
  135054. /**
  135055. * @ignore
  135056. * Specifies if the HDR pipeline is enabled
  135057. */
  135058. get HDREnabled(): boolean;
  135059. set HDREnabled(enabled: boolean);
  135060. /**
  135061. * @ignore
  135062. * Specifies if the volumetric lights scattering effect is enabled
  135063. */
  135064. get VLSEnabled(): boolean;
  135065. set VLSEnabled(enabled: boolean);
  135066. /**
  135067. * @ignore
  135068. * Specifies if the motion blur effect is enabled
  135069. */
  135070. get MotionBlurEnabled(): boolean;
  135071. set MotionBlurEnabled(enabled: boolean);
  135072. /**
  135073. * Specifies if anti-aliasing is enabled
  135074. */
  135075. get fxaaEnabled(): boolean;
  135076. set fxaaEnabled(enabled: boolean);
  135077. /**
  135078. * Specifies the number of steps used to calculate the volumetric lights
  135079. * Typically in interval [50, 200]
  135080. */
  135081. get volumetricLightStepsCount(): number;
  135082. set volumetricLightStepsCount(count: number);
  135083. /**
  135084. * Specifies the number of samples used for the motion blur effect
  135085. * Typically in interval [16, 64]
  135086. */
  135087. get motionBlurSamples(): number;
  135088. set motionBlurSamples(samples: number);
  135089. /**
  135090. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135091. */
  135092. get samples(): number;
  135093. set samples(sampleCount: number);
  135094. /**
  135095. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  135096. * @constructor
  135097. * @param name The rendering pipeline name
  135098. * @param scene The scene linked to this pipeline
  135099. * @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)
  135100. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  135101. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135102. */
  135103. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  135104. private _buildPipeline;
  135105. private _createDownSampleX4PostProcess;
  135106. private _createBrightPassPostProcess;
  135107. private _createBlurPostProcesses;
  135108. private _createTextureAdderPostProcess;
  135109. private _createVolumetricLightPostProcess;
  135110. private _createLuminancePostProcesses;
  135111. private _createHdrPostProcess;
  135112. private _createLensFlarePostProcess;
  135113. private _createDepthOfFieldPostProcess;
  135114. private _createMotionBlurPostProcess;
  135115. private _getDepthTexture;
  135116. private _disposePostProcesses;
  135117. /**
  135118. * Dispose of the pipeline and stop all post processes
  135119. */
  135120. dispose(): void;
  135121. /**
  135122. * Serialize the rendering pipeline (Used when exporting)
  135123. * @returns the serialized object
  135124. */
  135125. serialize(): any;
  135126. /**
  135127. * Parse the serialized pipeline
  135128. * @param source Source pipeline.
  135129. * @param scene The scene to load the pipeline to.
  135130. * @param rootUrl The URL of the serialized pipeline.
  135131. * @returns An instantiated pipeline from the serialized object.
  135132. */
  135133. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  135134. /**
  135135. * Luminance steps
  135136. */
  135137. static LuminanceSteps: number;
  135138. }
  135139. }
  135140. declare module BABYLON {
  135141. /** @hidden */
  135142. export var tonemapPixelShader: {
  135143. name: string;
  135144. shader: string;
  135145. };
  135146. }
  135147. declare module BABYLON {
  135148. /** Defines operator used for tonemapping */
  135149. export enum TonemappingOperator {
  135150. /** Hable */
  135151. Hable = 0,
  135152. /** Reinhard */
  135153. Reinhard = 1,
  135154. /** HejiDawson */
  135155. HejiDawson = 2,
  135156. /** Photographic */
  135157. Photographic = 3
  135158. }
  135159. /**
  135160. * Defines a post process to apply tone mapping
  135161. */
  135162. export class TonemapPostProcess extends PostProcess {
  135163. private _operator;
  135164. /** Defines the required exposure adjustement */
  135165. exposureAdjustment: number;
  135166. /**
  135167. * Creates a new TonemapPostProcess
  135168. * @param name defines the name of the postprocess
  135169. * @param _operator defines the operator to use
  135170. * @param exposureAdjustment defines the required exposure adjustement
  135171. * @param camera defines the camera to use (can be null)
  135172. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  135173. * @param engine defines the hosting engine (can be ignore if camera is set)
  135174. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  135175. */
  135176. constructor(name: string, _operator: TonemappingOperator,
  135177. /** Defines the required exposure adjustement */
  135178. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  135179. }
  135180. }
  135181. declare module BABYLON {
  135182. /** @hidden */
  135183. export var depthVertexShader: {
  135184. name: string;
  135185. shader: string;
  135186. };
  135187. }
  135188. declare module BABYLON {
  135189. /** @hidden */
  135190. export var volumetricLightScatteringPixelShader: {
  135191. name: string;
  135192. shader: string;
  135193. };
  135194. }
  135195. declare module BABYLON {
  135196. /** @hidden */
  135197. export var volumetricLightScatteringPassVertexShader: {
  135198. name: string;
  135199. shader: string;
  135200. };
  135201. }
  135202. declare module BABYLON {
  135203. /** @hidden */
  135204. export var volumetricLightScatteringPassPixelShader: {
  135205. name: string;
  135206. shader: string;
  135207. };
  135208. }
  135209. declare module BABYLON {
  135210. /**
  135211. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  135212. */
  135213. export class VolumetricLightScatteringPostProcess extends PostProcess {
  135214. private _volumetricLightScatteringPass;
  135215. private _volumetricLightScatteringRTT;
  135216. private _viewPort;
  135217. private _screenCoordinates;
  135218. private _cachedDefines;
  135219. /**
  135220. * If not undefined, the mesh position is computed from the attached node position
  135221. */
  135222. attachedNode: {
  135223. position: Vector3;
  135224. };
  135225. /**
  135226. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  135227. */
  135228. customMeshPosition: Vector3;
  135229. /**
  135230. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135231. */
  135232. useCustomMeshPosition: boolean;
  135233. /**
  135234. * If the post-process should inverse the light scattering direction
  135235. */
  135236. invert: boolean;
  135237. /**
  135238. * The internal mesh used by the post-process
  135239. */
  135240. mesh: Mesh;
  135241. /**
  135242. * @hidden
  135243. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135244. */
  135245. get useDiffuseColor(): boolean;
  135246. set useDiffuseColor(useDiffuseColor: boolean);
  135247. /**
  135248. * Array containing the excluded meshes not rendered in the internal pass
  135249. */
  135250. excludedMeshes: AbstractMesh[];
  135251. /**
  135252. * Controls the overall intensity of the post-process
  135253. */
  135254. exposure: number;
  135255. /**
  135256. * Dissipates each sample's contribution in range [0, 1]
  135257. */
  135258. decay: number;
  135259. /**
  135260. * Controls the overall intensity of each sample
  135261. */
  135262. weight: number;
  135263. /**
  135264. * Controls the density of each sample
  135265. */
  135266. density: number;
  135267. /**
  135268. * @constructor
  135269. * @param name The post-process name
  135270. * @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)
  135271. * @param camera The camera that the post-process will be attached to
  135272. * @param mesh The mesh used to create the light scattering
  135273. * @param samples The post-process quality, default 100
  135274. * @param samplingModeThe post-process filtering mode
  135275. * @param engine The babylon engine
  135276. * @param reusable If the post-process is reusable
  135277. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135278. */
  135279. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135280. /**
  135281. * Returns the string "VolumetricLightScatteringPostProcess"
  135282. * @returns "VolumetricLightScatteringPostProcess"
  135283. */
  135284. getClassName(): string;
  135285. private _isReady;
  135286. /**
  135287. * Sets the new light position for light scattering effect
  135288. * @param position The new custom light position
  135289. */
  135290. setCustomMeshPosition(position: Vector3): void;
  135291. /**
  135292. * Returns the light position for light scattering effect
  135293. * @return Vector3 The custom light position
  135294. */
  135295. getCustomMeshPosition(): Vector3;
  135296. /**
  135297. * Disposes the internal assets and detaches the post-process from the camera
  135298. */
  135299. dispose(camera: Camera): void;
  135300. /**
  135301. * Returns the render target texture used by the post-process
  135302. * @return the render target texture used by the post-process
  135303. */
  135304. getPass(): RenderTargetTexture;
  135305. private _meshExcluded;
  135306. private _createPass;
  135307. private _updateMeshScreenCoordinates;
  135308. /**
  135309. * Creates a default mesh for the Volumeric Light Scattering post-process
  135310. * @param name The mesh name
  135311. * @param scene The scene where to create the mesh
  135312. * @return the default mesh
  135313. */
  135314. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135315. }
  135316. }
  135317. declare module BABYLON {
  135318. interface Scene {
  135319. /** @hidden (Backing field) */
  135320. _boundingBoxRenderer: BoundingBoxRenderer;
  135321. /** @hidden (Backing field) */
  135322. _forceShowBoundingBoxes: boolean;
  135323. /**
  135324. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135325. */
  135326. forceShowBoundingBoxes: boolean;
  135327. /**
  135328. * Gets the bounding box renderer associated with the scene
  135329. * @returns a BoundingBoxRenderer
  135330. */
  135331. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135332. }
  135333. interface AbstractMesh {
  135334. /** @hidden (Backing field) */
  135335. _showBoundingBox: boolean;
  135336. /**
  135337. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135338. */
  135339. showBoundingBox: boolean;
  135340. }
  135341. /**
  135342. * Component responsible of rendering the bounding box of the meshes in a scene.
  135343. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135344. */
  135345. export class BoundingBoxRenderer implements ISceneComponent {
  135346. /**
  135347. * The component name helpfull to identify the component in the list of scene components.
  135348. */
  135349. readonly name: string;
  135350. /**
  135351. * The scene the component belongs to.
  135352. */
  135353. scene: Scene;
  135354. /**
  135355. * Color of the bounding box lines placed in front of an object
  135356. */
  135357. frontColor: Color3;
  135358. /**
  135359. * Color of the bounding box lines placed behind an object
  135360. */
  135361. backColor: Color3;
  135362. /**
  135363. * Defines if the renderer should show the back lines or not
  135364. */
  135365. showBackLines: boolean;
  135366. /**
  135367. * @hidden
  135368. */
  135369. renderList: SmartArray<BoundingBox>;
  135370. private _colorShader;
  135371. private _vertexBuffers;
  135372. private _indexBuffer;
  135373. private _fillIndexBuffer;
  135374. private _fillIndexData;
  135375. /**
  135376. * Instantiates a new bounding box renderer in a scene.
  135377. * @param scene the scene the renderer renders in
  135378. */
  135379. constructor(scene: Scene);
  135380. /**
  135381. * Registers the component in a given scene
  135382. */
  135383. register(): void;
  135384. private _evaluateSubMesh;
  135385. private _activeMesh;
  135386. private _prepareRessources;
  135387. private _createIndexBuffer;
  135388. /**
  135389. * Rebuilds the elements related to this component in case of
  135390. * context lost for instance.
  135391. */
  135392. rebuild(): void;
  135393. /**
  135394. * @hidden
  135395. */
  135396. reset(): void;
  135397. /**
  135398. * Render the bounding boxes of a specific rendering group
  135399. * @param renderingGroupId defines the rendering group to render
  135400. */
  135401. render(renderingGroupId: number): void;
  135402. /**
  135403. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135404. * @param mesh Define the mesh to render the occlusion bounding box for
  135405. */
  135406. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135407. /**
  135408. * Dispose and release the resources attached to this renderer.
  135409. */
  135410. dispose(): void;
  135411. }
  135412. }
  135413. declare module BABYLON {
  135414. /** @hidden */
  135415. export var depthPixelShader: {
  135416. name: string;
  135417. shader: string;
  135418. };
  135419. }
  135420. declare module BABYLON {
  135421. /**
  135422. * This represents a depth renderer in Babylon.
  135423. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135424. */
  135425. export class DepthRenderer {
  135426. private _scene;
  135427. private _depthMap;
  135428. private _effect;
  135429. private readonly _storeNonLinearDepth;
  135430. private readonly _clearColor;
  135431. /** Get if the depth renderer is using packed depth or not */
  135432. readonly isPacked: boolean;
  135433. private _cachedDefines;
  135434. private _camera;
  135435. /**
  135436. * Specifiess that the depth renderer will only be used within
  135437. * the camera it is created for.
  135438. * This can help forcing its rendering during the camera processing.
  135439. */
  135440. useOnlyInActiveCamera: boolean;
  135441. /** @hidden */
  135442. static _SceneComponentInitialization: (scene: Scene) => void;
  135443. /**
  135444. * Instantiates a depth renderer
  135445. * @param scene The scene the renderer belongs to
  135446. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135447. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135448. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135449. */
  135450. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135451. /**
  135452. * Creates the depth rendering effect and checks if the effect is ready.
  135453. * @param subMesh The submesh to be used to render the depth map of
  135454. * @param useInstances If multiple world instances should be used
  135455. * @returns if the depth renderer is ready to render the depth map
  135456. */
  135457. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135458. /**
  135459. * Gets the texture which the depth map will be written to.
  135460. * @returns The depth map texture
  135461. */
  135462. getDepthMap(): RenderTargetTexture;
  135463. /**
  135464. * Disposes of the depth renderer.
  135465. */
  135466. dispose(): void;
  135467. }
  135468. }
  135469. declare module BABYLON {
  135470. interface Scene {
  135471. /** @hidden (Backing field) */
  135472. _depthRenderer: {
  135473. [id: string]: DepthRenderer;
  135474. };
  135475. /**
  135476. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135477. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135478. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135479. * @returns the created depth renderer
  135480. */
  135481. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135482. /**
  135483. * Disables a depth renderer for a given camera
  135484. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135485. */
  135486. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135487. }
  135488. /**
  135489. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135490. * in several rendering techniques.
  135491. */
  135492. export class DepthRendererSceneComponent implements ISceneComponent {
  135493. /**
  135494. * The component name helpfull to identify the component in the list of scene components.
  135495. */
  135496. readonly name: string;
  135497. /**
  135498. * The scene the component belongs to.
  135499. */
  135500. scene: Scene;
  135501. /**
  135502. * Creates a new instance of the component for the given scene
  135503. * @param scene Defines the scene to register the component in
  135504. */
  135505. constructor(scene: Scene);
  135506. /**
  135507. * Registers the component in a given scene
  135508. */
  135509. register(): void;
  135510. /**
  135511. * Rebuilds the elements related to this component in case of
  135512. * context lost for instance.
  135513. */
  135514. rebuild(): void;
  135515. /**
  135516. * Disposes the component and the associated ressources
  135517. */
  135518. dispose(): void;
  135519. private _gatherRenderTargets;
  135520. private _gatherActiveCameraRenderTargets;
  135521. }
  135522. }
  135523. declare module BABYLON {
  135524. /** @hidden */
  135525. export var outlinePixelShader: {
  135526. name: string;
  135527. shader: string;
  135528. };
  135529. }
  135530. declare module BABYLON {
  135531. /** @hidden */
  135532. export var outlineVertexShader: {
  135533. name: string;
  135534. shader: string;
  135535. };
  135536. }
  135537. declare module BABYLON {
  135538. interface Scene {
  135539. /** @hidden */
  135540. _outlineRenderer: OutlineRenderer;
  135541. /**
  135542. * Gets the outline renderer associated with the scene
  135543. * @returns a OutlineRenderer
  135544. */
  135545. getOutlineRenderer(): OutlineRenderer;
  135546. }
  135547. interface AbstractMesh {
  135548. /** @hidden (Backing field) */
  135549. _renderOutline: boolean;
  135550. /**
  135551. * Gets or sets a boolean indicating if the outline must be rendered as well
  135552. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135553. */
  135554. renderOutline: boolean;
  135555. /** @hidden (Backing field) */
  135556. _renderOverlay: boolean;
  135557. /**
  135558. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135559. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135560. */
  135561. renderOverlay: boolean;
  135562. }
  135563. /**
  135564. * This class is responsible to draw bothe outline/overlay of meshes.
  135565. * It should not be used directly but through the available method on mesh.
  135566. */
  135567. export class OutlineRenderer implements ISceneComponent {
  135568. /**
  135569. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135570. */
  135571. private static _StencilReference;
  135572. /**
  135573. * The name of the component. Each component must have a unique name.
  135574. */
  135575. name: string;
  135576. /**
  135577. * The scene the component belongs to.
  135578. */
  135579. scene: Scene;
  135580. /**
  135581. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135582. */
  135583. zOffset: number;
  135584. private _engine;
  135585. private _effect;
  135586. private _cachedDefines;
  135587. private _savedDepthWrite;
  135588. /**
  135589. * Instantiates a new outline renderer. (There could be only one per scene).
  135590. * @param scene Defines the scene it belongs to
  135591. */
  135592. constructor(scene: Scene);
  135593. /**
  135594. * Register the component to one instance of a scene.
  135595. */
  135596. register(): void;
  135597. /**
  135598. * Rebuilds the elements related to this component in case of
  135599. * context lost for instance.
  135600. */
  135601. rebuild(): void;
  135602. /**
  135603. * Disposes the component and the associated ressources.
  135604. */
  135605. dispose(): void;
  135606. /**
  135607. * Renders the outline in the canvas.
  135608. * @param subMesh Defines the sumesh to render
  135609. * @param batch Defines the batch of meshes in case of instances
  135610. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135611. */
  135612. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135613. /**
  135614. * Returns whether or not the outline renderer is ready for a given submesh.
  135615. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135616. * @param subMesh Defines the submesh to check readyness for
  135617. * @param useInstances Defines wheter wee are trying to render instances or not
  135618. * @returns true if ready otherwise false
  135619. */
  135620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135621. private _beforeRenderingMesh;
  135622. private _afterRenderingMesh;
  135623. }
  135624. }
  135625. declare module BABYLON {
  135626. /**
  135627. * Defines the basic options interface of a Sprite Frame Source Size.
  135628. */
  135629. export interface ISpriteJSONSpriteSourceSize {
  135630. /**
  135631. * number of the original width of the Frame
  135632. */
  135633. w: number;
  135634. /**
  135635. * number of the original height of the Frame
  135636. */
  135637. h: number;
  135638. }
  135639. /**
  135640. * Defines the basic options interface of a Sprite Frame Data.
  135641. */
  135642. export interface ISpriteJSONSpriteFrameData {
  135643. /**
  135644. * number of the x offset of the Frame
  135645. */
  135646. x: number;
  135647. /**
  135648. * number of the y offset of the Frame
  135649. */
  135650. y: number;
  135651. /**
  135652. * number of the width of the Frame
  135653. */
  135654. w: number;
  135655. /**
  135656. * number of the height of the Frame
  135657. */
  135658. h: number;
  135659. }
  135660. /**
  135661. * Defines the basic options interface of a JSON Sprite.
  135662. */
  135663. export interface ISpriteJSONSprite {
  135664. /**
  135665. * string name of the Frame
  135666. */
  135667. filename: string;
  135668. /**
  135669. * ISpriteJSONSpriteFrame basic object of the frame data
  135670. */
  135671. frame: ISpriteJSONSpriteFrameData;
  135672. /**
  135673. * boolean to flag is the frame was rotated.
  135674. */
  135675. rotated: boolean;
  135676. /**
  135677. * boolean to flag is the frame was trimmed.
  135678. */
  135679. trimmed: boolean;
  135680. /**
  135681. * ISpriteJSONSpriteFrame basic object of the source data
  135682. */
  135683. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135684. /**
  135685. * ISpriteJSONSpriteFrame basic object of the source data
  135686. */
  135687. sourceSize: ISpriteJSONSpriteSourceSize;
  135688. }
  135689. /**
  135690. * Defines the basic options interface of a JSON atlas.
  135691. */
  135692. export interface ISpriteJSONAtlas {
  135693. /**
  135694. * Array of objects that contain the frame data.
  135695. */
  135696. frames: Array<ISpriteJSONSprite>;
  135697. /**
  135698. * object basic object containing the sprite meta data.
  135699. */
  135700. meta?: object;
  135701. }
  135702. }
  135703. declare module BABYLON {
  135704. /** @hidden */
  135705. export var spriteMapPixelShader: {
  135706. name: string;
  135707. shader: string;
  135708. };
  135709. }
  135710. declare module BABYLON {
  135711. /** @hidden */
  135712. export var spriteMapVertexShader: {
  135713. name: string;
  135714. shader: string;
  135715. };
  135716. }
  135717. declare module BABYLON {
  135718. /**
  135719. * Defines the basic options interface of a SpriteMap
  135720. */
  135721. export interface ISpriteMapOptions {
  135722. /**
  135723. * Vector2 of the number of cells in the grid.
  135724. */
  135725. stageSize?: Vector2;
  135726. /**
  135727. * Vector2 of the size of the output plane in World Units.
  135728. */
  135729. outputSize?: Vector2;
  135730. /**
  135731. * Vector3 of the position of the output plane in World Units.
  135732. */
  135733. outputPosition?: Vector3;
  135734. /**
  135735. * Vector3 of the rotation of the output plane.
  135736. */
  135737. outputRotation?: Vector3;
  135738. /**
  135739. * number of layers that the system will reserve in resources.
  135740. */
  135741. layerCount?: number;
  135742. /**
  135743. * number of max animation frames a single cell will reserve in resources.
  135744. */
  135745. maxAnimationFrames?: number;
  135746. /**
  135747. * number cell index of the base tile when the system compiles.
  135748. */
  135749. baseTile?: number;
  135750. /**
  135751. * boolean flip the sprite after its been repositioned by the framing data.
  135752. */
  135753. flipU?: boolean;
  135754. /**
  135755. * Vector3 scalar of the global RGB values of the SpriteMap.
  135756. */
  135757. colorMultiply?: Vector3;
  135758. }
  135759. /**
  135760. * Defines the IDisposable interface in order to be cleanable from resources.
  135761. */
  135762. export interface ISpriteMap extends IDisposable {
  135763. /**
  135764. * String name of the SpriteMap.
  135765. */
  135766. name: string;
  135767. /**
  135768. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135769. */
  135770. atlasJSON: ISpriteJSONAtlas;
  135771. /**
  135772. * Texture of the SpriteMap.
  135773. */
  135774. spriteSheet: Texture;
  135775. /**
  135776. * The parameters to initialize the SpriteMap with.
  135777. */
  135778. options: ISpriteMapOptions;
  135779. }
  135780. /**
  135781. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135782. */
  135783. export class SpriteMap implements ISpriteMap {
  135784. /** The Name of the spriteMap */
  135785. name: string;
  135786. /** The JSON file with the frame and meta data */
  135787. atlasJSON: ISpriteJSONAtlas;
  135788. /** The systems Sprite Sheet Texture */
  135789. spriteSheet: Texture;
  135790. /** Arguments passed with the Constructor */
  135791. options: ISpriteMapOptions;
  135792. /** Public Sprite Storage array, parsed from atlasJSON */
  135793. sprites: Array<ISpriteJSONSprite>;
  135794. /** Returns the Number of Sprites in the System */
  135795. get spriteCount(): number;
  135796. /** Returns the Position of Output Plane*/
  135797. get position(): Vector3;
  135798. /** Returns the Position of Output Plane*/
  135799. set position(v: Vector3);
  135800. /** Returns the Rotation of Output Plane*/
  135801. get rotation(): Vector3;
  135802. /** Returns the Rotation of Output Plane*/
  135803. set rotation(v: Vector3);
  135804. /** Sets the AnimationMap*/
  135805. get animationMap(): RawTexture;
  135806. /** Sets the AnimationMap*/
  135807. set animationMap(v: RawTexture);
  135808. /** Scene that the SpriteMap was created in */
  135809. private _scene;
  135810. /** Texture Buffer of Float32 that holds tile frame data*/
  135811. private _frameMap;
  135812. /** Texture Buffers of Float32 that holds tileMap data*/
  135813. private _tileMaps;
  135814. /** Texture Buffer of Float32 that holds Animation Data*/
  135815. private _animationMap;
  135816. /** Custom ShaderMaterial Central to the System*/
  135817. private _material;
  135818. /** Custom ShaderMaterial Central to the System*/
  135819. private _output;
  135820. /** Systems Time Ticker*/
  135821. private _time;
  135822. /**
  135823. * Creates a new SpriteMap
  135824. * @param name defines the SpriteMaps Name
  135825. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135826. * @param spriteSheet is the Texture that the Sprites are on.
  135827. * @param options a basic deployment configuration
  135828. * @param scene The Scene that the map is deployed on
  135829. */
  135830. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135831. /**
  135832. * Returns tileID location
  135833. * @returns Vector2 the cell position ID
  135834. */
  135835. getTileID(): Vector2;
  135836. /**
  135837. * Gets the UV location of the mouse over the SpriteMap.
  135838. * @returns Vector2 the UV position of the mouse interaction
  135839. */
  135840. getMousePosition(): Vector2;
  135841. /**
  135842. * Creates the "frame" texture Buffer
  135843. * -------------------------------------
  135844. * Structure of frames
  135845. * "filename": "Falling-Water-2.png",
  135846. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135847. * "rotated": true,
  135848. * "trimmed": true,
  135849. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135850. * "sourceSize": {"w":32,"h":32}
  135851. * @returns RawTexture of the frameMap
  135852. */
  135853. private _createFrameBuffer;
  135854. /**
  135855. * Creates the tileMap texture Buffer
  135856. * @param buffer normally and array of numbers, or a false to generate from scratch
  135857. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135858. * @returns RawTexture of the tileMap
  135859. */
  135860. private _createTileBuffer;
  135861. /**
  135862. * Modifies the data of the tileMaps
  135863. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135864. * @param pos is the iVector2 Coordinates of the Tile
  135865. * @param tile The SpriteIndex of the new Tile
  135866. */
  135867. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135868. /**
  135869. * Creates the animationMap texture Buffer
  135870. * @param buffer normally and array of numbers, or a false to generate from scratch
  135871. * @returns RawTexture of the animationMap
  135872. */
  135873. private _createTileAnimationBuffer;
  135874. /**
  135875. * Modifies the data of the animationMap
  135876. * @param cellID is the Index of the Sprite
  135877. * @param _frame is the target Animation frame
  135878. * @param toCell is the Target Index of the next frame of the animation
  135879. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135880. * @param speed is a global scalar of the time variable on the map.
  135881. */
  135882. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135883. /**
  135884. * Exports the .tilemaps file
  135885. */
  135886. saveTileMaps(): void;
  135887. /**
  135888. * Imports the .tilemaps file
  135889. * @param url of the .tilemaps file
  135890. */
  135891. loadTileMaps(url: string): void;
  135892. /**
  135893. * Release associated resources
  135894. */
  135895. dispose(): void;
  135896. }
  135897. }
  135898. declare module BABYLON {
  135899. /**
  135900. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135901. * @see http://doc.babylonjs.com/babylon101/sprites
  135902. */
  135903. export class SpritePackedManager extends SpriteManager {
  135904. /** defines the packed manager's name */
  135905. name: string;
  135906. /**
  135907. * Creates a new sprite manager from a packed sprite sheet
  135908. * @param name defines the manager's name
  135909. * @param imgUrl defines the sprite sheet url
  135910. * @param capacity defines the maximum allowed number of sprites
  135911. * @param scene defines the hosting scene
  135912. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135913. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135914. * @param samplingMode defines the smapling mode to use with spritesheet
  135915. * @param fromPacked set to true; do not alter
  135916. */
  135917. constructor(
  135918. /** defines the packed manager's name */
  135919. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135920. }
  135921. }
  135922. declare module BABYLON {
  135923. /**
  135924. * Defines the list of states available for a task inside a AssetsManager
  135925. */
  135926. export enum AssetTaskState {
  135927. /**
  135928. * Initialization
  135929. */
  135930. INIT = 0,
  135931. /**
  135932. * Running
  135933. */
  135934. RUNNING = 1,
  135935. /**
  135936. * Done
  135937. */
  135938. DONE = 2,
  135939. /**
  135940. * Error
  135941. */
  135942. ERROR = 3
  135943. }
  135944. /**
  135945. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135946. */
  135947. export abstract class AbstractAssetTask {
  135948. /**
  135949. * Task name
  135950. */ name: string;
  135951. /**
  135952. * Callback called when the task is successful
  135953. */
  135954. onSuccess: (task: any) => void;
  135955. /**
  135956. * Callback called when the task is not successful
  135957. */
  135958. onError: (task: any, message?: string, exception?: any) => void;
  135959. /**
  135960. * Creates a new AssetsManager
  135961. * @param name defines the name of the task
  135962. */
  135963. constructor(
  135964. /**
  135965. * Task name
  135966. */ name: string);
  135967. private _isCompleted;
  135968. private _taskState;
  135969. private _errorObject;
  135970. /**
  135971. * Get if the task is completed
  135972. */
  135973. get isCompleted(): boolean;
  135974. /**
  135975. * Gets the current state of the task
  135976. */
  135977. get taskState(): AssetTaskState;
  135978. /**
  135979. * Gets the current error object (if task is in error)
  135980. */
  135981. get errorObject(): {
  135982. message?: string;
  135983. exception?: any;
  135984. };
  135985. /**
  135986. * Internal only
  135987. * @hidden
  135988. */
  135989. _setErrorObject(message?: string, exception?: any): void;
  135990. /**
  135991. * Execute the current task
  135992. * @param scene defines the scene where you want your assets to be loaded
  135993. * @param onSuccess is a callback called when the task is successfully executed
  135994. * @param onError is a callback called if an error occurs
  135995. */
  135996. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135997. /**
  135998. * Execute the current task
  135999. * @param scene defines the scene where you want your assets to be loaded
  136000. * @param onSuccess is a callback called when the task is successfully executed
  136001. * @param onError is a callback called if an error occurs
  136002. */
  136003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136004. /**
  136005. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  136006. * This can be used with failed tasks that have the reason for failure fixed.
  136007. */
  136008. reset(): void;
  136009. private onErrorCallback;
  136010. private onDoneCallback;
  136011. }
  136012. /**
  136013. * Define the interface used by progress events raised during assets loading
  136014. */
  136015. export interface IAssetsProgressEvent {
  136016. /**
  136017. * Defines the number of remaining tasks to process
  136018. */
  136019. remainingCount: number;
  136020. /**
  136021. * Defines the total number of tasks
  136022. */
  136023. totalCount: number;
  136024. /**
  136025. * Defines the task that was just processed
  136026. */
  136027. task: AbstractAssetTask;
  136028. }
  136029. /**
  136030. * Class used to share progress information about assets loading
  136031. */
  136032. export class AssetsProgressEvent implements IAssetsProgressEvent {
  136033. /**
  136034. * Defines the number of remaining tasks to process
  136035. */
  136036. remainingCount: number;
  136037. /**
  136038. * Defines the total number of tasks
  136039. */
  136040. totalCount: number;
  136041. /**
  136042. * Defines the task that was just processed
  136043. */
  136044. task: AbstractAssetTask;
  136045. /**
  136046. * Creates a AssetsProgressEvent
  136047. * @param remainingCount defines the number of remaining tasks to process
  136048. * @param totalCount defines the total number of tasks
  136049. * @param task defines the task that was just processed
  136050. */
  136051. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  136052. }
  136053. /**
  136054. * Define a task used by AssetsManager to load meshes
  136055. */
  136056. export class MeshAssetTask extends AbstractAssetTask {
  136057. /**
  136058. * Defines the name of the task
  136059. */
  136060. name: string;
  136061. /**
  136062. * Defines the list of mesh's names you want to load
  136063. */
  136064. meshesNames: any;
  136065. /**
  136066. * Defines the root url to use as a base to load your meshes and associated resources
  136067. */
  136068. rootUrl: string;
  136069. /**
  136070. * Defines the filename of the scene to load from
  136071. */
  136072. sceneFilename: string;
  136073. /**
  136074. * Gets the list of loaded meshes
  136075. */
  136076. loadedMeshes: Array<AbstractMesh>;
  136077. /**
  136078. * Gets the list of loaded particle systems
  136079. */
  136080. loadedParticleSystems: Array<IParticleSystem>;
  136081. /**
  136082. * Gets the list of loaded skeletons
  136083. */
  136084. loadedSkeletons: Array<Skeleton>;
  136085. /**
  136086. * Gets the list of loaded animation groups
  136087. */
  136088. loadedAnimationGroups: Array<AnimationGroup>;
  136089. /**
  136090. * Callback called when the task is successful
  136091. */
  136092. onSuccess: (task: MeshAssetTask) => void;
  136093. /**
  136094. * Callback called when the task is successful
  136095. */
  136096. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  136097. /**
  136098. * Creates a new MeshAssetTask
  136099. * @param name defines the name of the task
  136100. * @param meshesNames defines the list of mesh's names you want to load
  136101. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  136102. * @param sceneFilename defines the filename of the scene to load from
  136103. */
  136104. constructor(
  136105. /**
  136106. * Defines the name of the task
  136107. */
  136108. name: string,
  136109. /**
  136110. * Defines the list of mesh's names you want to load
  136111. */
  136112. meshesNames: any,
  136113. /**
  136114. * Defines the root url to use as a base to load your meshes and associated resources
  136115. */
  136116. rootUrl: string,
  136117. /**
  136118. * Defines the filename of the scene to load from
  136119. */
  136120. sceneFilename: string);
  136121. /**
  136122. * Execute the current task
  136123. * @param scene defines the scene where you want your assets to be loaded
  136124. * @param onSuccess is a callback called when the task is successfully executed
  136125. * @param onError is a callback called if an error occurs
  136126. */
  136127. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136128. }
  136129. /**
  136130. * Define a task used by AssetsManager to load text content
  136131. */
  136132. export class TextFileAssetTask extends AbstractAssetTask {
  136133. /**
  136134. * Defines the name of the task
  136135. */
  136136. name: string;
  136137. /**
  136138. * Defines the location of the file to load
  136139. */
  136140. url: string;
  136141. /**
  136142. * Gets the loaded text string
  136143. */
  136144. text: string;
  136145. /**
  136146. * Callback called when the task is successful
  136147. */
  136148. onSuccess: (task: TextFileAssetTask) => void;
  136149. /**
  136150. * Callback called when the task is successful
  136151. */
  136152. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  136153. /**
  136154. * Creates a new TextFileAssetTask object
  136155. * @param name defines the name of the task
  136156. * @param url defines the location of the file to load
  136157. */
  136158. constructor(
  136159. /**
  136160. * Defines the name of the task
  136161. */
  136162. name: string,
  136163. /**
  136164. * Defines the location of the file to load
  136165. */
  136166. url: string);
  136167. /**
  136168. * Execute the current task
  136169. * @param scene defines the scene where you want your assets to be loaded
  136170. * @param onSuccess is a callback called when the task is successfully executed
  136171. * @param onError is a callback called if an error occurs
  136172. */
  136173. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136174. }
  136175. /**
  136176. * Define a task used by AssetsManager to load binary data
  136177. */
  136178. export class BinaryFileAssetTask extends AbstractAssetTask {
  136179. /**
  136180. * Defines the name of the task
  136181. */
  136182. name: string;
  136183. /**
  136184. * Defines the location of the file to load
  136185. */
  136186. url: string;
  136187. /**
  136188. * Gets the lodaded data (as an array buffer)
  136189. */
  136190. data: ArrayBuffer;
  136191. /**
  136192. * Callback called when the task is successful
  136193. */
  136194. onSuccess: (task: BinaryFileAssetTask) => void;
  136195. /**
  136196. * Callback called when the task is successful
  136197. */
  136198. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  136199. /**
  136200. * Creates a new BinaryFileAssetTask object
  136201. * @param name defines the name of the new task
  136202. * @param url defines the location of the file to load
  136203. */
  136204. constructor(
  136205. /**
  136206. * Defines the name of the task
  136207. */
  136208. name: string,
  136209. /**
  136210. * Defines the location of the file to load
  136211. */
  136212. url: string);
  136213. /**
  136214. * Execute the current task
  136215. * @param scene defines the scene where you want your assets to be loaded
  136216. * @param onSuccess is a callback called when the task is successfully executed
  136217. * @param onError is a callback called if an error occurs
  136218. */
  136219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136220. }
  136221. /**
  136222. * Define a task used by AssetsManager to load images
  136223. */
  136224. export class ImageAssetTask extends AbstractAssetTask {
  136225. /**
  136226. * Defines the name of the task
  136227. */
  136228. name: string;
  136229. /**
  136230. * Defines the location of the image to load
  136231. */
  136232. url: string;
  136233. /**
  136234. * Gets the loaded images
  136235. */
  136236. image: HTMLImageElement;
  136237. /**
  136238. * Callback called when the task is successful
  136239. */
  136240. onSuccess: (task: ImageAssetTask) => void;
  136241. /**
  136242. * Callback called when the task is successful
  136243. */
  136244. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136245. /**
  136246. * Creates a new ImageAssetTask
  136247. * @param name defines the name of the task
  136248. * @param url defines the location of the image to load
  136249. */
  136250. constructor(
  136251. /**
  136252. * Defines the name of the task
  136253. */
  136254. name: string,
  136255. /**
  136256. * Defines the location of the image to load
  136257. */
  136258. url: string);
  136259. /**
  136260. * Execute the current task
  136261. * @param scene defines the scene where you want your assets to be loaded
  136262. * @param onSuccess is a callback called when the task is successfully executed
  136263. * @param onError is a callback called if an error occurs
  136264. */
  136265. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136266. }
  136267. /**
  136268. * Defines the interface used by texture loading tasks
  136269. */
  136270. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136271. /**
  136272. * Gets the loaded texture
  136273. */
  136274. texture: TEX;
  136275. }
  136276. /**
  136277. * Define a task used by AssetsManager to load 2D textures
  136278. */
  136279. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136280. /**
  136281. * Defines the name of the task
  136282. */
  136283. name: string;
  136284. /**
  136285. * Defines the location of the file to load
  136286. */
  136287. url: string;
  136288. /**
  136289. * Defines if mipmap should not be generated (default is false)
  136290. */
  136291. noMipmap?: boolean | undefined;
  136292. /**
  136293. * Defines if texture must be inverted on Y axis (default is false)
  136294. */
  136295. invertY?: boolean | undefined;
  136296. /**
  136297. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136298. */
  136299. samplingMode: number;
  136300. /**
  136301. * Gets the loaded texture
  136302. */
  136303. texture: Texture;
  136304. /**
  136305. * Callback called when the task is successful
  136306. */
  136307. onSuccess: (task: TextureAssetTask) => void;
  136308. /**
  136309. * Callback called when the task is successful
  136310. */
  136311. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136312. /**
  136313. * Creates a new TextureAssetTask object
  136314. * @param name defines the name of the task
  136315. * @param url defines the location of the file to load
  136316. * @param noMipmap defines if mipmap should not be generated (default is false)
  136317. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136318. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136319. */
  136320. constructor(
  136321. /**
  136322. * Defines the name of the task
  136323. */
  136324. name: string,
  136325. /**
  136326. * Defines the location of the file to load
  136327. */
  136328. url: string,
  136329. /**
  136330. * Defines if mipmap should not be generated (default is false)
  136331. */
  136332. noMipmap?: boolean | undefined,
  136333. /**
  136334. * Defines if texture must be inverted on Y axis (default is false)
  136335. */
  136336. invertY?: boolean | undefined,
  136337. /**
  136338. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136339. */
  136340. samplingMode?: number);
  136341. /**
  136342. * Execute the current task
  136343. * @param scene defines the scene where you want your assets to be loaded
  136344. * @param onSuccess is a callback called when the task is successfully executed
  136345. * @param onError is a callback called if an error occurs
  136346. */
  136347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136348. }
  136349. /**
  136350. * Define a task used by AssetsManager to load cube textures
  136351. */
  136352. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136353. /**
  136354. * Defines the name of the task
  136355. */
  136356. name: string;
  136357. /**
  136358. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136359. */
  136360. url: string;
  136361. /**
  136362. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136363. */
  136364. extensions?: string[] | undefined;
  136365. /**
  136366. * Defines if mipmaps should not be generated (default is false)
  136367. */
  136368. noMipmap?: boolean | undefined;
  136369. /**
  136370. * Defines the explicit list of files (undefined by default)
  136371. */
  136372. files?: string[] | undefined;
  136373. /**
  136374. * Gets the loaded texture
  136375. */
  136376. texture: CubeTexture;
  136377. /**
  136378. * Callback called when the task is successful
  136379. */
  136380. onSuccess: (task: CubeTextureAssetTask) => void;
  136381. /**
  136382. * Callback called when the task is successful
  136383. */
  136384. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136385. /**
  136386. * Creates a new CubeTextureAssetTask
  136387. * @param name defines the name of the task
  136388. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136389. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136390. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136391. * @param files defines the explicit list of files (undefined by default)
  136392. */
  136393. constructor(
  136394. /**
  136395. * Defines the name of the task
  136396. */
  136397. name: string,
  136398. /**
  136399. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136400. */
  136401. url: string,
  136402. /**
  136403. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136404. */
  136405. extensions?: string[] | undefined,
  136406. /**
  136407. * Defines if mipmaps should not be generated (default is false)
  136408. */
  136409. noMipmap?: boolean | undefined,
  136410. /**
  136411. * Defines the explicit list of files (undefined by default)
  136412. */
  136413. files?: string[] | undefined);
  136414. /**
  136415. * Execute the current task
  136416. * @param scene defines the scene where you want your assets to be loaded
  136417. * @param onSuccess is a callback called when the task is successfully executed
  136418. * @param onError is a callback called if an error occurs
  136419. */
  136420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136421. }
  136422. /**
  136423. * Define a task used by AssetsManager to load HDR cube textures
  136424. */
  136425. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136426. /**
  136427. * Defines the name of the task
  136428. */
  136429. name: string;
  136430. /**
  136431. * Defines the location of the file to load
  136432. */
  136433. url: string;
  136434. /**
  136435. * Defines the desired size (the more it increases the longer the generation will be)
  136436. */
  136437. size: number;
  136438. /**
  136439. * Defines if mipmaps should not be generated (default is false)
  136440. */
  136441. noMipmap: boolean;
  136442. /**
  136443. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136444. */
  136445. generateHarmonics: boolean;
  136446. /**
  136447. * 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)
  136448. */
  136449. gammaSpace: boolean;
  136450. /**
  136451. * Internal Use Only
  136452. */
  136453. reserved: boolean;
  136454. /**
  136455. * Gets the loaded texture
  136456. */
  136457. texture: HDRCubeTexture;
  136458. /**
  136459. * Callback called when the task is successful
  136460. */
  136461. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136462. /**
  136463. * Callback called when the task is successful
  136464. */
  136465. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136466. /**
  136467. * Creates a new HDRCubeTextureAssetTask object
  136468. * @param name defines the name of the task
  136469. * @param url defines the location of the file to load
  136470. * @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.
  136471. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136472. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136473. * @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)
  136474. * @param reserved Internal use only
  136475. */
  136476. constructor(
  136477. /**
  136478. * Defines the name of the task
  136479. */
  136480. name: string,
  136481. /**
  136482. * Defines the location of the file to load
  136483. */
  136484. url: string,
  136485. /**
  136486. * Defines the desired size (the more it increases the longer the generation will be)
  136487. */
  136488. size: number,
  136489. /**
  136490. * Defines if mipmaps should not be generated (default is false)
  136491. */
  136492. noMipmap?: boolean,
  136493. /**
  136494. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136495. */
  136496. generateHarmonics?: boolean,
  136497. /**
  136498. * 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)
  136499. */
  136500. gammaSpace?: boolean,
  136501. /**
  136502. * Internal Use Only
  136503. */
  136504. reserved?: boolean);
  136505. /**
  136506. * Execute the current task
  136507. * @param scene defines the scene where you want your assets to be loaded
  136508. * @param onSuccess is a callback called when the task is successfully executed
  136509. * @param onError is a callback called if an error occurs
  136510. */
  136511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136512. }
  136513. /**
  136514. * Define a task used by AssetsManager to load Equirectangular cube textures
  136515. */
  136516. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136517. /**
  136518. * Defines the name of the task
  136519. */
  136520. name: string;
  136521. /**
  136522. * Defines the location of the file to load
  136523. */
  136524. url: string;
  136525. /**
  136526. * Defines the desired size (the more it increases the longer the generation will be)
  136527. */
  136528. size: number;
  136529. /**
  136530. * Defines if mipmaps should not be generated (default is false)
  136531. */
  136532. noMipmap: boolean;
  136533. /**
  136534. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136535. * but the standard material would require them in Gamma space) (default is true)
  136536. */
  136537. gammaSpace: boolean;
  136538. /**
  136539. * Gets the loaded texture
  136540. */
  136541. texture: EquiRectangularCubeTexture;
  136542. /**
  136543. * Callback called when the task is successful
  136544. */
  136545. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136546. /**
  136547. * Callback called when the task is successful
  136548. */
  136549. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136550. /**
  136551. * Creates a new EquiRectangularCubeTextureAssetTask object
  136552. * @param name defines the name of the task
  136553. * @param url defines the location of the file to load
  136554. * @param size defines the desired size (the more it increases the longer the generation will be)
  136555. * If the size is omitted this implies you are using a preprocessed cubemap.
  136556. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136557. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136558. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136559. * (default is true)
  136560. */
  136561. constructor(
  136562. /**
  136563. * Defines the name of the task
  136564. */
  136565. name: string,
  136566. /**
  136567. * Defines the location of the file to load
  136568. */
  136569. url: string,
  136570. /**
  136571. * Defines the desired size (the more it increases the longer the generation will be)
  136572. */
  136573. size: number,
  136574. /**
  136575. * Defines if mipmaps should not be generated (default is false)
  136576. */
  136577. noMipmap?: boolean,
  136578. /**
  136579. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136580. * but the standard material would require them in Gamma space) (default is true)
  136581. */
  136582. gammaSpace?: boolean);
  136583. /**
  136584. * Execute the current task
  136585. * @param scene defines the scene where you want your assets to be loaded
  136586. * @param onSuccess is a callback called when the task is successfully executed
  136587. * @param onError is a callback called if an error occurs
  136588. */
  136589. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136590. }
  136591. /**
  136592. * This class can be used to easily import assets into a scene
  136593. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136594. */
  136595. export class AssetsManager {
  136596. private _scene;
  136597. private _isLoading;
  136598. protected _tasks: AbstractAssetTask[];
  136599. protected _waitingTasksCount: number;
  136600. protected _totalTasksCount: number;
  136601. /**
  136602. * Callback called when all tasks are processed
  136603. */
  136604. onFinish: (tasks: AbstractAssetTask[]) => void;
  136605. /**
  136606. * Callback called when a task is successful
  136607. */
  136608. onTaskSuccess: (task: AbstractAssetTask) => void;
  136609. /**
  136610. * Callback called when a task had an error
  136611. */
  136612. onTaskError: (task: AbstractAssetTask) => void;
  136613. /**
  136614. * Callback called when a task is done (whatever the result is)
  136615. */
  136616. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136617. /**
  136618. * Observable called when all tasks are processed
  136619. */
  136620. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136621. /**
  136622. * Observable called when a task had an error
  136623. */
  136624. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136625. /**
  136626. * Observable called when all tasks were executed
  136627. */
  136628. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136629. /**
  136630. * Observable called when a task is done (whatever the result is)
  136631. */
  136632. onProgressObservable: Observable<IAssetsProgressEvent>;
  136633. /**
  136634. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136636. */
  136637. useDefaultLoadingScreen: boolean;
  136638. /**
  136639. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136640. * when all assets have been downloaded.
  136641. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136642. */
  136643. autoHideLoadingUI: boolean;
  136644. /**
  136645. * Creates a new AssetsManager
  136646. * @param scene defines the scene to work on
  136647. */
  136648. constructor(scene: Scene);
  136649. /**
  136650. * Add a MeshAssetTask to the list of active tasks
  136651. * @param taskName defines the name of the new task
  136652. * @param meshesNames defines the name of meshes to load
  136653. * @param rootUrl defines the root url to use to locate files
  136654. * @param sceneFilename defines the filename of the scene file
  136655. * @returns a new MeshAssetTask object
  136656. */
  136657. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136658. /**
  136659. * Add a TextFileAssetTask to the list of active tasks
  136660. * @param taskName defines the name of the new task
  136661. * @param url defines the url of the file to load
  136662. * @returns a new TextFileAssetTask object
  136663. */
  136664. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136665. /**
  136666. * Add a BinaryFileAssetTask to the list of active tasks
  136667. * @param taskName defines the name of the new task
  136668. * @param url defines the url of the file to load
  136669. * @returns a new BinaryFileAssetTask object
  136670. */
  136671. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136672. /**
  136673. * Add a ImageAssetTask to the list of active tasks
  136674. * @param taskName defines the name of the new task
  136675. * @param url defines the url of the file to load
  136676. * @returns a new ImageAssetTask object
  136677. */
  136678. addImageTask(taskName: string, url: string): ImageAssetTask;
  136679. /**
  136680. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  136684. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136685. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136686. * @returns a new TextureAssetTask object
  136687. */
  136688. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136689. /**
  136690. * Add a CubeTextureAssetTask to the list of active tasks
  136691. * @param taskName defines the name of the new task
  136692. * @param url defines the url of the file to load
  136693. * @param extensions defines the extension to use to load the cube map (can be null)
  136694. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136695. * @param files defines the list of files to load (can be null)
  136696. * @returns a new CubeTextureAssetTask object
  136697. */
  136698. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136699. /**
  136700. *
  136701. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136702. * @param taskName defines the name of the new task
  136703. * @param url defines the url of the file to load
  136704. * @param size defines the size you want for the cubemap (can be null)
  136705. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136706. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136707. * @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)
  136708. * @param reserved Internal use only
  136709. * @returns a new HDRCubeTextureAssetTask object
  136710. */
  136711. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136712. /**
  136713. *
  136714. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136715. * @param taskName defines the name of the new task
  136716. * @param url defines the url of the file to load
  136717. * @param size defines the size you want for the cubemap (can be null)
  136718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136719. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136720. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136721. * @returns a new EquiRectangularCubeTextureAssetTask object
  136722. */
  136723. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136724. /**
  136725. * Remove a task from the assets manager.
  136726. * @param task the task to remove
  136727. */
  136728. removeTask(task: AbstractAssetTask): void;
  136729. private _decreaseWaitingTasksCount;
  136730. private _runTask;
  136731. /**
  136732. * Reset the AssetsManager and remove all tasks
  136733. * @return the current instance of the AssetsManager
  136734. */
  136735. reset(): AssetsManager;
  136736. /**
  136737. * Start the loading process
  136738. * @return the current instance of the AssetsManager
  136739. */
  136740. load(): AssetsManager;
  136741. /**
  136742. * Start the loading process as an async operation
  136743. * @return a promise returning the list of failed tasks
  136744. */
  136745. loadAsync(): Promise<void>;
  136746. }
  136747. }
  136748. declare module BABYLON {
  136749. /**
  136750. * Wrapper class for promise with external resolve and reject.
  136751. */
  136752. export class Deferred<T> {
  136753. /**
  136754. * The promise associated with this deferred object.
  136755. */
  136756. readonly promise: Promise<T>;
  136757. private _resolve;
  136758. private _reject;
  136759. /**
  136760. * The resolve method of the promise associated with this deferred object.
  136761. */
  136762. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136763. /**
  136764. * The reject method of the promise associated with this deferred object.
  136765. */
  136766. get reject(): (reason?: any) => void;
  136767. /**
  136768. * Constructor for this deferred object.
  136769. */
  136770. constructor();
  136771. }
  136772. }
  136773. declare module BABYLON {
  136774. /**
  136775. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136776. */
  136777. export class MeshExploder {
  136778. private _centerMesh;
  136779. private _meshes;
  136780. private _meshesOrigins;
  136781. private _toCenterVectors;
  136782. private _scaledDirection;
  136783. private _newPosition;
  136784. private _centerPosition;
  136785. /**
  136786. * Explodes meshes from a center mesh.
  136787. * @param meshes The meshes to explode.
  136788. * @param centerMesh The mesh to be center of explosion.
  136789. */
  136790. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136791. private _setCenterMesh;
  136792. /**
  136793. * Get class name
  136794. * @returns "MeshExploder"
  136795. */
  136796. getClassName(): string;
  136797. /**
  136798. * "Exploded meshes"
  136799. * @returns Array of meshes with the centerMesh at index 0.
  136800. */
  136801. getMeshes(): Array<Mesh>;
  136802. /**
  136803. * Explodes meshes giving a specific direction
  136804. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136805. */
  136806. explode(direction?: number): void;
  136807. }
  136808. }
  136809. declare module BABYLON {
  136810. /**
  136811. * Class used to help managing file picking and drag'n'drop
  136812. */
  136813. export class FilesInput {
  136814. /**
  136815. * List of files ready to be loaded
  136816. */
  136817. static get FilesToLoad(): {
  136818. [key: string]: File;
  136819. };
  136820. /**
  136821. * Callback called when a file is processed
  136822. */
  136823. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136824. private _engine;
  136825. private _currentScene;
  136826. private _sceneLoadedCallback;
  136827. private _progressCallback;
  136828. private _additionalRenderLoopLogicCallback;
  136829. private _textureLoadingCallback;
  136830. private _startingProcessingFilesCallback;
  136831. private _onReloadCallback;
  136832. private _errorCallback;
  136833. private _elementToMonitor;
  136834. private _sceneFileToLoad;
  136835. private _filesToLoad;
  136836. /**
  136837. * Creates a new FilesInput
  136838. * @param engine defines the rendering engine
  136839. * @param scene defines the hosting scene
  136840. * @param sceneLoadedCallback callback called when scene is loaded
  136841. * @param progressCallback callback called to track progress
  136842. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136843. * @param textureLoadingCallback callback called when a texture is loading
  136844. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136845. * @param onReloadCallback callback called when a reload is requested
  136846. * @param errorCallback callback call if an error occurs
  136847. */
  136848. 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);
  136849. private _dragEnterHandler;
  136850. private _dragOverHandler;
  136851. private _dropHandler;
  136852. /**
  136853. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136854. * @param elementToMonitor defines the DOM element to track
  136855. */
  136856. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136857. /**
  136858. * Release all associated resources
  136859. */
  136860. dispose(): void;
  136861. private renderFunction;
  136862. private drag;
  136863. private drop;
  136864. private _traverseFolder;
  136865. private _processFiles;
  136866. /**
  136867. * Load files from a drop event
  136868. * @param event defines the drop event to use as source
  136869. */
  136870. loadFiles(event: any): void;
  136871. private _processReload;
  136872. /**
  136873. * Reload the current scene from the loaded files
  136874. */
  136875. reload(): void;
  136876. }
  136877. }
  136878. declare module BABYLON {
  136879. /**
  136880. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136882. */
  136883. export class SceneOptimization {
  136884. /**
  136885. * Defines the priority of this optimization (0 by default which means first in the list)
  136886. */
  136887. priority: number;
  136888. /**
  136889. * Gets a string describing the action executed by the current optimization
  136890. * @returns description string
  136891. */
  136892. getDescription(): string;
  136893. /**
  136894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136895. * @param scene defines the current scene where to apply this optimization
  136896. * @param optimizer defines the current optimizer
  136897. * @returns true if everything that can be done was applied
  136898. */
  136899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136900. /**
  136901. * Creates the SceneOptimization object
  136902. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136903. * @param desc defines the description associated with the optimization
  136904. */
  136905. constructor(
  136906. /**
  136907. * Defines the priority of this optimization (0 by default which means first in the list)
  136908. */
  136909. priority?: number);
  136910. }
  136911. /**
  136912. * Defines an optimization used to reduce the size of render target textures
  136913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136914. */
  136915. export class TextureOptimization extends SceneOptimization {
  136916. /**
  136917. * Defines the priority of this optimization (0 by default which means first in the list)
  136918. */
  136919. priority: number;
  136920. /**
  136921. * 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
  136922. */
  136923. maximumSize: number;
  136924. /**
  136925. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136926. */
  136927. step: number;
  136928. /**
  136929. * Gets a string describing the action executed by the current optimization
  136930. * @returns description string
  136931. */
  136932. getDescription(): string;
  136933. /**
  136934. * Creates the TextureOptimization object
  136935. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136936. * @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
  136937. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136938. */
  136939. constructor(
  136940. /**
  136941. * Defines the priority of this optimization (0 by default which means first in the list)
  136942. */
  136943. priority?: number,
  136944. /**
  136945. * 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
  136946. */
  136947. maximumSize?: number,
  136948. /**
  136949. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136950. */
  136951. step?: number);
  136952. /**
  136953. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136954. * @param scene defines the current scene where to apply this optimization
  136955. * @param optimizer defines the current optimizer
  136956. * @returns true if everything that can be done was applied
  136957. */
  136958. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136959. }
  136960. /**
  136961. * Defines an optimization used to increase or decrease the rendering resolution
  136962. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136963. */
  136964. export class HardwareScalingOptimization extends SceneOptimization {
  136965. /**
  136966. * Defines the priority of this optimization (0 by default which means first in the list)
  136967. */
  136968. priority: number;
  136969. /**
  136970. * Defines the maximum scale to use (2 by default)
  136971. */
  136972. maximumScale: number;
  136973. /**
  136974. * Defines the step to use between two passes (0.5 by default)
  136975. */
  136976. step: number;
  136977. private _currentScale;
  136978. private _directionOffset;
  136979. /**
  136980. * Gets a string describing the action executed by the current optimization
  136981. * @return description string
  136982. */
  136983. getDescription(): string;
  136984. /**
  136985. * Creates the HardwareScalingOptimization object
  136986. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136987. * @param maximumScale defines the maximum scale to use (2 by default)
  136988. * @param step defines the step to use between two passes (0.5 by default)
  136989. */
  136990. constructor(
  136991. /**
  136992. * Defines the priority of this optimization (0 by default which means first in the list)
  136993. */
  136994. priority?: number,
  136995. /**
  136996. * Defines the maximum scale to use (2 by default)
  136997. */
  136998. maximumScale?: number,
  136999. /**
  137000. * Defines the step to use between two passes (0.5 by default)
  137001. */
  137002. step?: number);
  137003. /**
  137004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137005. * @param scene defines the current scene where to apply this optimization
  137006. * @param optimizer defines the current optimizer
  137007. * @returns true if everything that can be done was applied
  137008. */
  137009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137010. }
  137011. /**
  137012. * Defines an optimization used to remove shadows
  137013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137014. */
  137015. export class ShadowsOptimization extends SceneOptimization {
  137016. /**
  137017. * Gets a string describing the action executed by the current optimization
  137018. * @return description string
  137019. */
  137020. getDescription(): string;
  137021. /**
  137022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137023. * @param scene defines the current scene where to apply this optimization
  137024. * @param optimizer defines the current optimizer
  137025. * @returns true if everything that can be done was applied
  137026. */
  137027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137028. }
  137029. /**
  137030. * Defines an optimization used to turn post-processes off
  137031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137032. */
  137033. export class PostProcessesOptimization extends SceneOptimization {
  137034. /**
  137035. * Gets a string describing the action executed by the current optimization
  137036. * @return description string
  137037. */
  137038. getDescription(): string;
  137039. /**
  137040. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137041. * @param scene defines the current scene where to apply this optimization
  137042. * @param optimizer defines the current optimizer
  137043. * @returns true if everything that can be done was applied
  137044. */
  137045. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137046. }
  137047. /**
  137048. * Defines an optimization used to turn lens flares off
  137049. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137050. */
  137051. export class LensFlaresOptimization extends SceneOptimization {
  137052. /**
  137053. * Gets a string describing the action executed by the current optimization
  137054. * @return description string
  137055. */
  137056. getDescription(): string;
  137057. /**
  137058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137059. * @param scene defines the current scene where to apply this optimization
  137060. * @param optimizer defines the current optimizer
  137061. * @returns true if everything that can be done was applied
  137062. */
  137063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137064. }
  137065. /**
  137066. * Defines an optimization based on user defined callback.
  137067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137068. */
  137069. export class CustomOptimization extends SceneOptimization {
  137070. /**
  137071. * Callback called to apply the custom optimization.
  137072. */
  137073. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  137074. /**
  137075. * Callback called to get custom description
  137076. */
  137077. onGetDescription: () => string;
  137078. /**
  137079. * Gets a string describing the action executed by the current optimization
  137080. * @returns description string
  137081. */
  137082. getDescription(): string;
  137083. /**
  137084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137085. * @param scene defines the current scene where to apply this optimization
  137086. * @param optimizer defines the current optimizer
  137087. * @returns true if everything that can be done was applied
  137088. */
  137089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137090. }
  137091. /**
  137092. * Defines an optimization used to turn particles off
  137093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137094. */
  137095. export class ParticlesOptimization extends SceneOptimization {
  137096. /**
  137097. * Gets a string describing the action executed by the current optimization
  137098. * @return description string
  137099. */
  137100. getDescription(): string;
  137101. /**
  137102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137103. * @param scene defines the current scene where to apply this optimization
  137104. * @param optimizer defines the current optimizer
  137105. * @returns true if everything that can be done was applied
  137106. */
  137107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137108. }
  137109. /**
  137110. * Defines an optimization used to turn render targets off
  137111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137112. */
  137113. export class RenderTargetsOptimization extends SceneOptimization {
  137114. /**
  137115. * Gets a string describing the action executed by the current optimization
  137116. * @return description string
  137117. */
  137118. getDescription(): string;
  137119. /**
  137120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137121. * @param scene defines the current scene where to apply this optimization
  137122. * @param optimizer defines the current optimizer
  137123. * @returns true if everything that can be done was applied
  137124. */
  137125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137126. }
  137127. /**
  137128. * Defines an optimization used to merge meshes with compatible materials
  137129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137130. */
  137131. export class MergeMeshesOptimization extends SceneOptimization {
  137132. private static _UpdateSelectionTree;
  137133. /**
  137134. * Gets or sets a boolean which defines if optimization octree has to be updated
  137135. */
  137136. static get UpdateSelectionTree(): boolean;
  137137. /**
  137138. * Gets or sets a boolean which defines if optimization octree has to be updated
  137139. */
  137140. static set UpdateSelectionTree(value: boolean);
  137141. /**
  137142. * Gets a string describing the action executed by the current optimization
  137143. * @return description string
  137144. */
  137145. getDescription(): string;
  137146. private _canBeMerged;
  137147. /**
  137148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137149. * @param scene defines the current scene where to apply this optimization
  137150. * @param optimizer defines the current optimizer
  137151. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  137152. * @returns true if everything that can be done was applied
  137153. */
  137154. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  137155. }
  137156. /**
  137157. * Defines a list of options used by SceneOptimizer
  137158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137159. */
  137160. export class SceneOptimizerOptions {
  137161. /**
  137162. * Defines the target frame rate to reach (60 by default)
  137163. */
  137164. targetFrameRate: number;
  137165. /**
  137166. * Defines the interval between two checkes (2000ms by default)
  137167. */
  137168. trackerDuration: number;
  137169. /**
  137170. * Gets the list of optimizations to apply
  137171. */
  137172. optimizations: SceneOptimization[];
  137173. /**
  137174. * Creates a new list of options used by SceneOptimizer
  137175. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  137176. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  137177. */
  137178. constructor(
  137179. /**
  137180. * Defines the target frame rate to reach (60 by default)
  137181. */
  137182. targetFrameRate?: number,
  137183. /**
  137184. * Defines the interval between two checkes (2000ms by default)
  137185. */
  137186. trackerDuration?: number);
  137187. /**
  137188. * Add a new optimization
  137189. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  137190. * @returns the current SceneOptimizerOptions
  137191. */
  137192. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  137193. /**
  137194. * Add a new custom optimization
  137195. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  137196. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  137197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  137198. * @returns the current SceneOptimizerOptions
  137199. */
  137200. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  137201. /**
  137202. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  137203. * @param targetFrameRate defines the target frame rate (60 by default)
  137204. * @returns a SceneOptimizerOptions object
  137205. */
  137206. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137207. /**
  137208. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  137209. * @param targetFrameRate defines the target frame rate (60 by default)
  137210. * @returns a SceneOptimizerOptions object
  137211. */
  137212. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137213. /**
  137214. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  137215. * @param targetFrameRate defines the target frame rate (60 by default)
  137216. * @returns a SceneOptimizerOptions object
  137217. */
  137218. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137219. }
  137220. /**
  137221. * Class used to run optimizations in order to reach a target frame rate
  137222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137223. */
  137224. export class SceneOptimizer implements IDisposable {
  137225. private _isRunning;
  137226. private _options;
  137227. private _scene;
  137228. private _currentPriorityLevel;
  137229. private _targetFrameRate;
  137230. private _trackerDuration;
  137231. private _currentFrameRate;
  137232. private _sceneDisposeObserver;
  137233. private _improvementMode;
  137234. /**
  137235. * Defines an observable called when the optimizer reaches the target frame rate
  137236. */
  137237. onSuccessObservable: Observable<SceneOptimizer>;
  137238. /**
  137239. * Defines an observable called when the optimizer enables an optimization
  137240. */
  137241. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137242. /**
  137243. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137244. */
  137245. onFailureObservable: Observable<SceneOptimizer>;
  137246. /**
  137247. * Gets a boolean indicating if the optimizer is in improvement mode
  137248. */
  137249. get isInImprovementMode(): boolean;
  137250. /**
  137251. * Gets the current priority level (0 at start)
  137252. */
  137253. get currentPriorityLevel(): number;
  137254. /**
  137255. * Gets the current frame rate checked by the SceneOptimizer
  137256. */
  137257. get currentFrameRate(): number;
  137258. /**
  137259. * Gets or sets the current target frame rate (60 by default)
  137260. */
  137261. get targetFrameRate(): number;
  137262. /**
  137263. * Gets or sets the current target frame rate (60 by default)
  137264. */
  137265. set targetFrameRate(value: number);
  137266. /**
  137267. * Gets or sets the current interval between two checks (every 2000ms by default)
  137268. */
  137269. get trackerDuration(): number;
  137270. /**
  137271. * Gets or sets the current interval between two checks (every 2000ms by default)
  137272. */
  137273. set trackerDuration(value: number);
  137274. /**
  137275. * Gets the list of active optimizations
  137276. */
  137277. get optimizations(): SceneOptimization[];
  137278. /**
  137279. * Creates a new SceneOptimizer
  137280. * @param scene defines the scene to work on
  137281. * @param options defines the options to use with the SceneOptimizer
  137282. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137283. * @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)
  137284. */
  137285. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137286. /**
  137287. * Stops the current optimizer
  137288. */
  137289. stop(): void;
  137290. /**
  137291. * Reset the optimizer to initial step (current priority level = 0)
  137292. */
  137293. reset(): void;
  137294. /**
  137295. * Start the optimizer. By default it will try to reach a specific framerate
  137296. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137297. */
  137298. start(): void;
  137299. private _checkCurrentState;
  137300. /**
  137301. * Release all resources
  137302. */
  137303. dispose(): void;
  137304. /**
  137305. * Helper function to create a SceneOptimizer with one single line of code
  137306. * @param scene defines the scene to work on
  137307. * @param options defines the options to use with the SceneOptimizer
  137308. * @param onSuccess defines a callback to call on success
  137309. * @param onFailure defines a callback to call on failure
  137310. * @returns the new SceneOptimizer object
  137311. */
  137312. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137313. }
  137314. }
  137315. declare module BABYLON {
  137316. /**
  137317. * Class used to serialize a scene into a string
  137318. */
  137319. export class SceneSerializer {
  137320. /**
  137321. * Clear cache used by a previous serialization
  137322. */
  137323. static ClearCache(): void;
  137324. /**
  137325. * Serialize a scene into a JSON compatible object
  137326. * @param scene defines the scene to serialize
  137327. * @returns a JSON compatible object
  137328. */
  137329. static Serialize(scene: Scene): any;
  137330. /**
  137331. * Serialize a mesh into a JSON compatible object
  137332. * @param toSerialize defines the mesh to serialize
  137333. * @param withParents defines if parents must be serialized as well
  137334. * @param withChildren defines if children must be serialized as well
  137335. * @returns a JSON compatible object
  137336. */
  137337. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137338. }
  137339. }
  137340. declare module BABYLON {
  137341. /**
  137342. * Class used to host texture specific utilities
  137343. */
  137344. export class TextureTools {
  137345. /**
  137346. * Uses the GPU to create a copy texture rescaled at a given size
  137347. * @param texture Texture to copy from
  137348. * @param width defines the desired width
  137349. * @param height defines the desired height
  137350. * @param useBilinearMode defines if bilinear mode has to be used
  137351. * @return the generated texture
  137352. */
  137353. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137354. }
  137355. }
  137356. declare module BABYLON {
  137357. /**
  137358. * This represents the different options available for the video capture.
  137359. */
  137360. export interface VideoRecorderOptions {
  137361. /** Defines the mime type of the video. */
  137362. mimeType: string;
  137363. /** Defines the FPS the video should be recorded at. */
  137364. fps: number;
  137365. /** Defines the chunk size for the recording data. */
  137366. recordChunckSize: number;
  137367. /** The audio tracks to attach to the recording. */
  137368. audioTracks?: MediaStreamTrack[];
  137369. }
  137370. /**
  137371. * This can help with recording videos from BabylonJS.
  137372. * This is based on the available WebRTC functionalities of the browser.
  137373. *
  137374. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137375. */
  137376. export class VideoRecorder {
  137377. private static readonly _defaultOptions;
  137378. /**
  137379. * Returns whether or not the VideoRecorder is available in your browser.
  137380. * @param engine Defines the Babylon Engine.
  137381. * @returns true if supported otherwise false.
  137382. */
  137383. static IsSupported(engine: Engine): boolean;
  137384. private readonly _options;
  137385. private _canvas;
  137386. private _mediaRecorder;
  137387. private _recordedChunks;
  137388. private _fileName;
  137389. private _resolve;
  137390. private _reject;
  137391. /**
  137392. * True when a recording is already in progress.
  137393. */
  137394. get isRecording(): boolean;
  137395. /**
  137396. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137397. * @param engine Defines the BabylonJS Engine you wish to record.
  137398. * @param options Defines options that can be used to customize the capture.
  137399. */
  137400. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137401. /**
  137402. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137403. */
  137404. stopRecording(): void;
  137405. /**
  137406. * Starts recording the canvas for a max duration specified in parameters.
  137407. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137408. * If null no automatic download will start and you can rely on the promise to get the data back.
  137409. * @param maxDuration Defines the maximum recording time in seconds.
  137410. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137411. * @return A promise callback at the end of the recording with the video data in Blob.
  137412. */
  137413. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137414. /**
  137415. * Releases internal resources used during the recording.
  137416. */
  137417. dispose(): void;
  137418. private _handleDataAvailable;
  137419. private _handleError;
  137420. private _handleStop;
  137421. }
  137422. }
  137423. declare module BABYLON {
  137424. /**
  137425. * Class containing a set of static utilities functions for screenshots
  137426. */
  137427. export class ScreenshotTools {
  137428. /**
  137429. * Captures a screenshot of the current rendering
  137430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137431. * @param engine defines the rendering engine
  137432. * @param camera defines the source camera
  137433. * @param size This parameter can be set to a single number or to an object with the
  137434. * following (optional) properties: precision, width, height. If a single number is passed,
  137435. * it will be used for both width and height. If an object is passed, the screenshot size
  137436. * will be derived from the parameters. The precision property is a multiplier allowing
  137437. * rendering at a higher or lower resolution
  137438. * @param successCallback defines the callback receives a single parameter which contains the
  137439. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137440. * src parameter of an <img> to display it
  137441. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137442. * Check your browser for supported MIME types
  137443. */
  137444. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137445. /**
  137446. * Captures a screenshot of the current rendering
  137447. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137448. * @param engine defines the rendering engine
  137449. * @param camera defines the source camera
  137450. * @param size This parameter can be set to a single number or to an object with the
  137451. * following (optional) properties: precision, width, height. If a single number is passed,
  137452. * it will be used for both width and height. If an object is passed, the screenshot size
  137453. * will be derived from the parameters. The precision property is a multiplier allowing
  137454. * rendering at a higher or lower resolution
  137455. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137456. * Check your browser for supported MIME types
  137457. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137458. * to the src parameter of an <img> to display it
  137459. */
  137460. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137461. /**
  137462. * Generates an image screenshot from the specified camera.
  137463. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137464. * @param engine The engine to use for rendering
  137465. * @param camera The camera to use for rendering
  137466. * @param size This parameter can be set to a single number or to an object with the
  137467. * following (optional) properties: precision, width, height. If a single number is passed,
  137468. * it will be used for both width and height. If an object is passed, the screenshot size
  137469. * will be derived from the parameters. The precision property is a multiplier allowing
  137470. * rendering at a higher or lower resolution
  137471. * @param successCallback The callback receives a single parameter which contains the
  137472. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137473. * src parameter of an <img> to display it
  137474. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137475. * Check your browser for supported MIME types
  137476. * @param samples Texture samples (default: 1)
  137477. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137478. * @param fileName A name for for the downloaded file.
  137479. */
  137480. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137481. /**
  137482. * Generates an image screenshot from the specified camera.
  137483. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137484. * @param engine The engine to use for rendering
  137485. * @param camera The camera to use for rendering
  137486. * @param size This parameter can be set to a single number or to an object with the
  137487. * following (optional) properties: precision, width, height. If a single number is passed,
  137488. * it will be used for both width and height. If an object is passed, the screenshot size
  137489. * will be derived from the parameters. The precision property is a multiplier allowing
  137490. * rendering at a higher or lower resolution
  137491. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137492. * Check your browser for supported MIME types
  137493. * @param samples Texture samples (default: 1)
  137494. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137495. * @param fileName A name for for the downloaded file.
  137496. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137497. * to the src parameter of an <img> to display it
  137498. */
  137499. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137500. /**
  137501. * Gets height and width for screenshot size
  137502. * @private
  137503. */
  137504. private static _getScreenshotSize;
  137505. }
  137506. }
  137507. declare module BABYLON {
  137508. /**
  137509. * Interface for a data buffer
  137510. */
  137511. export interface IDataBuffer {
  137512. /**
  137513. * Reads bytes from the data buffer.
  137514. * @param byteOffset The byte offset to read
  137515. * @param byteLength The byte length to read
  137516. * @returns A promise that resolves when the bytes are read
  137517. */
  137518. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137519. /**
  137520. * The byte length of the buffer.
  137521. */
  137522. readonly byteLength: number;
  137523. }
  137524. /**
  137525. * Utility class for reading from a data buffer
  137526. */
  137527. export class DataReader {
  137528. /**
  137529. * The data buffer associated with this data reader.
  137530. */
  137531. readonly buffer: IDataBuffer;
  137532. /**
  137533. * The current byte offset from the beginning of the data buffer.
  137534. */
  137535. byteOffset: number;
  137536. private _dataView;
  137537. private _dataByteOffset;
  137538. /**
  137539. * Constructor
  137540. * @param buffer The buffer to read
  137541. */
  137542. constructor(buffer: IDataBuffer);
  137543. /**
  137544. * Loads the given byte length.
  137545. * @param byteLength The byte length to load
  137546. * @returns A promise that resolves when the load is complete
  137547. */
  137548. loadAsync(byteLength: number): Promise<void>;
  137549. /**
  137550. * Read a unsigned 32-bit integer from the currently loaded data range.
  137551. * @returns The 32-bit integer read
  137552. */
  137553. readUint32(): number;
  137554. /**
  137555. * Read a byte array from the currently loaded data range.
  137556. * @param byteLength The byte length to read
  137557. * @returns The byte array read
  137558. */
  137559. readUint8Array(byteLength: number): Uint8Array;
  137560. /**
  137561. * Read a string from the currently loaded data range.
  137562. * @param byteLength The byte length to read
  137563. * @returns The string read
  137564. */
  137565. readString(byteLength: number): string;
  137566. /**
  137567. * Skips the given byte length the currently loaded data range.
  137568. * @param byteLength The byte length to skip
  137569. */
  137570. skipBytes(byteLength: number): void;
  137571. }
  137572. }
  137573. declare module BABYLON {
  137574. /**
  137575. * A cursor which tracks a point on a path
  137576. */
  137577. export class PathCursor {
  137578. private path;
  137579. /**
  137580. * Stores path cursor callbacks for when an onchange event is triggered
  137581. */
  137582. private _onchange;
  137583. /**
  137584. * The value of the path cursor
  137585. */
  137586. value: number;
  137587. /**
  137588. * The animation array of the path cursor
  137589. */
  137590. animations: Animation[];
  137591. /**
  137592. * Initializes the path cursor
  137593. * @param path The path to track
  137594. */
  137595. constructor(path: Path2);
  137596. /**
  137597. * Gets the cursor point on the path
  137598. * @returns A point on the path cursor at the cursor location
  137599. */
  137600. getPoint(): Vector3;
  137601. /**
  137602. * Moves the cursor ahead by the step amount
  137603. * @param step The amount to move the cursor forward
  137604. * @returns This path cursor
  137605. */
  137606. moveAhead(step?: number): PathCursor;
  137607. /**
  137608. * Moves the cursor behind by the step amount
  137609. * @param step The amount to move the cursor back
  137610. * @returns This path cursor
  137611. */
  137612. moveBack(step?: number): PathCursor;
  137613. /**
  137614. * Moves the cursor by the step amount
  137615. * If the step amount is greater than one, an exception is thrown
  137616. * @param step The amount to move the cursor
  137617. * @returns This path cursor
  137618. */
  137619. move(step: number): PathCursor;
  137620. /**
  137621. * Ensures that the value is limited between zero and one
  137622. * @returns This path cursor
  137623. */
  137624. private ensureLimits;
  137625. /**
  137626. * Runs onchange callbacks on change (used by the animation engine)
  137627. * @returns This path cursor
  137628. */
  137629. private raiseOnChange;
  137630. /**
  137631. * Executes a function on change
  137632. * @param f A path cursor onchange callback
  137633. * @returns This path cursor
  137634. */
  137635. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137636. }
  137637. }
  137638. declare module BABYLON {
  137639. /** @hidden */
  137640. export var blurPixelShader: {
  137641. name: string;
  137642. shader: string;
  137643. };
  137644. }
  137645. declare module BABYLON {
  137646. /** @hidden */
  137647. export var pointCloudVertexDeclaration: {
  137648. name: string;
  137649. shader: string;
  137650. };
  137651. }
  137652. // Mixins
  137653. interface Window {
  137654. mozIndexedDB: IDBFactory;
  137655. webkitIndexedDB: IDBFactory;
  137656. msIndexedDB: IDBFactory;
  137657. webkitURL: typeof URL;
  137658. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137659. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137660. WebGLRenderingContext: WebGLRenderingContext;
  137661. MSGesture: MSGesture;
  137662. CANNON: any;
  137663. AudioContext: AudioContext;
  137664. webkitAudioContext: AudioContext;
  137665. PointerEvent: any;
  137666. Math: Math;
  137667. Uint8Array: Uint8ArrayConstructor;
  137668. Float32Array: Float32ArrayConstructor;
  137669. mozURL: typeof URL;
  137670. msURL: typeof URL;
  137671. VRFrameData: any; // WebVR, from specs 1.1
  137672. DracoDecoderModule: any;
  137673. setImmediate(handler: (...args: any[]) => void): number;
  137674. }
  137675. interface HTMLCanvasElement {
  137676. requestPointerLock(): void;
  137677. msRequestPointerLock?(): void;
  137678. mozRequestPointerLock?(): void;
  137679. webkitRequestPointerLock?(): void;
  137680. /** Track wether a record is in progress */
  137681. isRecording: boolean;
  137682. /** Capture Stream method defined by some browsers */
  137683. captureStream(fps?: number): MediaStream;
  137684. }
  137685. interface CanvasRenderingContext2D {
  137686. msImageSmoothingEnabled: boolean;
  137687. }
  137688. interface MouseEvent {
  137689. mozMovementX: number;
  137690. mozMovementY: number;
  137691. webkitMovementX: number;
  137692. webkitMovementY: number;
  137693. msMovementX: number;
  137694. msMovementY: number;
  137695. }
  137696. interface Navigator {
  137697. mozGetVRDevices: (any: any) => any;
  137698. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137699. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137700. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137701. webkitGetGamepads(): Gamepad[];
  137702. msGetGamepads(): Gamepad[];
  137703. webkitGamepads(): Gamepad[];
  137704. }
  137705. interface HTMLVideoElement {
  137706. mozSrcObject: any;
  137707. }
  137708. interface Math {
  137709. fround(x: number): number;
  137710. imul(a: number, b: number): number;
  137711. }
  137712. interface WebGLRenderingContext {
  137713. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137714. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137715. vertexAttribDivisor(index: number, divisor: number): void;
  137716. createVertexArray(): any;
  137717. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137718. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137719. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137720. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137721. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137722. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137723. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137724. // Queries
  137725. createQuery(): WebGLQuery;
  137726. deleteQuery(query: WebGLQuery): void;
  137727. beginQuery(target: number, query: WebGLQuery): void;
  137728. endQuery(target: number): void;
  137729. getQueryParameter(query: WebGLQuery, pname: number): any;
  137730. getQuery(target: number, pname: number): any;
  137731. MAX_SAMPLES: number;
  137732. RGBA8: number;
  137733. READ_FRAMEBUFFER: number;
  137734. DRAW_FRAMEBUFFER: number;
  137735. UNIFORM_BUFFER: number;
  137736. HALF_FLOAT_OES: number;
  137737. RGBA16F: number;
  137738. RGBA32F: number;
  137739. R32F: number;
  137740. RG32F: number;
  137741. RGB32F: number;
  137742. R16F: number;
  137743. RG16F: number;
  137744. RGB16F: number;
  137745. RED: number;
  137746. RG: number;
  137747. R8: number;
  137748. RG8: number;
  137749. UNSIGNED_INT_24_8: number;
  137750. DEPTH24_STENCIL8: number;
  137751. MIN: number;
  137752. MAX: number;
  137753. /* Multiple Render Targets */
  137754. drawBuffers(buffers: number[]): void;
  137755. readBuffer(src: number): void;
  137756. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137757. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137758. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137759. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137760. // Occlusion Query
  137761. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137762. ANY_SAMPLES_PASSED: number;
  137763. QUERY_RESULT_AVAILABLE: number;
  137764. QUERY_RESULT: number;
  137765. }
  137766. interface WebGLProgram {
  137767. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137768. }
  137769. interface EXT_disjoint_timer_query {
  137770. QUERY_COUNTER_BITS_EXT: number;
  137771. TIME_ELAPSED_EXT: number;
  137772. TIMESTAMP_EXT: number;
  137773. GPU_DISJOINT_EXT: number;
  137774. QUERY_RESULT_EXT: number;
  137775. QUERY_RESULT_AVAILABLE_EXT: number;
  137776. queryCounterEXT(query: WebGLQuery, target: number): void;
  137777. createQueryEXT(): WebGLQuery;
  137778. beginQueryEXT(target: number, query: WebGLQuery): void;
  137779. endQueryEXT(target: number): void;
  137780. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137781. deleteQueryEXT(query: WebGLQuery): void;
  137782. }
  137783. interface WebGLUniformLocation {
  137784. _currentState: any;
  137785. }
  137786. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137787. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137788. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137789. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137790. interface WebGLRenderingContext {
  137791. readonly RASTERIZER_DISCARD: number;
  137792. readonly DEPTH_COMPONENT24: number;
  137793. readonly TEXTURE_3D: number;
  137794. readonly TEXTURE_2D_ARRAY: number;
  137795. readonly TEXTURE_COMPARE_FUNC: number;
  137796. readonly TEXTURE_COMPARE_MODE: number;
  137797. readonly COMPARE_REF_TO_TEXTURE: number;
  137798. readonly TEXTURE_WRAP_R: number;
  137799. readonly HALF_FLOAT: number;
  137800. readonly RGB8: number;
  137801. readonly RED_INTEGER: number;
  137802. readonly RG_INTEGER: number;
  137803. readonly RGB_INTEGER: number;
  137804. readonly RGBA_INTEGER: number;
  137805. readonly R8_SNORM: number;
  137806. readonly RG8_SNORM: number;
  137807. readonly RGB8_SNORM: number;
  137808. readonly RGBA8_SNORM: number;
  137809. readonly R8I: number;
  137810. readonly RG8I: number;
  137811. readonly RGB8I: number;
  137812. readonly RGBA8I: number;
  137813. readonly R8UI: number;
  137814. readonly RG8UI: number;
  137815. readonly RGB8UI: number;
  137816. readonly RGBA8UI: number;
  137817. readonly R16I: number;
  137818. readonly RG16I: number;
  137819. readonly RGB16I: number;
  137820. readonly RGBA16I: number;
  137821. readonly R16UI: number;
  137822. readonly RG16UI: number;
  137823. readonly RGB16UI: number;
  137824. readonly RGBA16UI: number;
  137825. readonly R32I: number;
  137826. readonly RG32I: number;
  137827. readonly RGB32I: number;
  137828. readonly RGBA32I: number;
  137829. readonly R32UI: number;
  137830. readonly RG32UI: number;
  137831. readonly RGB32UI: number;
  137832. readonly RGBA32UI: number;
  137833. readonly RGB10_A2UI: number;
  137834. readonly R11F_G11F_B10F: number;
  137835. readonly RGB9_E5: number;
  137836. readonly RGB10_A2: number;
  137837. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137838. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137839. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137840. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137841. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137842. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137843. 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;
  137844. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137845. readonly TRANSFORM_FEEDBACK: number;
  137846. readonly INTERLEAVED_ATTRIBS: number;
  137847. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137848. createTransformFeedback(): WebGLTransformFeedback;
  137849. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137850. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137851. beginTransformFeedback(primitiveMode: number): void;
  137852. endTransformFeedback(): void;
  137853. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137854. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137855. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137856. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137857. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137858. }
  137859. interface ImageBitmap {
  137860. readonly width: number;
  137861. readonly height: number;
  137862. close(): void;
  137863. }
  137864. interface WebGLQuery extends WebGLObject {
  137865. }
  137866. declare var WebGLQuery: {
  137867. prototype: WebGLQuery;
  137868. new(): WebGLQuery;
  137869. };
  137870. interface WebGLSampler extends WebGLObject {
  137871. }
  137872. declare var WebGLSampler: {
  137873. prototype: WebGLSampler;
  137874. new(): WebGLSampler;
  137875. };
  137876. interface WebGLSync extends WebGLObject {
  137877. }
  137878. declare var WebGLSync: {
  137879. prototype: WebGLSync;
  137880. new(): WebGLSync;
  137881. };
  137882. interface WebGLTransformFeedback extends WebGLObject {
  137883. }
  137884. declare var WebGLTransformFeedback: {
  137885. prototype: WebGLTransformFeedback;
  137886. new(): WebGLTransformFeedback;
  137887. };
  137888. interface WebGLVertexArrayObject extends WebGLObject {
  137889. }
  137890. declare var WebGLVertexArrayObject: {
  137891. prototype: WebGLVertexArrayObject;
  137892. new(): WebGLVertexArrayObject;
  137893. };
  137894. // Type definitions for WebVR API
  137895. // Project: https://w3c.github.io/webvr/
  137896. // Definitions by: six a <https://github.com/lostfictions>
  137897. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137898. interface VRDisplay extends EventTarget {
  137899. /**
  137900. * Dictionary of capabilities describing the VRDisplay.
  137901. */
  137902. readonly capabilities: VRDisplayCapabilities;
  137903. /**
  137904. * z-depth defining the far plane of the eye view frustum
  137905. * enables mapping of values in the render target depth
  137906. * attachment to scene coordinates. Initially set to 10000.0.
  137907. */
  137908. depthFar: number;
  137909. /**
  137910. * z-depth defining the near plane of the eye view frustum
  137911. * enables mapping of values in the render target depth
  137912. * attachment to scene coordinates. Initially set to 0.01.
  137913. */
  137914. depthNear: number;
  137915. /**
  137916. * An identifier for this distinct VRDisplay. Used as an
  137917. * association point in the Gamepad API.
  137918. */
  137919. readonly displayId: number;
  137920. /**
  137921. * A display name, a user-readable name identifying it.
  137922. */
  137923. readonly displayName: string;
  137924. readonly isConnected: boolean;
  137925. readonly isPresenting: boolean;
  137926. /**
  137927. * If this VRDisplay supports room-scale experiences, the optional
  137928. * stage attribute contains details on the room-scale parameters.
  137929. */
  137930. readonly stageParameters: VRStageParameters | null;
  137931. /**
  137932. * Passing the value returned by `requestAnimationFrame` to
  137933. * `cancelAnimationFrame` will unregister the callback.
  137934. * @param handle Define the hanle of the request to cancel
  137935. */
  137936. cancelAnimationFrame(handle: number): void;
  137937. /**
  137938. * Stops presenting to the VRDisplay.
  137939. * @returns a promise to know when it stopped
  137940. */
  137941. exitPresent(): Promise<void>;
  137942. /**
  137943. * Return the current VREyeParameters for the given eye.
  137944. * @param whichEye Define the eye we want the parameter for
  137945. * @returns the eye parameters
  137946. */
  137947. getEyeParameters(whichEye: string): VREyeParameters;
  137948. /**
  137949. * Populates the passed VRFrameData with the information required to render
  137950. * the current frame.
  137951. * @param frameData Define the data structure to populate
  137952. * @returns true if ok otherwise false
  137953. */
  137954. getFrameData(frameData: VRFrameData): boolean;
  137955. /**
  137956. * Get the layers currently being presented.
  137957. * @returns the list of VR layers
  137958. */
  137959. getLayers(): VRLayer[];
  137960. /**
  137961. * Return a VRPose containing the future predicted pose of the VRDisplay
  137962. * when the current frame will be presented. The value returned will not
  137963. * change until JavaScript has returned control to the browser.
  137964. *
  137965. * The VRPose will contain the position, orientation, velocity,
  137966. * and acceleration of each of these properties.
  137967. * @returns the pose object
  137968. */
  137969. getPose(): VRPose;
  137970. /**
  137971. * Return the current instantaneous pose of the VRDisplay, with no
  137972. * prediction applied.
  137973. * @returns the current instantaneous pose
  137974. */
  137975. getImmediatePose(): VRPose;
  137976. /**
  137977. * The callback passed to `requestAnimationFrame` will be called
  137978. * any time a new frame should be rendered. When the VRDisplay is
  137979. * presenting the callback will be called at the native refresh
  137980. * rate of the HMD. When not presenting this function acts
  137981. * identically to how window.requestAnimationFrame acts. Content should
  137982. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137983. * asynchronously from other displays and at differing refresh rates.
  137984. * @param callback Define the eaction to run next frame
  137985. * @returns the request handle it
  137986. */
  137987. requestAnimationFrame(callback: FrameRequestCallback): number;
  137988. /**
  137989. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137990. * Repeat calls while already presenting will update the VRLayers being displayed.
  137991. * @param layers Define the list of layer to present
  137992. * @returns a promise to know when the request has been fulfilled
  137993. */
  137994. requestPresent(layers: VRLayer[]): Promise<void>;
  137995. /**
  137996. * Reset the pose for this display, treating its current position and
  137997. * orientation as the "origin/zero" values. VRPose.position,
  137998. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137999. * updated when calling resetPose(). This should be called in only
  138000. * sitting-space experiences.
  138001. */
  138002. resetPose(): void;
  138003. /**
  138004. * The VRLayer provided to the VRDisplay will be captured and presented
  138005. * in the HMD. Calling this function has the same effect on the source
  138006. * canvas as any other operation that uses its source image, and canvases
  138007. * created without preserveDrawingBuffer set to true will be cleared.
  138008. * @param pose Define the pose to submit
  138009. */
  138010. submitFrame(pose?: VRPose): void;
  138011. }
  138012. declare var VRDisplay: {
  138013. prototype: VRDisplay;
  138014. new(): VRDisplay;
  138015. };
  138016. interface VRLayer {
  138017. leftBounds?: number[] | Float32Array | null;
  138018. rightBounds?: number[] | Float32Array | null;
  138019. source?: HTMLCanvasElement | null;
  138020. }
  138021. interface VRDisplayCapabilities {
  138022. readonly canPresent: boolean;
  138023. readonly hasExternalDisplay: boolean;
  138024. readonly hasOrientation: boolean;
  138025. readonly hasPosition: boolean;
  138026. readonly maxLayers: number;
  138027. }
  138028. interface VREyeParameters {
  138029. /** @deprecated */
  138030. readonly fieldOfView: VRFieldOfView;
  138031. readonly offset: Float32Array;
  138032. readonly renderHeight: number;
  138033. readonly renderWidth: number;
  138034. }
  138035. interface VRFieldOfView {
  138036. readonly downDegrees: number;
  138037. readonly leftDegrees: number;
  138038. readonly rightDegrees: number;
  138039. readonly upDegrees: number;
  138040. }
  138041. interface VRFrameData {
  138042. readonly leftProjectionMatrix: Float32Array;
  138043. readonly leftViewMatrix: Float32Array;
  138044. readonly pose: VRPose;
  138045. readonly rightProjectionMatrix: Float32Array;
  138046. readonly rightViewMatrix: Float32Array;
  138047. readonly timestamp: number;
  138048. }
  138049. interface VRPose {
  138050. readonly angularAcceleration: Float32Array | null;
  138051. readonly angularVelocity: Float32Array | null;
  138052. readonly linearAcceleration: Float32Array | null;
  138053. readonly linearVelocity: Float32Array | null;
  138054. readonly orientation: Float32Array | null;
  138055. readonly position: Float32Array | null;
  138056. readonly timestamp: number;
  138057. }
  138058. interface VRStageParameters {
  138059. sittingToStandingTransform?: Float32Array;
  138060. sizeX?: number;
  138061. sizeY?: number;
  138062. }
  138063. interface Navigator {
  138064. getVRDisplays(): Promise<VRDisplay[]>;
  138065. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  138066. }
  138067. interface Window {
  138068. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  138069. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  138070. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  138071. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  138072. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  138073. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  138074. }
  138075. interface Gamepad {
  138076. readonly displayId: number;
  138077. }
  138078. type XRSessionMode =
  138079. | "inline"
  138080. | "immersive-vr"
  138081. | "immersive-ar";
  138082. type XRReferenceSpaceType =
  138083. | "viewer"
  138084. | "local"
  138085. | "local-floor"
  138086. | "bounded-floor"
  138087. | "unbounded";
  138088. type XREnvironmentBlendMode =
  138089. | "opaque"
  138090. | "additive"
  138091. | "alpha-blend";
  138092. type XRVisibilityState =
  138093. | "visible"
  138094. | "visible-blurred"
  138095. | "hidden";
  138096. type XRHandedness =
  138097. | "none"
  138098. | "left"
  138099. | "right";
  138100. type XRTargetRayMode =
  138101. | "gaze"
  138102. | "tracked-pointer"
  138103. | "screen";
  138104. type XREye =
  138105. | "none"
  138106. | "left"
  138107. | "right";
  138108. interface XRSpace extends EventTarget {
  138109. }
  138110. interface XRRenderState {
  138111. depthNear?: number;
  138112. depthFar?: number;
  138113. inlineVerticalFieldOfView?: number;
  138114. baseLayer?: XRWebGLLayer;
  138115. }
  138116. interface XRInputSource {
  138117. handedness: XRHandedness;
  138118. targetRayMode: XRTargetRayMode;
  138119. targetRaySpace: XRSpace;
  138120. gripSpace: XRSpace | undefined;
  138121. gamepad: Gamepad | undefined;
  138122. profiles: Array<string>;
  138123. }
  138124. interface XRSession extends XRAnchorCreator {
  138125. addEventListener: Function;
  138126. removeEventListener: Function;
  138127. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  138128. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  138129. requestAnimationFrame: Function;
  138130. end(): Promise<void>;
  138131. renderState: XRRenderState;
  138132. inputSources: Array<XRInputSource>;
  138133. // AR hit test
  138134. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  138135. updateWorldTrackingState(options: {
  138136. planeDetectionState?: { enabled: boolean; }
  138137. }): void;
  138138. }
  138139. interface XRReferenceSpace extends XRSpace {
  138140. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  138141. onreset: any;
  138142. }
  138143. type XRPlaneSet = Set<XRPlane>;
  138144. type XRAnchorSet = Set<XRAnchor>;
  138145. interface XRFrame {
  138146. session: XRSession;
  138147. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  138148. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  138149. // Anchors
  138150. trackedAnchors?: XRAnchorSet;
  138151. // Planes
  138152. worldInformation: {
  138153. detectedPlanes?: XRPlaneSet;
  138154. };
  138155. }
  138156. interface XRViewerPose extends XRPose {
  138157. views: Array<XRView>;
  138158. }
  138159. interface XRPose {
  138160. transform: XRRigidTransform;
  138161. emulatedPosition: boolean;
  138162. }
  138163. interface XRWebGLLayerOptions {
  138164. antialias?: boolean;
  138165. depth?: boolean;
  138166. stencil?: boolean;
  138167. alpha?: boolean;
  138168. multiview?: boolean;
  138169. framebufferScaleFactor?: number;
  138170. }
  138171. declare var XRWebGLLayer: {
  138172. prototype: XRWebGLLayer;
  138173. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  138174. };
  138175. interface XRWebGLLayer {
  138176. framebuffer: WebGLFramebuffer;
  138177. framebufferWidth: number;
  138178. framebufferHeight: number;
  138179. getViewport: Function;
  138180. }
  138181. declare class XRRigidTransform {
  138182. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  138183. position: DOMPointReadOnly;
  138184. orientation: DOMPointReadOnly;
  138185. matrix: Float32Array;
  138186. inverse: XRRigidTransform;
  138187. }
  138188. interface XRView {
  138189. eye: XREye;
  138190. projectionMatrix: Float32Array;
  138191. transform: XRRigidTransform;
  138192. }
  138193. interface XRInputSourceChangeEvent {
  138194. session: XRSession;
  138195. removed: Array<XRInputSource>;
  138196. added: Array<XRInputSource>;
  138197. }
  138198. interface XRInputSourceEvent extends Event {
  138199. readonly frame: XRFrame;
  138200. readonly inputSource: XRInputSource;
  138201. }
  138202. // Experimental(er) features
  138203. declare class XRRay {
  138204. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  138205. origin: DOMPointReadOnly;
  138206. direction: DOMPointReadOnly;
  138207. matrix: Float32Array;
  138208. }
  138209. interface XRHitResult {
  138210. hitMatrix: Float32Array;
  138211. }
  138212. interface XRAnchor {
  138213. // remove?
  138214. id?: string;
  138215. anchorSpace: XRSpace;
  138216. lastChangedTime: number;
  138217. detach(): void;
  138218. }
  138219. interface XRPlane extends XRAnchorCreator {
  138220. orientation: "Horizontal" | "Vertical";
  138221. planeSpace: XRSpace;
  138222. polygon: Array<DOMPointReadOnly>;
  138223. lastChangedTime: number;
  138224. }
  138225. interface XRAnchorCreator {
  138226. // AR Anchors
  138227. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  138228. }